RSS

Using Python & OpenCV to control WebCam, black window: problem and troubleshooting in a single code line

23 Apr

I recently involved in a project to capture images with webcam. I soon found that OpenCV seems to be the best solutions to program in Python.

For how to install Python and OpenCV, refer to the link here. However, I found that a black window pops and the captured images does not show up.

opencv

I googled, and a number of solutions do exist, some are funny, but do not work. Finally I found that editing a single line will troubleshoot the problem:

captured

The solution is to “import cv2.cv”, instead of “import cv”, The code shown in http://luugiathuy.com/2011/02/setup-opencv-for-python/ then works like a charm.

opencv2

Cheers and happy coding

About these ads
 
2 Comments

Posted by on April 23, 2012 in Programming

 

2 responses to “Using Python & OpenCV to control WebCam, black window: problem and troubleshooting in a single code line

  1. So Lopinto

    April 30, 2012 at 12:58 pm

    Thanks for the data on this subject, it’ll be actually helpful.

     
  2. Ales

    November 13, 2013 at 8:28 pm

    i’m using Win 7 64 bit with py 2.7 and open cv2 …
    But the image from webcam is alway black!

    i’m becoming crazy…

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 50 other followers

%d bloggers like this: