I have: Linux laptop with built-in camera, 2 other cameras, OpenCV-based program.
I need: to pass the device number of those two cameras to the program automatically.
In OpenCV you open a camera with videoCapture.open(n);, where videoCapture is an object of a cv::VideoCapture and n is device number of the camera you wish to open. My program uses two webcams. Here OpenCV part of this question is over.
Usually this n is hard-coded or manually passed by user. I want to write a script that would automatically detect the device number of two desired cameras. But built-in camera is the obstacle.
When loaded, Linux defaults the device number of the built-in camera to 0. Two connected USB-cameras get the numbers 1 and 2 accordingly. And when you reboot the laptop you most probably get all the numbers mixed up, e.g. built-in camera - 1, 0 and 2 - for USB-cameras. And anyways I have to change the device numbers in the code when I switch the platfrom and execute the program on desktop which have no built-in cameras.
I thought I could write sh script that would parse an output of lsusb | grep Logitech (those two USB webcams are Logitech ones) and get the device number according to USB Bus number but that rebooting thing obstructs this.
I would appreciate any ideas and thoughts on what I could check out for the problem.
I think you should enumerate the USB devices--you can see details on how to do it here:
Enum USB devices in Linux/C++
For a previous question similar to yours, see: How to count cameras in OpenCV 2.3?
Related
I am working with a DMD (digital micromirror array) device Provided from TI (DLP3010EVM-LC). It is basically a projector that can be controlled through USB and HDMI. The HDMI is used to input external image data to the projector, thus the DMD. I am planning to control the pixels of the DMD by sending an image of 1-bit data. My goal framerate is about 1000 fps. It seems that this is possible in case of a 1-bit data where the pixel data even though HDMI port has a max of 60 fps. I am looking for a way to send image data using c/c++/opencv from my windows 10 PC HDMI output. I looked a lot on different sites and forums but couldn't find a concrete way or documentations of how to program the HDMI port (in fact, I just need image output with no sound data). Some people on the Rasberry Pi community simply use imshow() from opencv for this, but it doesn't seem to work on a Windows PC.
Any help on this matter is appreciated.
I am currently using opencv2.4.8 with three cameras on Win 7 in C++. I understand how to read from a camera through VideoCapture cap etc but I am having trouble identifying which camera is which.
From what I can understand, cap.open(int num) takes in the camera index. In my case, these are 0, 1, & 2.
CAMA = 0
CAMB = 1
CAMC = 2
If however, before starting up the program, cam at index 0 becomes unplugged, my cameras index change.
CAMA //GONE
CAMB = 0
CAMC = 1
So is there some way to remember which camera is which (other than displaying each camera to the user every single time...)? Perhaps logging some unique ID for the camera that can be then read in on restart?
In the device manager, I see under the properties of the USB device - Device Class guid which seems to be a somewhat persistent value. Is there a way to correlate this ID to the cam index?
I have searched here and tried the code here. I imagine stereovision users commonly run into this problem, so how have people managed this?
Not really an answer, but then I think there isn't really one.
What I've done for production applications is to do the video handling completely outside of OpenCV and then convert the frames to OpenCV images and do further processing.
On Windows you could use DirectShow, and I've used camera-specific APIs as well. Not in any way portable or convenient, but it has the benefit of working. On the plus side, you usually get access to the full set of camera settings and features, rather than just the few properties OpenCV defines.
I am trying to get video stream from analog camera connected to usb easycap - in OpenCV C++.
using MATLAB, I can get stream the same approach like for laptop webcam (with changing the index from 1 to 2).
with OpenCV, I can get stream from laptop webcam with index 0.
but when I am trying to get with the camera connected to the easycap (using index 1) , the laptop crashes and get blue screen.
Anyone have done this before?
Thanks
I work on the same device and I also have some BSOD with it.
Do you plug it with the USB extension provided ? If yes, try don't use it.
If your problem is still hapening, it's probably because like me, you use a low quality chinese fake EasyCap. I bought a real one and I haven't problems anymore
If you want to keep your device, you can use it with VideoCapture in python, it works very well and there is no more BSOD
Try using Linux. I tested my code with a fake EasyCAP in windows and I got many BSOD then I built and executed the same code in Linux and it worked.
Linux is driver friendly.
i want to built a 3D view of my scene with inputs from at least 3 webcams...presently i am using OpenCV (with C/C++) on Windows 7 32 bit platform and it gives me a maximum of 2 webcam views parallely...i have generated a 3D view with 2 webcams but that is not up to the mark...so i have the following questions...
if i use 3 webcams (2.0) in a USB hub is it possible to access the USB video frames without OpenCV?if yes then how?to keep it simple i can skip the USB hub because my laptop has 3 USB ports...is it then possible?
i have read about LIBUSB library...yet not used it...is it possible to access webcam video frames with this kind of usb library?
how safe is the LIBUSB library?i have read in some forums that if not configured and used correctly the blue screen pops up very frequently...it also runs a chance to damage the usb driver...? is there any other usb library i can use safely?
anyone who have worked on similar usb multiple webcam access stuff or has any idea on this please guide me...any suggestion is welcome...
You can run as many webcams as USB bandwidth allows
If USB bandwidth limit is hit, you are unlikely to resolve this by using certain software library
It might be helpful to lower resolution or start using on-camera compression if such option exists since both reduce USB traffic
More links on USB bandwidth constraint: 2 usb cameras not working with opencv
Is it possible to tap into the VGA output of a (different) computer? The computer in question will be running a driving simulator (which is at full screen). I would like to feed this video to another computer running a program, that I've written, which can detect motorway/freeway lanes and generate an output to steer the vehicle running in the driving simulator.
I did find this: http://www.synthenv.com/PixelPusher_usb_frame_grabber.aspx
A Frame grabber that can a VGA input and output it as a USB. Its also compatible with OpenCV (which is what I'm using for computer vision). Any suggestions on how to go about this?
Have you looked at VGA2USB Frame Grabber?
Frame grabbers are definitely an option. You could also convert your VGA signal to S-Video and use any graphics card with TV-in. Or, if you do not insist on running this on two computers, you could use a screen-grabbing camera driver, like http://www.splitmedialabs.com/vh-video-sdk/vh-screen-capture