本文整理汇总了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)