code/WPILib/Vision/BinaryImage.cpp
/**
 * Get a single particle analysis report.
 * Get one (of possibly many) particle analysis reports for an image.
 * @param particleNumber Which particle analysis report to return.
 * @returns the selected particle analysis report
 */
Get a single particle analysis report.
Get one (of possibly many) particle analysis reports for an image.
@param particleNumber Which particle analysis report to return.
@returns the selected particle analysis report
Get a single particle analysis report . Get one ( of possibly many ) particle analysis reports for an image . @param particleNumber Which particle analysis report to return . @returns the selected particle analysis report
ParticleAnalysisReport BinaryImage::GetParticleAnalysisReport(int particleNumber)
{
	ParticleAnalysisReport par;
	int success = 0;
	success = imaqGetImageSize(m_imaqImage, &par.imageWidth, &par.imageHeight);
	wpi_imaqAssert(success, "Error getting image size");
	par.particleIndex = particleNumber;		
	success = imaqCountParticles(m_imaqImage, TRUE, NULL);
	wpi_imaqAssert(success, "Error counting particles");
	par.center_mass_x = (int) ParticleMeasurement(particleNumber, IMAQ_MT_CENTER_OF_MASS_X);
	par.center_mass_y = (int) ParticleMeasurement(particleNumber, IMAQ_MT_CENTER_OF_MASS_Y);
	par.particleArea = (int) ParticleMeasurement(particleNumber, IMAQ_MT_AREA);	
	par.boundingRect.top = (int) ParticleMeasurement(particleNumber, IMAQ_MT_BOUNDING_RECT_TOP);
	par.boundingRect.left = (int) ParticleMeasurement(particleNumber, IMAQ_MT_BOUNDING_RECT_LEFT);
	par.boundingRect.height = (int) ParticleMeasurement(particleNumber, IMAQ_MT_BOUNDING_RECT_HEIGHT);
	par.boundingRect.width = (int) ParticleMeasurement(particleNumber, IMAQ_MT_BOUNDING_RECT_WIDTH);
	par.particleToImagePercent = ParticleMeasurement(particleNumber, IMAQ_MT_AREA_BY_IMAGE_AREA);
	par.particleQuality = ParticleMeasurement(particleNumber, IMAQ_MT_AREA_BY_PARTICLE_AND_HOLES_AREA);
	par.center_mass_x_normalized = NormalizeFromRange(par.center_mass_x, par.imageWidth);
	par.center_mass_y_normalized = NormalizeFromRange(par.center_mass_y, par.imageHeight);
	return par;
}
ParticleAnalysisReport BinaryImage :: GetParticleAnalysisReport ( int particleNumber ) { ParticleAnalysisReport par ; int success = 0 ; success = imaqGetImageSize ( m_imaqImage , & par . imageWidth , & par . imageHeight ) ; wpi_imaqAssert ( success , " " ) ; par . particleIndex = particleNumber ; success = imaqCountParticles ( m_imaqImage , TRUE , NULL ) ; wpi_imaqAssert ( success , " " ) ; par . center_mass_x = ( int ) ParticleMeasurement ( particleNumber , IMAQ_MT_CENTER_OF_MASS_X ) ; par . center_mass_y = ( int ) ParticleMeasurement ( particleNumber , IMAQ_MT_CENTER_OF_MASS_Y ) ; par . particleArea = ( int ) ParticleMeasurement ( particleNumber , IMAQ_MT_AREA ) ; par . boundingRect . top = ( int ) ParticleMeasurement ( particleNumber , IMAQ_MT_BOUNDING_RECT_TOP ) ; par . boundingRect . left = ( int ) ParticleMeasurement ( particleNumber , IMAQ_MT_BOUNDING_RECT_LEFT ) ; par . boundingRect . height = ( int ) ParticleMeasurement ( particleNumber , IMAQ_MT_BOUNDING_RECT_HEIGHT ) ; par . boundingRect . width = ( int ) ParticleMeasurement ( particleNumber , IMAQ_MT_BOUNDING_RECT_WIDTH ) ; par . particleToImagePercent = ParticleMeasurement ( particleNumber , IMAQ_MT_AREA_BY_IMAGE_AREA ) ; par . particleQuality = ParticleMeasurement ( particleNumber , IMAQ_MT_AREA_BY_PARTICLE_AND_HOLES_AREA ) ; par . center_mass_x_normalized = NormalizeFromRange ( par . center_mass_x , par . imageWidth ) ; par . center_mass_y_normalized = NormalizeFromRange ( par . center_mass_y , par . imageHeight ) ; return par ; }
Get a single particle analysis report.
Get a single particle analysis report .
/* normalized position (-1 to 1) */