本文整理匯總了Python中cv2.findCirclesGrid方法的典型用法代碼示例。如果您正苦於以下問題:Python cv2.findCirclesGrid方法的具體用法?Python cv2.findCirclesGrid怎麽用?Python cv2.findCirclesGrid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cv2
的用法示例。
在下文中一共展示了cv2.findCirclesGrid方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: live_calibrate
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import findCirclesGrid [as 別名]
def live_calibrate(camera, pattern_shape, n_matches_needed):
""" Find calibration parameters as the user moves a checkerboard in front of the camera """
print("Looking for %s checkerboard" % (pattern_shape,))
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
example_3d = np.zeros((pattern_shape[0] * pattern_shape[1], 3), np.float32)
example_3d[:, :2] = np.mgrid[0 : pattern_shape[1], 0 : pattern_shape[0]].T.reshape(-1, 2)
points_3d = []
points_2d = []
while len(points_3d) < n_matches_needed:
ret, frame = camera.cap.read()
assert ret
gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
ret, corners = cv2.findCirclesGrid(
gray_frame, pattern_shape, flags=cv2.CALIB_CB_ASYMMETRIC_GRID
)
cv2.imshow("camera", frame)
if ret:
points_3d.append(example_3d.copy())
points_2d.append(corners)
print("Found calibration %i of %i" % (len(points_3d), n_matches_needed))
drawn_frame = cv2.drawChessboardCorners(frame, pattern_shape, corners, ret)
cv2.imshow("calib", drawn_frame)
cv2.waitKey(10)
ret, camera_matrix, distortion_coefficients, _, _ = cv2.calibrateCamera(
points_3d, points_2d, gray_frame.shape[::-1], None, None
)
assert ret
return camera_matrix, distortion_coefficients
示例2: _circulargrid_image_points
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import findCirclesGrid [as 別名]
def _circulargrid_image_points(self,img,flags,blobDetector):
found, corners = cv2.findCirclesGrid(img,(self.pattern_columns,self.pattern_rows),
flags=flags,
blobDetector=blobDetector
)
return(found,corners)