Using USB Cameras

Raspberry Pi cameras (V1, V2, wide angle etc), HDMI capture modules etc.
Post Reply
vaizaragorn
Posts: 5
Joined: Thu May 23, 2019 1:35 am

Using USB Cameras

Post by vaizaragorn » Thu May 23, 2019 1:40 am

I have been trying to make my own stereo camera and I recently found stereopi. I have been using my two logitech c270 cameras with open cv. I got some good results but not as good as stereopi's. So I wanted to try stereopi but looks like it only works with raspberry's camera modules. Looks like stereo pi uses picamera to get videos from camera. Are there any possible ways to use my usb cameras with this?

User avatar
Realizator
Site Admin
Posts: 283
Joined: Tue Apr 16, 2019 9:23 am
Contact:

Re: Using USB Cameras

Post by Realizator » Thu May 23, 2019 9:47 am

vaizaragorn wrote:
Thu May 23, 2019 1:40 am
I have been trying to make my own stereo camera and I recently found stereopi. I have been using my two logitech c270 cameras with open cv. I got some good results but not as good as stereopi's. So I wanted to try stereopi but looks like it only works with raspberry's camera modules. Looks like stereo pi uses picamera to get videos from camera. Are there any possible ways to use my usb cameras with this?
To say briefly - no, you can't use other cameras with the StereoPi except Pi-supported. Please notice, I'm talking about CSI-2 connected cameras.
As for USB cams - you can, but it is a bad idea to use two USB cameras with your Pi (StereoPi or a classic Raspberry Pi). It only makes sense with desktop computer.
Key problems you'll face this way are:

1. You have no sync options for the two USB camera settings (like brightness, contrast etc.)
2. Using SoC H264 and MJPEG encoding is impossible or ineffective this way.
3. Pi's power for processing 2 videos from 2 USB cams is poor. But with native cameras all data goes to GPU directly, and this process is optimized.

Actually you have several options with Pi cameras. It is V1, V2, pinhole and wideangle optics. Look at "Catching a unicorn" section in one of our updates here.
Eugene a.k.a. Realizator

stereomaton
Posts: 90
Joined: Tue May 21, 2019 12:33 pm
Location: France

Re: Using USB Cameras

Post by stereomaton » Thu May 23, 2019 9:59 am

Realizator answered while I was still typing.
Here is my answer, as a few elements are complementary.

The main advantage (in my point of view) to use stereopi is because of the access to the two CSI buses of the raspberry-pi module, which allows for fast fetching of the two signals and as a consequence have good synchronization of the two images. Of course, there are other advantages such as useful connector to securely power it in robots, and so on.

If you want to use 2 USB cameras, a classic raspberry-pi or even a computer is enough for your tests: all stereopi software is available without the hardware if you really want them.

However, if you plan to create a stereocamera, using webcam is probably not the best way to follow (depending on what is you final goal).
If you care about photography (especially color dynamic, exposure dynamic, image quality, high and convenient control of shutter/aperture/iso...) the best way is probably to buy two cameras of the same model which can be triggered externally, and build a small synchronization cable. Some stereophotography groups can help to choose a suitable model (personally, I do not care much about gears and hardware-hacked my cameras which is much more difficult and stressful).
If you care about video, I have not much experience in this domain.
If you care about livestream or hacking, stereopi is probably a good choice with the CSI cams; or a classical raspberry-pi with webcams (since you have the webcams) but you will have very very little control on it and that might be very frustrating.
Stereophotographer and hacker
StereoPi Standard Edition + CM3Lite module

vaizaragorn
Posts: 5
Joined: Thu May 23, 2019 1:35 am

Re: Using USB Cameras

Post by vaizaragorn » Thu May 23, 2019 1:08 pm

After researching more about it I find out I made a big mistake by buying two usb cams. I'm trying to build an object tracking system for our UAV. I tried some ai based ones but they need a lot of processing power as you know. Stereo cameras are good choice for me because I don't even know the shape of what am I going to track. I first tried with cheap 640x480 cameras. They had so much noise and I thought maybe better cameras are the solution for poor quality depth map results. Looks like it isn't :) I'm planing to buy standart set if we can gather some money as a team. Before buying it I want to know if stereopi's depth map performs good in high speeds. Also I'll look for my object in 15-20 meters, can it perform well at hat distance?

User avatar
Realizator
Site Admin
Posts: 283
Joined: Tue Apr 16, 2019 9:23 am
Contact:

Re: Using USB Cameras

Post by Realizator » Thu May 23, 2019 2:01 pm

vaizaragorn wrote:
Thu May 23, 2019 1:08 pm
Before buying it I want to know if stereopi's depth map performs good in high speeds. Also I'll look for my object in 15-20 meters, can it perform well at hat distance?
For the speed you'll need to optimize your code. In our OpenCV experiments we were able to achieve ~17 FPS at 320x240 using Python. On a native C with code optimizations you can achieve better results.

As for 15-20 m distance - it's a question of your stereobase (distance between camera axis) and depth map settings. For such a distance I'd use not 65 mm, but 100 mm or 150 mm stereobase.
Eugene a.k.a. Realizator

vaizaragorn
Posts: 5
Joined: Thu May 23, 2019 1:35 am

Re: Using USB Cameras

Post by vaizaragorn » Fri May 24, 2019 1:07 pm

I don't know if that resulation will be enough, and 17fps is lower than I expected. I don't want to get commercial ones, they are too expensive for our team. I think In order to get good depth maps for that distance, I think I need better resulation too. Also I'm curious, can you increase the performance by not showing camera and depthmap output. I'm planning to put this in our UAV. I don't need to see what's happening in cameras after I set it up properly. Maybe it can effect performance someway.

User avatar
Realizator
Site Admin
Posts: 283
Joined: Tue Apr 16, 2019 9:23 am
Contact:

Re: Using USB Cameras

Post by Realizator » Fri May 24, 2019 3:43 pm

vaizaragorn, our Depth Map experiment was intended for OpenCV learners. That's why we used Python and GUI mode. We plan to do one more Python-based experiment for indoor robots (obstacle avoidance, lidar-like mode). After that we'll do performance-focused solution for more serious implementations, using C/C++ and all possible optimizations we can.

Just a notice for you: for advanced systems you may combine StereoPi with AI accelerators (like Google Coral, mentioned here on our forum)
Eugene a.k.a. Realizator

vaizaragorn
Posts: 5
Joined: Thu May 23, 2019 1:35 am

Re: Using USB Cameras

Post by vaizaragorn » Sun Jun 16, 2019 7:18 pm

Thank you guys for you kind answers. Also sorry for answering late, I haven't been able to work on my project recently. So I decided to change your code a little to be able to use it with usb cameras. I'm currently on pairs script, it cuts images I couldn't figured it out yet. We are planning to use Nvidia Nano to process images. After I test it on my machine ofcourse. I'll post my results in here after I manage to run it. :)

vaizaragorn
Posts: 5
Joined: Thu May 23, 2019 1:35 am

Re: Using USB Cameras

Post by vaizaragorn » Mon Jun 17, 2019 2:25 pm

So finally I got rid of all the Picamera things, and used cv2.VideoCapture instead. Now time to do some calibration. I'll post my result in here.

Post Reply