3

=Question 1===========================

I'm using python 2.7.3, Ubuntu and opencv.

I used this script:

import sys, os
import pygtk, gtk, gobject
import pygst
import Image;
import cv;

camcapture = cv.CreateCameraCapture(0)
cv.SetCaptureProperty(camcapture,cv.CV_CAP_PROP_FRAME_WIDTH, 640)
cv.SetCaptureProperty(camcapture,cv.CV_CAP_PROP_FRAME_HEIGHT, 480);

if not camcapture:
    print "Error opening WebCAM"
    sys.exit(1)

while 1:
frame = cv.QueryFrame(camcapture)
if frame is None:
    break
    cv.ShowImage('Camera', frame)
    k=cv.WaitKey(1);

And I get this:

** (test.py:21226): WARNING **: The connection is closed
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
select timeout

And it stops to stream the camera! I hope you can help me!

=Question 2(additional)===========================

Do you know any Python program to find objects in a webcam image?

1 Answer 1

0

Try with

k=cv.WaitKey(20) 

or

k=cv.WaitKey(30)

The program could fail because you try to access too fast to the camera.

Question2: Look at Template.

2
  • Man tha second question i found a sample in opencv docs and i will test this waitkey thank you foir the feedback Oct 15, 2012 at 16:12
  • This helped the problem for me, but I still got select timeout errors after several seconds.
    – lazd
    May 18, 2013 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.