- Keypoints and compute descriptors in the loaded image, image, with ORB are as follows:
orb = cv2.ORB()
keypoints = orb.detect(image, None)
keypoints, descriptors = orb.compute(image, keypoints)
- Previously detected keypoints, keypoints, are as follows:
image_keypoints = cv2.drawKeypoints(image, keypoints, None, color=(255, 0, 255), flags=0)
To draw detected keypoints, the cv2.drawKeypoints() function is used.
- The BFMatcher object and matching of the descriptors, descriptors_1 and descriptors_2, which have been previously calculated, is created as follows:
bf_matcher = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
bf_matches = bf_matcher.match(descriptors_1, descriptors_2)
- The first 20 matches of the matches that were sorted before is as follows:
bf_matches = sorted(bf_matches, key=lambda x: x.distance)
result = cv2.drawMatches(image_query, keypoints_1, image_scene, keypoints_2, bf_matches[:20], None, matchColor=(255, 255, 0), singlePointColor=(255, 0, 255), flags=0)
To draw the computed matches, cv2.drawMatches() is used.
- Markers using ArUco in the image gray_frame are detected as follows:
corners, ids, rejected_corners = cv2.aruco.detectMarkers(gray_frame, aruco_dictionary, parameters=parameters)
To detect markers, the cv2.aruco.detectMarkers() function is used.
- The detected markers when using ArUco are as follows:
frame = cv2.aruco.drawDetectedMarkers(image=frame, corners=corners, ids=ids, borderColor=(0, 255, 0))
To draw markers, the cv2.aruco.drawDetectedMarkers() function is used.
- The rejected markers when using Aruco are as follows:
frame = cv2.aruco.drawDetectedMarkers(image=frame, corners=rejected_corners, borderColor=(0, 0, 255))
To draw markers, the cv2.aruco.drawDetectedMarkers() function is also used.
- Detect and decode a QR code contained in the image with the following code:
data, bbox, rectified_qr_code = qr_code_detector.detectAndDecode(image)