(array([[[1023., 4862.],
[1023., 5080.],
[ 806., 5080.],
[ 807., 4861.]]], dtype=float32), array([[[2339., 4865.],
[2340., 5083.],
[2125., 5085.],
[2124., 4868.]]], dtype=float32), array([[[1030., 299.],
[1028., 511.],
[ 815., 511.],
[ 817., 298.]]], dtype=float32), array([[[2333., 308.],
[2333., 518.],
[2119., 519.],
[2119., 306.]]], dtype=float32))
< /code>
array([[12],
[13],
[14],
[11]], dtype=int32)
< /code>
In order to undistort an image, I need the camera matrix and distance coefficients. From a comment in this stackoverflow question, camera matrix and distance coefficients can initially be None when generating with cv.aruco.calibrateCameraAruco(...)[/code].
Документы на Calibratecameraaruco можно найти здесь. Требуемые входы: < /p>
Углы: вектор обнаруженных углов маркеров во всех кадрах. Углы должны иметь тот же формат, возвращаемый с помощью маркеров DecectMarkers (см. Detectmarers). < /Li>
Идентификаторы: список идентификаторов для каждого маркера в углах
счетчик маркеров в каждом кадре, чтобы углы и идентификаторы можно было разделить < /li>
. Матрица. < /li>
Cameramatrix (не может быть изначально или пустой, и она будет заполнена функцией) < /li>
Distcoeffs (то же самое, как 5. Cameramatrix) < /li>
< /ol>
для ввода объекта платы в точке 3 выше, это требует < /p>
для ввода объекта платы). /> Objpoints: массив объектных точек всех углов маркеров в доске < /li>
Словарь: Словарь маркеров, используемый для этой доски < /li>
ID: вектор идентификаторов маркеров в совет. Из этого урока точки объекта могут быть инициализированы со значениями Z, установленными в 0. Однако они используют CV.SolvePnp, который требует камматрицы и дискаеффа, Как я должен генерировать камматрию и дистанцию, используя CalibrateCameraaruco?ml = marker_length # = 0.0127 meters = 0.5 inches
obj_points = np.array([np.array([-ml/2, ml/2, 0], dtype=np.float32),
np.array([ml/2, ml/2, 0], dtype=np.float32),
np.array([ml/2, -ml/2, 0], dtype=np.float32),
np.array([-ml/2, -ml/2, 0], dtype=np.float32)], dtype=np.float32)
< /code>
However I have four markers in frame, I can't reuse the same object points can I? How do I initialize object points so I can create a board object? I tried filling it with dumby values just to see if I could get some matrix values from calibrateCameraAruco, but I get this error:
dumby_obj_points_list = [ obj_points, obj_points+[4*marker_length, 2*marker_length, 0], obj_points+[0, -2*marker_length, 0], obj_points+[4*marker_length, -2*marker_length, 0] ]
board = cv.aruco.Board([objPoints], ardict, ids)
< /code>
>>> cv.aruco.Board(dumby_obj_points_list, ardict, ids)
cv2.error: OpenCV(4.11.0) /build/source/modules/objdetect/src/aruco/aruco_board.cpp:163: error: (-215:Assertion failed) corners_mat.total() == 4 in function 'Board'
< /code>
If I instead try and use a GridBoard object instead, with dumby separation values, I get:
dumby_gridboard = cv.aruco.GridBoard((2,2), marker_length, 2*marker_length, ardict)
>>> cv.aruco.calibrateCameraAruco(corners, ids, 4, dumby_gridboard, gray.shape, cameraMatrix, distCoeffs)
cv2.error: OpenCV(4.11.0) /build/source/opencv_contrib/aruco/src/aruco_calib.cpp:33: error: (-215:Assertion failed) nMarkersInThisFrame > 0 in function 'calibrateCameraAruco'
< /code>
Even if I generate a GridBoard directly without taking a photo, and use that exact gridboard in cv.calibrateCameraAruco I get the same error, how come opencv detects 0 markers in frame?
The Input image is provided here:

The result of cv2.detectMarkers is here (the green/blue/red outline trace is thin w.r.t the image)

Подробнее здесь: https://stackoverflow.com/questions/797 ... efficients