When we hooked up the camera to the Rio we noticed that the camera has very bad lag, to the point of being unusable. Amazon has various performance specs listed for the camera, and I imagine the issue is that the resolution is too high. Is there a way to set the resolution in code? We are using Java. Or can it be set on the smartdashboard?
Since youâre using Java, you can go to the camera stream webpage at http://roborio-TEAM-frc.local:1181/, which will list the available modes and also provide interactive settings for things like exposure which can drive frame rate. The camera stream on that webpage doesnât set resolution or compression and should show the âbest possibleâ lag for the currently active stream. Setting either resolution or compression from the dashboard will dramatically increase latency as that requires the Rio decompress/recompress the stream. You canât change the selected video mode via the webpage, but you can set it in code by using setVideoMode() on the VideoSource object returned by CameraServer.startAutomaticCapture().
The PixelFormat just defines the pixel format from the camera. Use mjpeg pixel format to have the camera do the compression (otherwise the Rio will need to do it in software). The width, height, and FPS are all separate parameters from the pixel format. Cameras support a set of combinations of all 4 parameters.
You should theoretically be able to call CameraServer.getInstance().startAutomaticCapture().setResolution(...) to set the height and width of the camera stream.
Weâre using a similar camera (180Âș) but a totally different way of streaming it (on a Jetson TX2 via g-streamer over UDP) and weâre getting decent results (~100ms latency) with 640x360 @ 30fps.
Either should work. Itâs possible mDNS isnât resolving; you can try the Rio IP address instead of roborio-TEAM-frc.local (should be 10.TE.AM.2 on Ethernet or 172.22.11.2 on USB). Itâs basically the same way you get to the RoboRIO dashboard, just on a different port number.
I still havenât found the camera stream via the Rios IP, but did put the code you suggested in Java. The camera is still very delayed. I put
camera1.setVideoMode(pixelFormat.kMJPEG, 640, 480, 30);
Could I be having issues because of using 2 cameras and using the kKeepOpen connection strategy for both?
You need to put in both the IP and the port number. E.g. http://172.22.11.2:1181/ when connected via USB. 1181 for the first camera, 1182 for the second, etc.
Using kKeepOpen doesnât cause issues unless you run out of USB bandwidth, in which case youâd be getting console errors and the camera wouldnât even connect.
The one setting that might help FPS is making sure itâs manual exposure. However, the 640x480 lowest resolution poses a challenge. Youâll probably run into bandwidth constraints quickly even if you do get the native FPS higher. Resizing in software to reduce bandwidth will also slow things down. I would recommend a different camera (see my post here: What are teams doing about the Logitech C920's minimum resolution problem?). Either way, I would recommend moving it to a coprocessor (see my post here WPILIB CameraServer Input/Output error).
Weâve been having similar issues with a similar camera (https://www.amazon.com/180degree-Fisheye-Camera-usb-Android-Windows/dp/B00LQ854AG). The lowest res it supports in MJPEG is 320 x 240 @120fps but setting it to that spec weirdly results in a bit over 2.2mbps used and a choppy 10-15fps. Would this suggest that Iâm doing something wrong with config or am I SOL?
Iâm hoping that the rio can just cut out frames and not lag as 120fps is obviously not happening
[I saw your recommended fish-eye camera but we already bought 3 of these ]
Thanks, changing the exposure didnât help. I guess we will go back to the drawing board. Do you have a recommendation for a wide angle camera that we can run on the Rio?
We are using FRC RaspberryPi and the results are very good - https://wpilib.screenstepslive.com/s/currentCS/m/85074/l/1027241-using-the-raspberry-pi-for-frc , you can get the image from here (https://github.com/wpilibsuite/FRCVision-pi-gen/releases) and burn it on a SD card. First time it will take probably a minute to come up, subsequent reboots will take 20 seconds. It will survive a robot shutdown because the SD card is in read-only mode. Weâve set the image at 160x120 with 25fps which consumes 0.9 to 1.1Mbps out the 4Mbps allowed this year during the game. We are using SmartDashboard (yes, I know itâs deprecated) but had really good experience with it. The drive team is very happy. It shows video in real time, no delays.
We decided to try out a rPi on our testbed. We downloaded and flashed the image and connected via frcvision.local and had a camera image, but when we connect the Pi to the testbed we arenât getting any images on the dashboard.
Edited to add: When we try the Pi on another computer it says the ethernet does not have a valid IP and wont connect to frcvision.local
Also, we cannot view a second camera on the frcvision.local:1182. We get a message saying the site canât be reached.
To get image on the FRC SmartDashboard you need to have the RoboRio (running), FRC RPi and the radio (optional) in the same network. If you just want to see the image and configure various settings, go to http://frcvision.local or if that doesnât work try to run arp -a in command prompt. Run that command several times until you see on the âPhysical Addressâ column an address starting with b8-27-eb-⊠Next to it will be the IP address of your RPi.
Alternatively, you can download âAngry IP scannerâ and scan your network/subnet.
After that, go to Vision Settings -> Open Stream, next to Camera rPi Camera 0. It should open another tab http://frcvision.local:1181.
Launch the FRC Driver Station then click on the âgearâ and select SmartDashboar from the Dashboard Type menu. Once it launched (it takes few seconds), in the SmartDashboard go to View, select Editable. Then View, Add, CameraServer Strream Viewer. In few more seconds you should see the image from FRC rPi. Drag a corner and make the image as big as you need. Right-click over the image âPropertiesâ and select âDegrees of rotationâ put a number in there if you need to : 0, 90, 180, 270. Hope this helps.