Ask Your Question
0

Python openCV drawing functions does not work?!

asked 2014-06-11 12:55:41 -0500

Hi, today I tried to draw a line in a window, this is the code I used.

import numpy as np import cv2

Create a black image

img = np.zeros((512,512,3), np.uint8)

Draw a diagonal blue line with thickness of 5 px

cv2.line(img,(0,0),(511,511),(255,0,0),5)

The problem is that when I run this, I get no errors and the Shell comes up and start running but the window to show the video never pops up or anything, nothing happens. Am I missing some plugin or something that I need to run this?

I got OpenCV and Matplotlib installed for Python.

Heelp please! =(

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-07-11 14:14:43 -0500

li8bot gravatar image

Actually I had the same problem.All you need to do is img = np.zeros((512,512,3), np.uint8) img1= cv2.line(img,(0,0),(511,511),(255,0,0),5)

Thats it..renaming the variable for line does the trick.Now you can use imshow to display the image. Do visit my blog li8bot for further info on opencv with python

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2014-06-11 12:55:41 -0500

Seen: 658 times

Last updated: Jul 11 '14