bug found in a tutorial [closed]
I think I have found a bug in this tutorial. It is focussed in this part:
def draw(img, corners, imgpts):
corner = tuple(corners[0].ravel())
img = cv2.line(img, corner, tuple(imgpts[0].ravel()), (255,0,0), 5)
img = cv2.line(img, corner, tuple(imgpts[1].ravel()), (0,255,0), 5)
img = cv2.line(img, corner, tuple(imgpts[2].ravel()), (0,0,255), 5)
return img
because cv2.line()
return none
, img will be nonetype. So the correct way should be:
def draw(img, corners, imgpts):
corner = tuple(corners[0].ravel())
cv2.line(img, corner, tuple(imgpts[0].ravel()), (255,0,0), 5)
cv2.line(img, corner, tuple(imgpts[1].ravel()), (0,255,0), 5)
cv2.line(img, corner, tuple(imgpts[2].ravel()), (0,0,255), 5)
return img
It is not a mistake. Your sample is from the 3.0 development branch where python functions will return objects instead of none and not by supplying them as empty elements like before. The difference is that you are probably using 2.4 as code. You can see the difference here for 2.4 and for master . So make sure you don't mix both up :)
If you get the problem, then this topic can be closed down. Give me a signal for that!