Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Vision Processing ERROR: too many simultaneous streams (http://www.chiefdelphi.com/forums/showthread.php?t=154669)

Lesafian 03-02-2017 17:51

Vision Processing ERROR: too many simultaneous streams
 
There's a problem with my vision code. I'm only using 1 output stream, but I'm getting the error "too many output streams". Here is my code

Code:

        // Vision Processing
        private VisionThread visionThread;
        private final Object imgLock = new Object();
        double centerX = 0.0;
        double width = 0.0;
        public String shotReady = "Shot Ready";
        int gripTolerance = 3;
        int tooFar = 90;
        int tooClose = 110;
        int camWidth = 320;
        int camHeight = 240;
        int imageCenter = (camWidth / 2);
        boolean isShotReady = false;
        VisionClass pipeline = new VisionClass();
        VisionRunner<?> visionRunner;
        UsbCamera cam0, cam1, selectedCam;
        Mat image;
        CvSink selectedVideo, gearVid, highGoalVid;
        CvSource outputStream;
        boolean isTargetFound = false;

        @Override
        public void robotInit() {

                // Switch Vision Targets
                cam0 = new UsbCamera("cam0", 0); // High Goal Camera
                cam1 = new UsbCamera("cam1", 1); // Gear Camera
                cam0.setResolution(camWidth, camHeight);
                cam1.setResolution(camWidth, camHeight);
                cam0.setFPS(16);
                cam1.setFPS(16);
                selectedCam = cam0;
               
                image = new Mat();
                // MjpegServer server = new MjpegServer("server", 1181);

                highGoalVid = CameraServer.getInstance().getVideo(cam0);
                highGoalVid.setEnabled(true);

                gearVid = CameraServer.getInstance().getVideo(cam1);
                gearVid.setEnabled(false);

                highGoalVid.grabFrame(image);
                selectedVideo = highGoalVid;

                outputStream = CameraServer.getInstance().putVideo("Selected Video", camWidth, camHeight);
                // server.setSource(outputStream);
                outputStream.putFrame(image);

                visionThread = new VisionThread(selectedCam, pipeline, pipeline -> {
                        if (!pipeline.filterContoursOutput().isEmpty()) {
                                isTargetFound = true;
                                Rect r = Imgproc.boundingRect(pipeline.filterContoursOutput().get(0));
                                Rect r1 = Imgproc.boundingRect(pipeline.filterContoursOutput().get(1));
                                Mat processedImage = new Mat();
                                synchronized (imgLock) {
                                        selectedVideo.grabFrame(processedImage);
                                        Imgproc.rectangle(processedImage, new Point(r.x, r.y), new Point(r.x + r.width, r.y + r.height),
                                                        new Scalar(0, 0, 255), 2);
                                        Imgproc.rectangle(processedImage, new Point(r1.x, r1.y), new Point(r1.x + r1.width, r1.y + r1.height),
                                                        new Scalar(0, 0, 255), 2);
                                        outputStream.putFrame(processedImage);
                                }
                        } else {
                                isTargetFound = false;
                        }
                });

                visionThread.start();


AquaMorph 05-02-2017 10:05

Re: Vision Processing ERROR: too many simultaneous streams
 
I had this problem even though the code was 100% correct. Rebooting the roboRIO while both webcams were plugged in fixed the issue.

jwatson12 08-02-2017 17:24

Re: Vision Processing ERROR: too many simultaneous streams
 
Running into similar issue with two webcams. Rebooted Roborio with cams connected. Still get the same issue. How was this issue resolved?

Thanks :)


All times are GMT -5. The time now is 04:11.

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