Go to Post Since this thread doesn't seem to have quite enough numbers yet, here are some more. - William Frost [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 03-02-2017, 17:51
Lesafian Lesafian is offline
Registered User
AKA: Jeremy Styma
FRC #6077 (Wiking Kujon)
Team Role: Programmer
 
Join Date: Feb 2016
Rookie Year: 2016
Location: Posen, Michigan
Posts: 38
Lesafian is an unknown quantity at this point
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();
Reply With Quote
 


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:16.

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