Go to Post We are all just pawns in FIRST's quest for global domination. - Tom Bottiglieri [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 01-02-2017, 08:52
rudun's Avatar
rudun rudun is offline
Registered User
FRC #0496 (Royals)
Team Role: Coach
 
Join Date: Jan 2009
Rookie Year: 2005
Location: Babylon
Posts: 48
rudun is an unknown quantity at this point
Vision tracking and camera server rectangle draws in only one spot

I am trying to draw a rectangle on the output based on the detected contours.
What i am getting is it works on initialization and then when you move the target, the rectangles are still in the same place. I am not sure where I am going wrong.

Code:
HttpCamera camera = CameraServer.getInstance().addAxisCamera("10.4.96.20");
		camera.setResolution(IMG_WIDTH, IMG_HEIGHT);
		pegVisionThread = new VisionThread(camera, new PegPipeline(), pipeline -> {
			
			
			if (!pipeline.filterContoursOutput().isEmpty()) {
				
				synchronized (imgLock) {
					//centerX = r.x + (r.width / 2);
					//SmartDashboard.putNumber("center x", centerX);
					CvSink cvSink = CameraServer.getInstance().getVideo();
					CvSource outputStream = CameraServer.getInstance().putVideo("Peg Vision", 640, 480);

					Mat source = new Mat();
					//Mat output = new Mat();

					while (!Thread.interrupted()) {
						cvSink.grabFrame(source);
						Rect r = Imgproc.boundingRect(pipeline.filterContoursOutput().get(0));
						Rect r1 = Imgproc.boundingRect(pipeline.filterContoursOutput().get(1));
						Imgproc.rectangle(source, new Point(r.x, r.y), new Point(r.x + r.width, r.y + r.height),
								new Scalar(0, 0, 255),2);
						Imgproc.rectangle(source, new Point(r1.x, r1.y), new Point(r1.x + r1.width, r1.y + r1.height),
								new Scalar(0, 0, 255),2);
						//Imgproc.cvtColor(source, output, Imgproc.COLOR_BGR2GRAY);
						outputStream.putFrame(source);
						// Can do target math here

					}
				}
			}
		});
		pegVisionThread.setDaemon(true);
		pegVisionThread.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 04:15.

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