There’s some good and some not-so-good about the new WPI-provided way to handle multiple video streams using a Raspebrry Pi.
ELP Cameras problems
I have bought many of these ELP cameras last year and this. I may be a slow learner, but eventually it dawned on me that the problems I noticed seem to occur because of this model of USB camera. Finally this year we got a chance to explore this further. I got my hands on a Logitech webcam, the kind you use perched on top of a display monitor. We had this set up as a second camera while an ELP camera was the first. Then we rebooted the Pi a whole bunch of times to gather some stats. About 25% of the time there were problems with the ELP over about 10 tries. There were no problems with the Logitech. Here are various problems we’e seen:
– horizontal lines superimposed over image, and image dull
– ghosting, a corner of the field of view is shown in the center of the image
– sometimes the stream never starts and we’re not yet sure if that’s a camera problem or a software problem though I begin to suspect it’s an ELP problem
– one of my pinhole ELP cameras died
So: Logitech webcam is decidedly better.
We pay extra attention to the power draw of the Pi. With two cameras attached and a 2 amp or 1.8 amp power supply the red LED power flashes. That is not good. It’s a sign of undervoltage. The command
on your Pi will tell you if there was an undervoltage condition. I see
when using a 2 amp power supply. Note that as far as we can see the camera display itself works just as well. We also have a 3 amp power supply. That produces a solid red led light and vcgencmd get_throttled produces a response of
which probably indicates there were no undervoltage conditions.
The problem we need to avoid for the Pi to attempt to draw more than 2 amps from the regulator. Doing so may shut it down. So we will try to use the Pi along with a powered USB hub.
We want to be well below 3 mbps for two cameras. How to get there while still providing a useful service. Initially we felt we could run the cameras at 320×240 resolution, 10 fps. But after much playing we found conditions under which we exceed 3 mbps though normally we were below that. I believe that the compressibility of the image is what matters. So a “rich” visudal field with lots of contrasting objects is the least compressible. That vaguely fits our findings as well. So we felt it important to prepare for the worst case. So we actually looked at supported resolutions and settled on 176×144 pixels! It sure isn’t much, agreed, but it’s still helpful. We blow up the images during the display. We use YUYV mode. MJPEG uses considerably more bandwidth.
With this WPI software, the video streams never display the first time. You have to refresh the page for some reason. We wished to have a one click operation for viewing, however, to minimize the risk of operator error. So we used some old-fashioned META HTML tags to force a page refresh.
Initial page HTML source
<html><head> <meta http-equiv="Refresh" content="1;url=file:///C:/users/aperture/Desktop/2019-no-refresh.htm"> <title>stream</title></head> <body> <img src="http://10.31.42.18:1182/stream.mjpg" width=560 height=400> <img src="http://10.31.42.18:1181/stream.mjpg" width=560 height=400> </body> </html>
And we size the browser window to just fit the two video streams side-by-side.
Target HTML source for 2019-no-refresh.htm
<html><head> <title>stream</title></head> <body> <img src="http://10.31.42.18:1182/stream.mjpg" width=560 height=400> <img src="http://10.31.42.18:1181/stream.mjpg" width=560 height=400> </body> </html>
Timing and sequence of events
After the Ras Pi is powered up, we launch the initial page from the task bar where it was pinned, 20 seconds later.
It takes a bit of time, then it displays the side-by-side video streams as broken images.
The red LEDs on the Logitech webcams begin to glow.
(We know when we see both red LEDs glowing we are good to go by the way).
the refresh occurs automatically to the 2019-no-refresh.htm web page.
Two side-by-side video streams are displayed, each with 560×400 display dimensions.
References and related
My 2018 version of using the Raspebrry Pi to handle two USB cameras: USB webcam on Raspberry Pi
WPI PDF manual, Using a Ras Pi as Video coprocessor
Download compressed image from Github: https://github.com/wpilibsuite/FRCVision-pi-gen/releases/. Scroll down to Assets and look for FRCVision_image_2019xxxx.zip. (2019.3.1 is the latest at time of this writing.