Ask Your Question
0

Why python "line()" draw one line when called three times ?

asked 2014-03-26 10:54:48 -0600

Guido gravatar image

Hi,

I am trying to draw a coordinate frame on an image from some points. The code is the following

def draw(img, corners):
points = tuple(map(tuple, corners))
img = cv2.line(img, points[0], points[1], (0,0,255), 3)
img = cv2.line(img, points[0], points[2], (0,255,0), 3)
img = cv2.line(img, points[0], points[3], (255,0,0), 3)
return img

However, only the first of the three lines is drawn. Any idea on what is going wrong ?

Guido

edit retag flag offensive close merge delete

Comments

Make sure that your points are not equal or out of bound.

Haris gravatar imageHaris ( 2014-03-26 11:31:16 -0600 )edit

Alright I solve this, and there were two errors. First, I wasn't retrieving the returned image. Seconde cv2.line doesn't return an image (it returns none) I got misled by the opencv 3.0.0 documentation.

Guido gravatar imageGuido ( 2014-03-26 11:38:53 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-03-26 11:39:11 -0600

Guido gravatar image

updated 2014-03-26 11:41:06 -0600

Alright I solved this, and there were two errors. First, I wasn't retrieving the returned image. Second cv2.line doesn't return an image (it returns none) I got misled by the opencv 3.0.0 documentation.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-03-26 10:54:48 -0600

Seen: 279 times

Last updated: Mar 26 '14