OpenCV with 2 cameras VC++

南楼画角 提交于 2020-01-11 06:36:09

问题


I am importing a source code for stereo visions. The next code of the author works. It takes two cameras sources. I have two different cameras currently and i receive images. Both works. It crashes at capture2. interesting part is that if i change the orders of the webcams(Unplugging them and invert the orders) the first camera it will be the second one. We it doesn't work? I tested also with Windows XP sp3 and Windows 7 X64. The same problem.

//---------Starting WebCam----------
    capture1= cvCaptureFromCAM(1);
    assert(capture1!=NULL); cvWaitKey(100);
    capture2= cvCaptureFromCAM(2);
    assert(capture2!=NULL);

Also If i use -1 for paramters the just give me the first one(all the time).

Or any method to capture two camers using function cvCaptureFrom


回答1:


Firstly the cameras are generally numbered from 0 - is this just the problem?

Secondly, directshow and multiple USB webcams is notoriously bad in windows. Sometimes it will work with two identical camera, sometimes only if they are different.

You can also try a delay between initialising the cameras, sometimes one will lock the capture stream until it is sending data, preventing the other being detected.

Often the drivers assume they are the only camera and make incorrect calls to lock up the entire capture graph. This isn't helped by it being extremely complicated to write correct drivers+fdirectshow filters in Windows




回答2:


some mother board can not work with some usb 2.0 cameras. one usb 2.0 camera take 40-60% of usb controller. solution is connect second usb 2.0 camera from pci2usb controller




回答3:


Get 2 PS3 Eyes, around EUR 10 each, and the free codelaboratories.com SDK, this gets you support up to 2 cameras using C, C#, Java, and AS3 incl. examples etc. You also get FIXED frame rates up 75 fps @ 640*480. Their free driver only version 5.1.1.0177 provides decent DirectShow component, but for a single camera only.

COmment for the rest: Multi-cam DirectShow drivers should be a default for any manufacturer, not providing this is a direct failure to implement THE VERY BASIC PORPUSE AND FEATURE OF USB as an interface. It is also VERY EASY to implement, compared to implementing the driver itself for a particular sensor / chipset.

Alternatives that are confirmed to work in identical pairs (via DirectShow):

  • Microsoft Lifecam HD Cinema (use general UVC driver if you can, less limited fps)
  • Logitech Webcam Pro 9000 (not to be confused with QuickCam Pro 9000, which DOES NOT work)
  • Creative VF0220
  • Creative VF0330
  • Canyon WCAMN-1N

If you're serious about your work, get a pair of machine vision cameras to get PERFORMANCE. Cheapest on the market, with german engineering quality, CCD, CMOS, mono, colour, GigE (ethernet), USB, FireWire, excellent range of dedicated drivers:

http://www.theimagingsource.com



来源:https://stackoverflow.com/questions/10194033/opencv-with-2-cameras-vc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!