Capture image from multiple cameras at the same time instant - opencv

My setup consists of 3 USB 2.0 cameras connected to a USB 3.0 hub and then connected to computer. Cameras are independent of each other and the hardware is not synchronized. Goal is to capture an image from all these camera when an event occur, in this case just pressing a button.
I came across this opencv document page ,"VideoCapture::grab" & "VideoCapture::retrieve" but unable to find a simple example that i can understand/easy to use. Any help is greatly appreciated. I also see that many people are using multi threading, multi processing etc. and almost all of them are using "VideoCapture::read" rather than grab&retrieve.

Related

Secure Video Streaming - Limit by IP or device

As part of a student project, I am currently setting up device to device video streaming.
I am using two Raspberry Pi 3 with the camera modules and am adding face tracking via OpenCV (all in Python3).
I want to stream live Video captured by Raspberry Pi (X) to Raspberry Pi (Y) and vice versa. The Raspberries will not be in the same building/network.
What I don't want, is anyone being able to stream the video on a different device.
As I am new to the whole streaming and security idea, I was wondering if there is some way of adding security to live streams by limiting access by the device.
Say, the video of Raspberry Pi (X) CAN ONLY be viewed by Raspberry Pi (Y).
Is this possible? If not, what's the next most secure option (limiting by IP maybe).
I am also not fixed to using Raspberries for this project, if there is a different solution I'd love to hear about it.
Thanks for any ideas.
You're not the first person to do something like this. A raspberry pi is an excellent choice for the project and you should be able to find plenty of guides online to doing something like this.
You'll want to ensure you enable a strong username and password within whatever library you use.If you want to protect the live stream with a username and password, you should enable this:
stream_auth_method 2
stream_authentication SOMEUSERNAME:SOMEPASSWORD
https://www.instructables.com/Raspberry-Pi-as-low-cost-HD-surveillance-camera/

Microsoft HoloLens Spectator View Rig - Using a camera that's different than what the documentation says

Can you use a USB camera for the Spectator View rig and overwrite one of the scripts OpenCV uses to get the camera feed?
I think this is the first StackOverflow question where it talks about Spectator View the Microsoft HoloLens supports, because I checked once to see if any other questions talk about it here, and it doesn't look like it.
Anyway, according to the documentation here, to enable Spectator View on a Unity-based UWP app that is deployed to more than one Microsoft HoloLens, I need to choose one out of four different ways to capture live video feed from a camera:
OpenCV 3.2
DeckLink Capture Card
Elgato Capture Card
Canon SDK
In this Spectator View setup I have for a project that's under a non-disclosure agreement, I am using OpenCV 3.2. What I'm using is a Lenovo ThinkPad laptop as the hub for Spectator View.
In detail, it runs the Unity Editor that holds the Spectator View Manager component I need to see in the Inspector in order to build, install, and launch the app that two HoloLens headsets I have will use to see a shared, anchored hologram that is spatially placed. The editor also has the Compositor interface I need to overlap what the camera sees with what a virtual camera this Unity scene has to create a video feed that goes out to a projector or TV set. Lastly, I have an executable from Microsoft's Mixed Reality Toolkit called Sharing Service where it runs basically a server program to exchange the transform of holograms on the fly, as if those are put in place in the real environment.
Now, the Lenovo ThinkPad cannot take in any capture cards, because there are no internal expansion ports. The laptop does not have an HDMI input port; only output. As such, when I start running the app on the Unity Editor, I do get video input and Unity view input in the Compositor interface, but the video feed is coming from the built-in camera the Lenovo ThinkPad provides. What I want to do is use a different camera instead, preferably a DSLR camera that can connect to my laptop using USB.
By using OpenCV 3.2 as the main dependency in the libraries I need, can I modify one of the scripts where it accepts video stream from a USB camera?
#Dtb49 says in the StackOverflow chat above,
"I don't think you are limited to those four choices I think those are just the ones that they tested with. I do remember something about the USB port needed to be a 3.0 for it to work properly. I do remember coming across that problem when I was initially setting it up."
I don't know right now whether I need to change a script or not to have the Compositor interface take camera input from the external camera that's connected by USB, or just disable the webcam on my laptop temporarily where something in the OpenCV assembly or motherboard determines which camera to load for the interface. But it looks like using a DSLR camera connected by USB for the Microsoft HoloLens Spectator View rig is possible.
As a university intern, I can say that the documentation for Spectator View in its current state is quite confusing, as I am not familiar with UNET and some other Microsoft technologies.

Multiple USB cameras simultaneously - labview

I am quite new to Labview. Does anyone know how to get images from 2 usb cameras simultaneously. There are some topics about it in the internet, but all of them are a little bit misleading and do not present the whole solution.
use labview 2014 and higher also check if your cpu and RAM of your system could support two or more simountensous camera .you can check this by open two camera in same time but with different software after that you find out that you system could handle two camera
use Imaqdx for open camera but it is better to use flat sequence for config and open part
it is better open camera by one by but you can capture in same time inside while loop
if you system could not handle two camera told me I could suggest a method to solve it
This isn't something supported using basic LabVIEW funtions.
However, you can use hooks into the User32.dll to create windows and populate them with live images from USB webcams.
I've had the example posted here working on LabVIEW 2016 + 2018
The linked example is displaying 2 webcams and doesn't need IMAQ drivers to run

Create 2 virtual camera devices streaming the same images one actual webcam does

I would like to use the images of one webcam in two different systems that require exclusive access to the video device simultaneously. Therefore I created two virtual cameras with v4l2loopback, one for each of the systems, and now I am trying to stream the data from the actual webcam to both virtual cameras. I tried to use GStreamer, but it only allows me to stream the data to one single virtual camera. If I try to stream to the other one also, I end up with my original problem of the webcam being already busy. I can't figure out a way to solve this problem, help would be greatly appreciated!
Just a thought I haven’t actually tried it, suppose you have a webcam attached and its /dev/video0, now create two virtual devices using v4l2loopback say /dev/video1 & /dev/video2 and now create a gstreamer pipeline with a tee element which outputs to 2 v4l2sink's /dev/video1 and /dev/video2.
Hope that helps!

OpenCV with 2 cameras VC++

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
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
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
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

Resources