Go to Post Rain? Prepare for Armageddon to strike when you go to St. Louis. Two years in St. Louis. Two years of Tornado scares. Tis the season. - Koko Ed [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 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
  #2   Spotlight this post!  
Unread 01-02-2017, 11:20
SamCarlberg's Avatar
SamCarlberg SamCarlberg is offline
GRIP, WPILib. 2084 alum
FRC #2084
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 161
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: Vision tracking and camera server rectangle draws in only one spot

You have an infinite loop in the pipeline callback, so once the pipeline finds a contour, it will not run again.
__________________
WPILib
GRIP, RobotBuilder
Reply With Quote
  #3   Spotlight this post!  
Unread 01-02-2017, 12:37
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
Re: Vision tracking and camera server rectangle draws in only one spot

Where is it getting caught? I assumed that in the while(!thread.interupted) would continue to grab a new frame and process as long the thread was running.
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