This is the camera matrix content:
[[1.39808931e+03 0.00000000e+00 1.05008177e+03]
[0.00000000e+00 1.39923210e+03 7.37656591e+02]
[0.00000000e+00 0.00000000e+00 1.00000000e+00]]
This is the relevant code:
corners, ids, rejectedImgPoints = aruco.detectMarkers(img, aruco.getPredefinedDictionary(aruco.DICT_4X4_1000))
retval, rvec, tvec = aruco.estimatePoseBoard( corners, ids, board, camera_matrix, dist_coeffs, None, None )
frame = aruco.drawAxis(img, camera_matrix, dist_coeffs, rvec, tvec, length=0.008 )
This is the error message:
cv2.error: OpenCV(4.5.2) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-i3ohmhl0\opencv\modules\calib3d\src\calibration.cpp:556: error: (-5:Bad argument) One of required arguments is not a valid matrix in function 'cvProjectPoints2Internal'
What is wrong?
the other arguments would be good to know too. values, shape
, dtype
, …
Sure.
- print(img) gives
[[[0 0 0]
[0 0 0]
[0 0 0]
...
[0 0 0]
[0 0 0]
[0 0 0]]
[[0 0 0]
[0 0 0]
[0 0 0]
...
[0 0 0]
[0 0 0]
[0 0 0]]
[[0 0 0]
[0 0 0]
[0 0 0]
...
[0 0 0]
[0 0 0]
[0 0 0]]
...
[[0 0 0]
[0 0 0]
[0 0 0]
...
[0 0 0]
[0 0 0]
[0 0 0]]
[[0 0 0]
[0 0 0]
[0 0 0]
...
[0 0 0]
[0 0 0]
[0 0 0]]
[[0 0 0]
[0 0 0]
[0 0 0]
...
[0 0 0]
[0 0 0]
[0 0 0]]]
-
print(dist_coeffs)
gives
[[-4.25085710e-01 2.29057132e-01 4.01520054e-04 -2.88108507e-04 -6.83859299e-02]]
-
print(rvec)
and print(tvec)
give None
-
print( numpy.shape (img) )
gives (4192, 3104, 3)
-
print( numpy.shape (camera_matrix) )
gives (3, 3)
-
print( numpy.shape (dist_coeffs) )
gives (1, 5)
-
print( numpy.shape (rvec) )
and print( numpy.shape (rvec) )
gives ()
.
-
print( numpy.dtype (rvec) )
and print( numpy.dtype (rvec) )
gives float64
.
estimate single markers. I doubt you actually have a board. you didn’t show the definition of board
.
the rvec and tvec being none tells me the function couldn’t do its job. retval is likely False
.
the image looks black around the corners. why is that? is it entirely black? what did you do to it? post the whole image. post source data. post the entire code.
Oh, I didn’t realize that error message simply meant markers were not detected. It seems like something more fundamental was wrong in the code. I increased source resolution and the board markers were detected as expected.
Thanks.
How should I implement the exception handling so that my code doesn’t simply crash when markers are not detected, but so that I also won’t be bypassing a real issue?
check return values.
check if things that should be numpy arrays are actually None
(identity comparison with None goes like: thing is None
or thing is not None
)
1 Like