Go to Post Oh, you mean the refs. The only hand signal I've seen the judges use is the hi-five. - RoboMom [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 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
  #2   Spotlight this post!  
Unread 05-02-2017, 10:05
AquaMorph's Avatar
AquaMorph AquaMorph is offline
Alumnus of 2059
AKA: Christian Colglazier
FRC #2642 (Pitt Pirates)
Team Role: Mentor
 
Join Date: Jun 2010
Rookie Year: 2008
Location: Cary
Posts: 79
AquaMorph is on a distinguished road
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.
__________________
FRC Drive: Play Store FRC Manager: Play Store
Reply With Quote
  #3   Spotlight this post!  
Unread 08-02-2017, 17:24
jwatson12 jwatson12 is offline
Mr. Watson
FRC #1025 (Impi Warriors)
Team Role: Mentor
 
Join Date: Feb 2012
Rookie Year: 2009
Location: Michigan
Posts: 18
jwatson12 is an unknown quantity at this point
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

Last edited by jwatson12 : 09-02-2017 at 07:16.
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:17.

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