本文整理汇总了C++中BinaryImage::GetNumberParticles方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryImage::GetNumberParticles方法的具体用法?C++ BinaryImage::GetNumberParticles怎么用?C++ BinaryImage::GetNumberParticles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryImage
的用法示例。
在下文中一共展示了BinaryImage::GetNumberParticles方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tracking
bool tracking (bool use_alternate_score) //camera tracking function
{
//takes one camera frame and turns towards tallest target
//returns true if target is within deadzone, returns false otherwise
Threshold tapeThreshold(0, 255, 0, 90, 220, 255); //red hsl as of 20110303, this is the hue, saturation and luminosicity ranges that we want
BinaryImage *tapePixels;//
Image *convexHull;
BinaryImage *convexHullBinaryImage;
ParticleAnalysisReport par;//analyzed blob (pre convex hull)
ParticleAnalysisReport convexpar;// ONE filled-in blob
vector<ParticleAnalysisReport>* pars;//where many analyzed blob goes (pre)
vector<ParticleAnalysisReport>* convexpars; //where MANY filled-in blobs go
bool foundAnything = false;
double best_score = 120;
double best_speed;
double particle_score;
ImageType t;
int bs;
img = cam->GetImage();
printf("cam->GetImage() returned frame %d x %d\n",img->GetWidth(),img->GetHeight());
tapePixels = img->ThresholdHSL(tapeThreshold);
imaqGetBorderSize(tapePixels->GetImaqImage(),&bs);
imaqGetImageType(tapePixels->GetImaqImage(),&t);
convexHull = imaqCreateImage(t,bs);
convexHullBinaryImage = new BinaryImageWrapper(convexHull);
convexHullBinaryImage->GetOrderedParticleAnalysisReports();
//tapePixels = img->ThresholdHSL(int 0,int 50,int -100,int -50,int luminenceLow,int luminanceHigh);
pars = tapePixels->GetOrderedParticleAnalysisReports();
imaqConvexHull(convexHull,tapePixels->GetImaqImage(),true);
convexHullBinaryImage = new BinaryImageWrapper(convexHull);
convexpars = convexHullBinaryImage->GetOrderedParticleAnalysisReports();
//imaqGetParticleInfo()
//convexpars = convexHull->GetOrderedParticleAnalysisReports();
for (int i=0;i < convexHullBinaryImage->GetNumberParticles();i++)
{
//par = (*pars)[0];
//convexpar = (*convexpars)[i];
convexpar = convexHullBinaryImage->GetParticleAnalysisReport(i);
par = tapePixels->GetParticleAnalysisReport(i);
if((convexpar.boundingRect.width < 10) || (convexpar.boundingRect.height < 7))
{
continue;
}
// printf("%d par:%f convex:%f particle area\n",i,par.particleArea,convexpar.particleArea);
if ((par.particleArea/convexpar.particleArea > 0.4))
{
printf("%d skip max fillness ratio\n",i);
continue;
}
if ((par.particleArea/convexpar.particleArea < 0.10))
{
printf("%d skip min fillness ratio\n",i);
continue;
}
if((double)(convexpar.boundingRect.width)/(double)(convexpar.boundingRect.height)>1.8)
{
printf("%d skip max aspect ratio\n",i);
continue;
}
if((double)(convexpar.boundingRect.width)/(double)(convexpar.boundingRect.height)<.8)
{
printf("%d skip min aspect ratio\n",i);
continue;
}
//printf("%f center of mass x\n",par.center_mass_x_normalized);
//printf("%f center of mass y\n",par.center_mass_y_normalized);
distanceInInches = (18.0*179.3)/(convexpar.boundingRect.height);
double pwidth = convexpar.boundingRect.width;
double mwidth = ((double)convexpar.boundingRect.left+(double)convexpar.boundingRect.width*0.5);
double angle = ((180.0/3.14159)*acos (pwidth * distanceInInches/179.3/24.0) );
if(angle != angle) angle = 0.0; // if angle is NaN, set to zero
printf("%f distance in inches\n",distanceInInches);
//printf("%f angle\n",(180.0/3.14159)*acos (pwidth * distanceInInches/415.0/24.0) );
printf("%d BBctrX:%f CMX:%f\n", i, (double)convexpar.boundingRect.left + (double)convexpar.boundingRect.width*0.5, (double)par.center_mass_x);
//printf("%f angle2\n",(((pwidth * distanceInInches)/415.0)/24.0));
//printf("%f center of mass x\n",par.center_mass_x_normalized);
printf("%d %f %f center of mass x\n",i,convexpar.center_mass_x_normalized,par.center_mass_x_normalized);
printf("%d %f %f center of mass y\n",i,convexpar.center_mass_y_normalized,par.center_mass_y_normalized);
printf("%d %f %f rectangle score\n",i,(convexpar.particleArea)/((convexpar.boundingRect.width)*(convexpar.boundingRect.height))*(100),(par.particleArea)/((par.boundingRect.width)*(par.boundingRect.height))*(100));
printf("%d %f fillness ratio\n",i,par.particleArea/convexpar.particleArea);
printf("%d %d %d width and height\n",i,(convexpar.boundingRect.width),(convexpar.boundingRect.height));
printf("%d %f aspect ratio\n",i,((convexpar.boundingRect.width)/(double)(convexpar.boundingRect.height)));
if ((double)(par.center_mass_x)>mwidth)
{
angle=angle*(-1.0);
}
printf("%f true angle\n",angle);
//.........这里部分代码省略.........