rvecs and tvecs are NoneType?
I saw some python codes online for detecting aruco markers, and I combined them together. This is the code: https://github.com/czjczjczj1/aruco/b...
I wanted to draw the x-, y-, z-axis too, but I got an error saying:
for i in range(len(tvecs)):
TypeError: object of type 'NoneType' has no len()
So why rvecs and tvecs are NoneType? How can I get two arrays?
this means, your
tvecs
array is empty, it probably did not detect any marker before.for further help, please EDIT your question. we need to see, how you try to detect the marker(s), code, example image, etc.
@supra56@berak It's still not working. It said
for i in range(0, tvecs): TypeError: 'NoneType' object cannot be interpreted as an integer
Even I added something like
for i in range(0, 2):
it said
frame_axis_image = cv2.aruco.drawAxis(frame_detected_markers.copy(), mtx, dist, rvecs[i], tvecs[i], 0.05) TypeError: 'NoneType' object is not subscriptable
please check:
(https://github.com/czjczjczj1/aruco/b...)
@czjczjczj1. I just deleted it. I will rephase it. You cannot used len function to draw line. I f you want to draw a line , then us cv2.line.
it seems, that the 1st thing python noobs have to learn is:
(blindly copypasting shit is never an option !)
@czjczjczj1 Does this help?
cv2.aruco.drawAxis(frame
instead ofcv2.aruco..drawAxis(frame_detected_markers.copy()
Also don't forget
cv2.imshow('frame', frame)
I don't think it's None.
I know I'm silly, then what should I do?
@czjczjczj1. There is nothing wrong with ur code. I attempted from link. The reasoning why you getting an errored
TypeError: object of type 'NoneType' has no len()
, is because you need to add boolean for both.if ids is not None and len(ids) > 0:
. Btw, I'm using linux.It's working now, thank you very much for your help. By the way, it seems that the z-axis is not vertical to the marker. Why is that? @supra56 I would like to know the 3D distance between two markers, is this possible?