MatteiLuca
Posts: 4
Joined: Tue Jan 28, 2014 1:54 pm

Camera Module + Open cv

Tue Jan 28, 2014 2:52 pm

Hi, I'm an Italian student, so I'm sorry for my elementary English, however I hope that you can understand and help me to solve my problem.
I bought a Camera Module and I want try to capture imagines in a Python shell using IDLE . I installed the library opencv-2.4.8, but when I run the program the window of the program appears but I don't see nothing inside it.
There's only the gray background.
The program is:

#!/usr/bin/python

import cv2.cv as cv
import time

cv.NamedWindow("camera", 1)

capture = cv.CaptureFromCAM(0)

while True:
img = cv.QueryFrame(capture)
cv.ShowImage("camera", img)
if cv.WaitKey(10) == 27:
break
cv.DestroyAllWindows()

How can I do? Where is the problem?
thank you for the attention, I wait your answer.

TrevorAppleton
Posts: 74
Joined: Wed May 30, 2012 7:26 pm
Contact: Website

Re: Camera Module + Open cv

Tue Jan 28, 2014 4:49 pm

As a starting point I have written a tutorial on how to get started with Open CV and Python.

http://trevorappleton.blogspot.co.uk/20 ... pencv.html
Check out my blog post for Raspberry Pi and Python tutorials.

http://trevorappleton.blogspot.co.uk/

MatteiLuca
Posts: 4
Joined: Tue Jan 28, 2014 1:54 pm

Re: Camera Module + Open cv

Thu Jan 30, 2014 9:40 am

Initially thank you for the quick response. I try it and it works, unfortunately the acquisition of image is very slow. I need a higher frame because I have to do a imagine processing. What can I do?

samarth_i
Posts: 2
Joined: Thu Sep 05, 2013 4:24 pm

Re: Camera Module + Open cv

Fri Mar 28, 2014 2:24 am

Rather than capturing still images with system calls to 'simulate' a video, you can use the OpenCV 2.x C++ wrapper I wrote for the RPi camera module. This will be much faster (~20 fps for grayscale 320x240 frames)

This wrapper interfaces at the low level with the camera module and offers a VideoCapture-like object which you can use to capture frames in a loop.

You can find it on GitHub at: https://github.com/samarth-robo/RPi-OpenCV

Return to “Python”