Python Opencv camera select timeout

By : Meni
Source: Stackoverflow.com
Question!

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

Im using python 2.7.3, ubuntu and opencv.

Guys 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 stop to stream the camera! I hope you help me!

=Question 2(aditional)=========================== Well if you know i want to do a program thar can find objects in webcam using python! Some way?

By : Meni


Answers

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.

By : Virako


This video can help you solving your question :)
By: admin