Camera Compression Complications

Mr. Crane picked up some cheap Logitech webcams the other day, so we could try testing multiple camera streams. He also got a USB 2.0 hub, so we could have them all on one USB port.

The software that we used to stream the cameras over the network, Motion, supports multiple cameras very easily. Linux detects each USB camera as  /dev/videoX  where X is the camera index. Motion config files are stored in ~/.motion , the main config file is motion.conf .

All I had to do was edit the  motion.conf  and replace the camera device with this, for each camera you have:  thread /home/sart/.motion/cameraX.conf

Each thread file looked like this, just with the device and port increased to the next number for each camera:

I started with the three webcams that we bought and plugged them into the UDOO. We had a spare camera at school, one of the oCam ones that was used on the robot during the competition last year. This was going to be our fourth test camera, but I just used the three webcams to start off.

And it worked!

 

However, when I tried to plug the three cameras into the USB hub, there was an issue.

Quite an issue indeed. It appears only one of the Logitech cameras was working at a time.

It looks like perhaps the cameras were not getting enough power from the one port. Alex and I looked at splicing in a 5V source into the hub, to allow us to power it without using a bulky powered hub with an external power source.

With his signature impeccable timing, Mr. Elias sent us a photo of a small powered USB hub that used a standard micro-usb cable for power. Perfect!

However, to our great disappointment, it didn’t help.

It looked like it might be a bandwidth issue. Now that we were at school, we tried it with the fourth camera (the oCam) and to our surprise, we could have the oCam on the same hub as a Logitech one, with no problems. In fact, we even plugged the camera that is in the old robot into the hub as well and we could have two oCams and a Logitech one on the one port. So what was the difference between these cameras?

And thanks to a bit of research I found a tool for debugging USB camera issues: v4l2-ctl

If the only pixel format listed is “YUYV”, “IUYV”, “I420”, or “GBRG” then we can only run one camera per USB controller as they are uncompressed streams.

However, if it lists MJPEG, it means it supports motion JPEG compression. The oCam cameras did support this, and that is why we could have multiple on the same port. The Logitech cameras did not.

Thankfully the new cameras that we are buying will support compression, so that’s great. Once the cameras arrive we will have to film some awesome videos of the robot in action.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.