本文整理汇总了Java中edu.wpi.first.wpilibj.image.NIVision.getLinearAverages方法的典型用法代码示例。如果您正苦于以下问题:Java NIVision.getLinearAverages方法的具体用法?Java NIVision.getLinearAverages怎么用?Java NIVision.getLinearAverages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.wpi.first.wpilibj.image.NIVision
的用法示例。
在下文中一共展示了NIVision.getLinearAverages方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scoreXEdge
import edu.wpi.first.wpilibj.image.NIVision; //导入方法依赖的package包/类
/**
* Computes a score based on the match between a template profile and the
* particle profile in the X direction. This method uses the the column
* averages and the profile defined at the top of the sample to look for the
* solid vertical edges with a hollow center.
*
* @param image The image to use, should be the image before the convex hull
* is performed
* @param report The Particle Analysis Report for the particle
*
* @return The X Edge Score (0-100)
*/
public static double scoreXEdge(BinaryImage image, ParticleAnalysisReport report) throws NIVisionException {
double total = 0;
LinearAverages averages;
NIVision.Rect rect = new NIVision.Rect(report.boundingRectTop, report.boundingRectLeft, report.boundingRectHeight, report.boundingRectWidth);
averages = NIVision.getLinearAverages(image.image, LinearAverages.LinearAveragesMode.IMAQ_COLUMN_AVERAGES, rect);
float columnAverages[] = averages.getColumnAverages();
for (int i = 0; i < (columnAverages.length); i++) {
if (xMin[(i * (XMINSIZE - 1) / columnAverages.length)] < columnAverages[i]
&& columnAverages[i] < xMax[i * (XMAXSIZE - 1) / columnAverages.length]) {
total++;
}
}
total = 100 * total / (columnAverages.length);
return total;
}
示例2: scoreYEdge
import edu.wpi.first.wpilibj.image.NIVision; //导入方法依赖的package包/类
/**
* Computes a score based on the match between a template profile and the
* particle profile in the Y direction. This method uses the the row
* averages and the profile defined at the top of the sample to look for the
* solid horizontal edges with a hollow center
*
* @param image The image to use, should be the image before the convex hull
* is performed
* @param report The Particle Analysis Report for the particle
*
* @return The Y Edge score (0-100)
*
*/
public static double scoreYEdge(BinaryImage image, ParticleAnalysisReport report) throws NIVisionException {
double total = 0;
LinearAverages averages;
NIVision.Rect rect = new NIVision.Rect(report.boundingRectTop, report.boundingRectLeft, report.boundingRectHeight, report.boundingRectWidth);
averages = NIVision.getLinearAverages(image.image, LinearAverages.LinearAveragesMode.IMAQ_ROW_AVERAGES, rect);
float rowAverages[] = averages.getRowAverages();
for (int i = 0; i < (rowAverages.length); i++) {
if (yMin[(i * (YMINSIZE - 1) / rowAverages.length)] < rowAverages[i]
&& rowAverages[i] < yMax[i * (YMAXSIZE - 1) / rowAverages.length]) {
total++;
}
}
total = 100 * total / (rowAverages.length);
return total;
}
示例3: scoreXEdge
import edu.wpi.first.wpilibj.image.NIVision; //导入方法依赖的package包/类
/**
* Computes a score based on the match between a template profile and the particle profile in the X direction. This method uses the
* the column averages and the profile defined at the top of the sample to look for the solid vertical edges with
* a hollow center.
*
* @param image The image to use, should be the image before the convex hull is performed
* @param report The Particle Analysis Report for the particle
*
* @return The X Edge Score (0-100)
*/
public double scoreXEdge(BinaryImage image, ParticleAnalysisReport report) throws NIVisionException
{
double total = 0;
LinearAverages averages;
NIVision.Rect rect = new NIVision.Rect(report.boundingRectTop, report.boundingRectLeft, report.boundingRectHeight, report.boundingRectWidth);
averages = NIVision.getLinearAverages(image.image, LinearAverages.LinearAveragesMode.IMAQ_COLUMN_AVERAGES, rect);
float columnAverages[] = averages.getColumnAverages();
for(int i=0; i < (columnAverages.length); i++){
if(xMin[(i*(XMINSIZE-1)/columnAverages.length)] < columnAverages[i]
&& columnAverages[i] < xMax[i*(XMAXSIZE-1)/columnAverages.length]){
total++;
}
}
total = 100*total/(columnAverages.length);
return total;
}
示例4: scoreYEdge
import edu.wpi.first.wpilibj.image.NIVision; //导入方法依赖的package包/类
/**
* Computes a score based on the match between a template profile and the particle profile in the Y direction. This method uses the
* the row averages and the profile defined at the top of the sample to look for the solid horizontal edges with
* a hollow center
*
* @param image The image to use, should be the image before the convex hull is performed
* @param report The Particle Analysis Report for the particle
*
* @return The Y Edge score (0-100)
*
*/
public double scoreYEdge(BinaryImage image, ParticleAnalysisReport report) throws NIVisionException
{
double total = 0;
LinearAverages averages;
NIVision.Rect rect = new NIVision.Rect(report.boundingRectTop, report.boundingRectLeft, report.boundingRectHeight, report.boundingRectWidth);
averages = NIVision.getLinearAverages(image.image, LinearAverages.LinearAveragesMode.IMAQ_ROW_AVERAGES, rect);
float rowAverages[] = averages.getRowAverages();
for(int i=0; i < (rowAverages.length); i++){
if(yMin[(i*(YMINSIZE-1)/rowAverages.length)] < rowAverages[i]
&& rowAverages[i] < yMax[i*(YMAXSIZE-1)/rowAverages.length]){
total++;
}
}
total = 100*total/(rowAverages.length);
return total;
}