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.

This whitepaper was put out last year, and goes over the “concepts” in vision targeting: 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:

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.

//Get an instance of the camera
AxisCamera &camera = AxisCamera::GetInstance("");

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

//Fill that image with the camera data

//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 :slight_smile: