Go to Post * FIOTWOD -pronounced "FI ot wood", the first two syllables rhyme with "riot" -stands for: FIRST-is-the-only-topic-worthy-of-discussion - Joe Johnson [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 26-01-2017, 13:33
Ashier Ashier is offline
Registered User
FRC #1245
 
Join Date: Jan 2017
Location: Colorado
Posts: 4
Ashier is an unknown quantity at this point
Error while processing images through OpenCV pipeline

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!

Code:
https://gist.github.com/SnowCrystalz...75f1f4c9971188

- Team 1245 Programming
Reply With Quote
  #2   Spotlight this post!  
Unread 26-01-2017, 16:45
jmcculloch jmcculloch is offline
Jeremy McCulloch
FRC #2485 (W.A.R. (We Are Robot) Lords)
Team Role: Programmer
 
Join Date: May 2016
Rookie Year: 2015
Location: San Diego
Posts: 5
jmcculloch is a jewel in the roughjmcculloch is a jewel in the roughjmcculloch is a jewel in the roughjmcculloch is a jewel in the rough
Re: Error while processing images through OpenCV pipeline

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.
Reply With Quote
  #3   Spotlight this post!  
Unread 26-01-2017, 17:02
SamCarlberg's Avatar
SamCarlberg SamCarlberg is offline
GRIP, WPILib. 2084 alum
FRC #2084
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 136
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: Error while processing images through OpenCV pipeline

There are a lot of problems with this code.
  • 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
__________________
WPILib
GRIP, RobotBuilder
Reply With Quote
  #4   Spotlight this post!  
Unread 26-01-2017, 17:33
Ashier Ashier is offline
Registered User
FRC #1245
 
Join Date: Jan 2017
Location: Colorado
Posts: 4
Ashier is an unknown quantity at this point
Re: Error while processing images through OpenCV pipeline

Thanks for the responses guys!

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!

- Team 1245 Programming
Reply With Quote
  #5   Spotlight this post!  
Unread 26-01-2017, 17:49
SamCarlberg's Avatar
SamCarlberg SamCarlberg is offline
GRIP, WPILib. 2084 alum
FRC #2084
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 136
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: Error while processing images through OpenCV pipeline

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.
__________________
WPILib
GRIP, RobotBuilder
Reply With Quote
  #6   Spotlight this post!  
Unread 28-01-2017, 13:19
Ashier Ashier is offline
Registered User
FRC #1245
 
Join Date: Jan 2017
Location: Colorado
Posts: 4
Ashier is an unknown quantity at this point
Re: Error while processing images through OpenCV pipeline

Alright, I've moved everything to a more proper programming structure, here's the relevant code for reference. https://gist.github.com/SnowCrystalz...12f0023b932695

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 am lost.
Thanks for the help guys,
- Evan : 1245 Programming
Reply With Quote
  #7   Spotlight this post!  
Unread 28-01-2017, 14:54
SamCarlberg's Avatar
SamCarlberg SamCarlberg is offline
GRIP, WPILib. 2084 alum
FRC #2084
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 136
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: Error while processing images through OpenCV pipeline

Too many streams may be caused by the SmartDashboard.
__________________
WPILib
GRIP, RobotBuilder
Reply With Quote
  #8   Spotlight this post!  
Unread 28-01-2017, 15:40
Ashier Ashier is offline
Registered User
FRC #1245
 
Join Date: Jan 2017
Location: Colorado
Posts: 4
Ashier is an unknown quantity at this point
Re: Error while processing images through OpenCV pipeline

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.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:24.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi