Код: Выделить всё
success, rvec, tvec = cv2.solvePnP(points_3d, points_2d, camera_mat, dist_coeffs, cv2.SOLVEPNP_SQPNP)
Код: Выделить всё
def get_reproj_error(self, obj_points, actual_img_points):
"""Measures how accurate the calibration parameters are based of the arguments passed to this method"""
reproj_error = 0
for i, (rvec, tvec) in enumerate(zip(self._rvecs, self._tvecs)):
imgpoints2, _ = cv2.projectPoints(obj_points, rvec, tvec, self._camera_matrix, self._dist_coeffs)
imgpoints2 = np.reshape(imgpoints2, (len(imgpoints2), 2))
error = np.linalg.norm(actual_img_points[i] - imgpoints2) / len(imgpoints2)
reproj_error += error
reproj_error /= len(obj_points)
return reproj_error
Я получаю ошибку репетиции около 4.6. Я не уверен, что это хорошо или плохо, но когда я вижу результаты при графике, точки, рассчитанные из вычисленных векторов вращения и трансляционных векторов, вообще не соответствуют исходным 2D -точкам. Если вам нужно что -нибудь еще, чтобы помочь мне решить это, пожалуйста, дайте мне знать.
Подробнее здесь: https://stackoverflow.com/questions/797 ... points-cam