Hi, my team is trying to do Vision Processing this year, and we are having some issues. The robot can detect a stationary target from boot, but once the target starts to move around a bit, it throws this error:
ERROR: serve_fc: Too many simultaneous client streams (MjpegServerImpl.cpp:403)
My code is as follows:
@Override
public void robotInit() {
Pipeline visionPipeline=new Pipeline();
visionThread=new Thread(() -> {
UsbCamera camera=CameraServer.getInstance().startAutomaticCapture();
CvSink imageSink=CameraServer.getInstance().getVideo();
CvSource imageSource=CameraServer.getInstance().putVideo("fc", 320,240);
Mat image = new Mat();;
Mat image2 = new Mat();
List<MatOfPoint> contours;
while (!Thread.interrupted()) {
// Tell the CvSink to grab a frame from the camera and put it
// in the source mat. If there is an error notify the output.
if (imageSink.grabFrame(image) == 0) {
// Send the output the error.
imageSource.notifyError(imageSink.getError());
// skip the rest of the current iteration
continue;
}
image.copyTo(image2);
visionPipeline.process(image2);
contours=visionPipeline.filterContoursOutput();
Imgproc.drawMarker(image2,new Point( Imgproc.boundingRect(contours.get(0)).x, Imgproc.boundingRect(contours.get(0)).y),new Scalar(0,0,255,255));
//Imgproc.drawContours(image2, contours, -1, new Scalar(0,0,255,255));
imageSource.putFrame(image2);
}
});
visionThread.start();
}
Has anyone had similar issues and been able to fix them?