Go to Post By the end of week six, I'm sick of looking at the robot enough that stuffing it in a bag is rather cathartic...:rolleyes: - 2544HCRC [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-01-2013, 15:52
flamer075 flamer075 is offline
Registered User
FRC #3200
 
Join Date: Jan 2013
Location: Colorado
Posts: 21
flamer075 is an unknown quantity at this point
Camera Tracking

My team programs in Java. We need help with some camera tracking code, we wished to accomplish this last year, but it seems to be a bigger deal this year. Any help and sample code would be much appreciated.
  #2   Spotlight this post!  
Unread 09-01-2013, 16:28
DjScribbles DjScribbles is offline
Programming Mentor
AKA: Joe S
FRC #2474 (Team Excel)
Team Role: Mentor
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Niles MI
Posts: 284
DjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to beholdDjScribbles is a splendid one to behold
Re: Camera Tracking

This whitepaper was put out last year, and goes over the "concepts" in vision targeting: https://decibel.ni.com/content/docs/DOC-20173 I highly suggest reading the whole thing.

You will want to use the NI vision assistant to determine your vision processing algorithm and parameters.

From there, I'm not a java guy, but I can link you my C++ code from last year, which should be quite similar to the java implementation:
https://github.com/TeamExcel/Project.../Robot2012.cpp
Line 454 has camera setup and image aquisition and checking.
Line 795 is where image processing starts.
Line 1313 is the camera init function.

Here are the basic steps, with extra features removed, and all null checking stuff.
Code:
//Get an instance of the camera
AxisCamera &camera = AxisCamera::GetInstance("10.24.74.11");

//Allocate an image
ColorImage *colorImage = new ColorImage(IMAQ_IMAGE_HSL);

//Fill that image with the camera data
camera.GetImage(colorImage);

//Turn the image from the camera into an image where only your target is shown
binaryImage = colorImage->ThresholdHSL(90, 115,30, 255, 70, 255);

//Get a particle analysis report.
vector<ParticleAnalysisReport> *reports = binaryImage->GetOrderedParticleAnalysisReports();

//Find the target you want to shoot (here I get the top one), you may want to apply a particle filter before this step.
for (int particleIndex = 0; particleIndex < reports->size(); particleIndex++)
{
	ParticleAnalysisReport &thisReport = reports->at(particleIndex);
	if ((!topParticlePtr) || (thisReport.center_mass_y < topParticlePtr->center_mass_y))
	{
		topParticlePtr = &thisReport;
	}
}

//then get the metrics you want from the top target, here I got center of mass
int centerOfMassX = topParticlePtr->center_mass_x;
I think I got all the important steps, but I don't claim my code, or the helper code above to be bug free
Closed Thread


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 02:14.

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