USB Camera Help

We are having a problem getting two USB cameras to work simultaneously,
we’ve gone over the examples several times but to no avail. We’ve even tried rewriting our own camera code instead of copying and renaming the default one, but that also hasn’t worked. Can anyone help us with our problem? Thank You

Are you trying to get two cameras to show up on the dashboard, have two cameras processed on the roboRIO, or something else?

Greg McKaskle

We’re trying to get 2 cameras plugged into the roborio to show up on the dashboard.

I decided to try it to see what had to be done. One key reminder is to make sure that you allocate a second image with a different name. Using the same name will have them overwriting to the same image.

I wired that second image into a simple loop that used the same Camera IP value going into the Read MJPEG for Dashboard and that is wired to the second display.

Does this help? Were there things that you did differently that seem to break it?

Greg McKaskle

We tried duplicating the camera code in the dashboard but even when they are running with different names it never looks for the second camera it tries to use the same camera for both dashboard displays.

I don’t know how to get it to use the second camera for the second display. Do I need to give the USB cameras different IP addresses? If so where do I find that address? Please help.

It’s a fairly involved process to get 2 USB cameras working. The “camera IP address” is really just the RoboRIO IP address, because the RoboRIO is what actually reads the cameras. By default, the RoboRIO listens on TCP port 1180 and sends a stream of JPEG images over a TCP connection through a custom protocol.

In order to use two different cameras, we needed to modify “WPI_CameraSendImages To PC” to take a port as an input, instead of just using 1180 as a hardcoded value. This way we can use two different TCP streams on different ports, one for each camera. The VI also needed to be made reentrant so multiple cameras can send images at the same time.

On the dashboard side, we modified the MJPEG loop VI plus its internal USB camera reading VI (WPI CameraGet Image From to also take a TCP port to use.

That so far has sort of worked, but the image from one camera appears frozen while the other streams. I think this is because the actual TCP read occurs in a non-reentrant VI, meaning that the receive loop for one camera is blocked while data is being transferred over the network for the other. I have modified more of the receiver VIs on our dashboard to make them reentrant, but haven’t been able to test it yet.

In the future, it would be nice to have a way to stream images from multiple USB cameras without modifying WPI VIs. It’s a bit nicer with the Axis cams, but some modifications are still necessary to get things like recording working right.

Where do you find “WPI_CameraSendImages To PC” cause I can’t find it?

I failed to mention that what I had access to was one USB camera and on Axis. I made the following modification, set the left one to USB and the right to IP and it worked.

If you are wanting the roboRIO to forward multiple USB cameras, you are correct that there are limitations. Your edits sound about right. I wouldn’t be surprised to find out that the bottleneck isn’t reentrant VIs, but the compression. Making IMAQ Flatten be reentrant may help that.

You will also need to make the DB end of the connection know about the other port as well.

Greg McKaskle