TLDR: ERROR: serve_Tracking: Too many simultaneous client streams (MjpegServerImpl.cpp:403) While viewing the image in smart dashboard and I believe it halts processing.
Team 1245 head programmer here!
Our team has decided to go along with robot vision and has had varied success for the past week or so. I managed to get our pipeline to read the images, and find the pixel height of the two rectangles (Code below) but whenever we try to view the processed image in Smart Dashboard we get the error above.
This also seems to happen in the background after a few seconds causing the pipeline to halt (for some reason) and stop processing the images.
I must be missing something (could be memory overload) but there weren’t any google results when searching this error. Have any of you had this or know what the issue is and how to fix it? Thanks!
This error occurs when you have opened 10 or more output streams, which you are presumably not trying to do. However, because you put the code that opens an output stream in the vision thread, and start the vision thread each time you run the constructor of this command, it is possible that this code will run multiple times and open a new stream each time. To remedy this you should probably create a single instance of the output stream and access it through the RobotMap instead of creating one each time you construct this command. Hope this helps.
Why are you sleeping for 15 seconds in the constructor
? Why do you have that at all?
You set all the camera parameters in this command’s constructor. These should be set by the subsystem
You set the Robot’s visionThread variable to the exact same thing
(this is what’s causing the “too many clients” error). Again, it should be set in the Robot class, and be private so stuff like this doesn’t happen
Regarding the 15 second thread sleep: Fromhttps://wpilib.screenstepslive.com/s/4485/m/24194/l/288984-camera-settings
“To custom-calibrate the white balance, place a known neutral object in front of the camera. A sheet of white paper is a reasonable object to start with. Set the white balance setting to auto, wait for the camera to update its filters (ten seconds or so), and switch the white balance to hold.”
I’ll move the code that creates the stream and server outside of the command and put it into RobotMap. I’ll also try to move the thread outside of the constructor to see if that works.
Thanks for the help, I’ll respond back if any of these end up not working or if a new issue arises due to this!
The problem with a call to Thread.sleep() is that the entire program runs on one thread. You’re basically freezing the entire robot for 15 seconds to do the calibration.
You also only really need to the calibration once per event.
There’s still the error, however it occurs when grabbing the frame. It doesn’t seem to get further than the if statement. It doesn’t even fail it just stalls with the “too many streams” error during the cvSink.grabFrame(mat).
I’ve moved the stream to RobotMap, and as far as I can tell it’s the only one that is ever made. That also doesn’t explain why it halts during grabFrame. To me it seems as though the cvSink is never created, or there isn’t an open stream for it to put the frame into but there clearly is in RobotMap.
I would say you’re correct, but that wouldn’t explain why it doesn’t run anything after the grabFrame. Even if I start with running the tracking the error still happens after grabFrame. I’ve had it print a warning to the DriverStation “Grabbed Frame” after and it never printed it out, while it would print something before the grab frame event.