bug found in a tutorial [closed]

asked 2014-08-12 03:31:43 -0600

lyl gravatar image

updated 2014-08-12 03:38:23 -0600

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
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-16 17:27:59.284259

Comments

2

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 :)

StevenPuttemans gravatar imageStevenPuttemans ( 2014-08-12 03:42:03 -0600 )edit

If you get the problem, then this topic can be closed down. Give me a signal for that!

StevenPuttemans gravatar imageStevenPuttemans ( 2014-08-12 03:43:25 -0600 )edit