Note that there are some explanatory texts on larger screens.

plurals
  1. POPython OpenCV stereo cam blind one?
    primarykey
    data
    text
    <p>My system is Linux HPDebian 3.2.0-2-amd64 #1 SMP x86_64 GNU/Linux Python 2.7, OpenCV2. I can use only 1 cam. </p> <p>My question is How to get a video feed from 2 cams? I had read C++ version but I prefer python. It is easier for non-programmer.</p> <p>I don't understand why my webcam works only Wleft, but WRight is blank-gray windows. And at the command line </p> <blockquote> <p>VIDIOC_QBUF: Invalid argument </p> </blockquote> <p>continue to flood my command line.</p> <p>OpenCV-Python has a ready-made package of stereo program, but I need to access the elements of each cam because I want to test my algorithm.</p> <p>My attempt:</p> <pre><code>''' Simple Stereo feed ''' import cv cv.NamedWindow("wLeft", cv.CV_WINDOW_AUTOSIZE) cv.NamedWindow("wRight", cv.CV_WINDOW_AUTOSIZE) captureL = cv.CaptureFromCAM(0) captureR = cv.CaptureFromCAM(1) def repeat(): frameL = cv.QueryFrame(captureL) cv.ShowImage("wLeft", frameL) frameR = cv.QueryFrame(captureR) cv.ShowImage("wRight", frameR) while True: repeat() if cv.WaitKey(33)==27: break cv.DestroyAllWindows() </code></pre> <h2>Update 1</h2> <p>Answer to your questions:</p> <ol> <li>In current OpenCV-Python. I can not find any command, but I when I comment out the Leftcam, Rightcam works. And vice versa.</li> <li><p>Yes, I just found it!. I redirected command and carefully searched.</p> <blockquote> <p>libv4l2: error turning on stream: No space left on device</p> </blockquote></li> <li><p>They are identical. OKER193.</p></li> <li>I can use it just only 1 cam Left or Right only. Can not get a video feed from two of them simulataneously.</li> <li><p>I have no hubs. I don't know it is a real port or not, but I connect it left and right of my notebook.</p> <p><a href="http://opencv-users.1802565.n2.nabble.com/Multiple-Camera-Read-Error-td7001563.html" rel="nofollow noreferrer">http://opencv-users.1802565.n2.nabble.com/Multiple-Camera-Read-Error-td7001563.html</a></p></li> </ol> <p>I tried cv.ReleaseCapture()</p> <pre><code>def repeat(): frameL = cv.QueryFrame(captureL) cv.ShowImage("wLeft", frameL) cv.ReleaseCapture(captureL) frameR = cv.QueryFrame(captureR) cv.ShowImage("wRight", frameR) cv.ReleaseCapture(captureR) </code></pre> <p>I got the errors:</p> <pre><code>... VIDIOC_QUERYMENU: Invalid argument //Many lines ... Traceback (most recent call last): File "55.py", line 19, in &lt;module&gt; repeat() File "55.py", line 13, in repeat cv.ReleaseCapture(captureL) AttributeError: 'module' object has no attribute 'ReleaseCapture' </code></pre> <p>I really wonder <br><a href="http://opencv.willowgarage.com/documentation/python/highgui_reading_and_writing_images_and_video.html?highlight=releasecapture" rel="nofollow noreferrer">http://opencv.willowgarage.com/documentation/python/highgui_reading_and_writing_images_and_video.html?highlight=releasecapture</a><br> CaptureFromCAM last line say To release the structure, use ReleaseCapture. This function may be dropped out.</p> <p>Wandering around and found this <br><a href="https://superuser.com/questions/431759/using-multiple-usb-webcams-in-linux" title="this">https://superuser.com/questions/431759/using-multiple-usb-webcams-in-linux</a><br></p> <p>Then I check my resolution per cam is 640x480 as a normal. And my webcam is 1.1/2.0 USB interface.</p> <pre><code>root@HPDebian:~# v4l2-ctl -d /dev/video0 --list-formats ioctl: VIDIOC_ENUM_FMT Index : 0 Type : Video Capture Pixel Format: 'YUYV' Name : YUV 4:2:2 (YUYV) </code></pre> <p>Then check another cam</p> <pre><code>root@HPDebian:~# v4l2-ctl -d /dev/video1 --list-formats ioctl: VIDIOC_ENUM_FMT Index : 0 Type : Video Capture Pixel Format: 'YUYV' Name : YUV 4:2:2 (YUYV) </code></pre> <p>At this point I am not sure about my USB notebook. It may be a hub inside. I will try reduce the resolution and post my result again.</p> <h2>Update 2</h2> <p>Try time.sleep(1) from Martin:</p> <pre><code>VIDIOC_QUERYMENU: Invalid argument //Many lines libv4l2: error setting pixformat: Device or resource busy HIGHGUI ERROR: libv4l unable to ioctl S_FMT libv4l2: error setting pixformat: Device or resource busy libv4l1: error setting pixformat: Device or resource busy HIGHGUI ERROR: libv4l unable to ioctl VIDIOCSPICT libv4l2: error turning on stream: No space left on device VIDIOC_STREAMON: No space left on device VIDIOC_QBUF: Invalid argument //Many lines until Ctrl C </code></pre> <p>I will try this again in M$ xp.</p> <h2>Update 3</h2> <p>Still using Linux. M$ xp is busy. This time I del the c1 and c2. Since I don't know how to release camera. I believe that API of driver I use is allow only 1 device access kernel per time. So I try this one.</p> <pre><code>def repeat1(): c1 = cv.CreateCameraCapture(0) i1 = cv.QueryFrame(c1) cv.ShowImage("WebCAM1", i1) del(c1) def repeat2(): c2 = cv.CreateCameraCapture(1) i2 = cv.QueryFrame(c2) cv.ShowImage("WebCAM2", i2) del(c2) </code></pre> <p>Program run very sluggish and WebCAM1 is distorted, WebCAM2 is not.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload