Help with two USB Cameras on the Dashboard.

Hello,

We have been tasked with the job to program two HD Microsoft USB cameras. With a possibility of showing them both at the same time on the dashboard. I understand this might be a problem with the limited information we can send though wifi. Our superiors believe that if we lower the FPS, compression, and the image size we might be able to send two images at the same time, I trust in their experience so I’m pretty confident we can do this.

We went ahead and looked for other vision codes on this website and we found one, the one attached. The only problem is that it is from 2015, so if there is anyway of converting the program to 2016 it would help, or someone explain what we need and don’t need, or if someone has an updated and/or better version.

That would help. If you need more information or any questions about our question please do ask and help us out.

Thank you,

Lorenzo Guerra and
Team 4063 Programming Team





The attached picture is a modified version of WPI_CameraSendImages To PC Loop. If you have the VI, put it in with the rest of your code – perhaps next to RobotMain. Then drag it to the project window so that it is listed there.

In the Vision Processing VI, comment out or delete the Background block and call the new VI instead by dragging it from the project to the Vision Processing diagram.

Post again if that doesn’t work.
Greg McKaskle

If lab view is the same as Java/c++, you are going to have trouble. The camera server (routines) are only designed for 1 camera.

If your second camera is an ip camera, you can open a browser window and get the image directly. There may be a way to access a sub camera directly, but I have no idea how

The code that the student attached is the video server.

The default one in WPILib serves one camera, the one posted opens sessions to two USB cameras and serves images from one of them. To further modify it to interleave the images on one port or to open a second port is just a bit more code. So teams are given the source to the video server and it is theirs to expand provided they don’t bypass the bandwidth limits.

Greg McKaskle

Thank you,

For posting your responses, Mr. McKaskle when you say “In the Vision Processing VI, comment out or delete the Background block and call the new VI instead by dragging it from the project to the Vision Processing diagram.” What do you mean?

Thank you again both of you for responding to the thread. Once we fully make this program functional we will post back, and vise versa if the program does not work.

Okay,

So we put the program into place and we found that there is too much data so the driverstation is shutting down the flow of information to the other camera feed or it doesn’t show it at all and then the cycle continues, it goes from 9E-5 Mbps to 0 Mbps then to 8E-5 Mbps.

So here is the program showing all of the case structures and their sub-cases. If there are any problems please help us.

Thank you,

Lorenzo Guerra and
Team 4063 Programming









Thanks for asking. Here is what I meant.

The attached image shows the part of the Vision Processing block diagram that calls the Background block – actually it is called the WPI_CameraBackground Loop.vi.
That VI does two background tasks:
1.) For Axis cameras, it reads images as soon as they are available and keeps the last one so that the user code will always be reading the most recent image.
2.) For USB cameras, it serves the images to the dashboard on TCP port 1180.

You have your own image server, and you don’t care about the Axis stuff, so you can delete or comment out the Background block and wire up the one you are using that serves two cameras.

The code shown in your attached images looks pretty good, but the compression is basically off. I’ll explain more in a sec. With two cameras at 5fps, that is the same as one camera at 10fps with very little compression. From the image, I can’t tell what the image size is, so I think the first thing to do is add compression and shrink the image size and test it again.

The server you are using has a T wired to the OpenAndSetMode. This means that the camera itself is doing the compression, and that we have no control on how much to compress. If you set the image size smaller and maybe the fps a to four, I think this will work.

Another approach is to change from camera compressed images to roboRIO compressed images. This involves two edits. The T constant that is wired to the Set Video Mode VI needs to be changed to a false. Next, drop the attached snippet of code somewhere on the edge of your VI. Surround it with the comment block to make it a comment. Notice that one frame of the snippet case structure, the -1 case, looks just like the code you have in your server. It gets the Raw Image Data from the camera and sends it to the dashboard. The other case, the Default one, gets the image and sends that image to the “Flatten Image to String” function telling it to make a JPEG with a compression number that ranges from 0 to 1000.

The default camera server supports both camera compressed and roboRIO compressed, and it uses a compression number of -1 to select camera compressed, and all other numbers mean roboRIO compressed. So if you want to, you can swap out the code in your server with the stuff from the commented snippet. Post the result if you want a review of it.

Greg McKaskle

From Clipboard.png
Image Server Image.png


From Clipboard.png
Image Server Image.png