项目:2014CataBot
文件:ImagingUtils.java
/**
* Computes a score (0-100) comparing the aspect ratio to the ideal aspect
* ratio for the target. This method uses the equivalent rectangle sides to
* determine aspect ratio as it performs better as the target gets skewed by
* moving to the left or right. The equivalent rectangle is the rectangle
* with sides x and y where particle area= x*y and particle perimeter= 2x+2y
*
* @param image The image containing the particle to score,needed to
* performa additional measurements
* @param report The Particle Analysis Report for the particle,used for the
* width,height,and particle number
* @param outer Indicates whether the particle aspect ratio should be
* compared to the ratio for the inner target or the outer
* @return The aspect ratio score (0-100)
*/
public static double scoreAspectRatio(BinaryImage image,ParticleAnalysisReport report,int particleNumber,boolean outer) throws NIVisionException {
double rectLong,rectShort,aspectRatio,idealAspectRatio;
rectLong = NIVision.MeasureParticle(image.image,particleNumber,false,NIVision.MeasurementType.IMAQ_MT_EQUIVALENT_RECT_LONG_SIDE);
rectShort = NIVision.MeasureParticle(image.image,NIVision.MeasurementType.IMAQ_MT_EQUIVALENT_RECT_SHORT_SIDE);
//idealAspectRatio = outer ? (62/29) : (62/20); //Dimensions of goal opening + 4 inches on all 4 sides for reflective tape
idealAspectRatio = outer ? (43 / 32) : (39 / 28);
//Divide width by height to measure aspect ratio
aspectRatio = report.boundingRectWidth / (double) report.boundingRectHeight;
/*if(report.boundingRectWidth > report.boundingRectHeight){
//particle is wider than it is tall,divide long by short
aspectRatio = 100*(1-Math.abs((1-((rectLong/rectShort)/idealAspectRatio))));
} else {
//particle is taller than it is wide,divide short by long
aspectRatio = 100*(1-Math.abs((1-((rectShort/rectLong)/idealAspectRatio))));
}*/
return aspectRatio;
//return (Math.max(0,Math.min(aspectRatio,100.0))); //force to be in range 0-100
}
项目:2014CataBot
文件:ImagingUtils.java
/**
* 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;
}
项目:2014CataBot
文件:ImagingUtils.java
/**
* 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,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;
}
项目:Aerial-Assist
文件:AxisCameraM1101.java
/**
* Computes a score (0-100) comparing the aspect ratio to the ideal aspect
* ratio for the target. This method uses the equivalent rectangle sides to
* determine aspect ratio as it performs better as the target gets skewed by
* moving to the left or right. The equivalent rectangle is the rectangle
* with sides x and y where particle area,xy and particle perimeter,2x+2y
*
* @param image The image containing the particle to score,needed to
* perform additional measurements
* @param report The Particle Analysis Report for the particle,and particle number
* @param outer Indicates whether the particle aspect ratio should be
* compared to the ratio for the inner target or the outer
* @return The aspect ratio score (0-100)
*/
private double scoreAspectRatio(BinaryImage image,ParticleAnalysisReport
report,boolean vertical) throws
NIVisionException {
double rectLong,MeasurementType.IMAQ_MT_EQUIVALENT_RECT_LONG_SIDE);
rectShort = NIVision.MeasureParticle(image.image,MeasurementType.IMAQ_MT_EQUIVALENT_RECT_SHORT_SIDE);
idealAspectRatio = vertical ? (4.0 / 32) : (23.5 / 4);
if (report.boundingRectWidth > report.boundingRectHeight) {
aspectRatio = ratioToscore((rectLong / rectShort)/idealAspectRatio);
} else {
aspectRatio = ratioToscore((rectShort / rectLong)/idealAspectRatio);
}
return aspectRatio;
}
项目:2014RobotCode
文件:CameraDetection.java
public double scoreAspectRatio(BinaryImage image,boolean vertical) throws NIVisionException
{
double rectLong,idealAspectRatio;
rectLong = NIVision.MeasureParticle(image.image,NIVision.MeasurementType.IMAQ_MT_EQUIVALENT_RECT_LONG_SIDE);
rectShort = NIVision.MeasureParticle(image.image,NIVision.MeasurementType.IMAQ_MT_EQUIVALENT_RECT_SHORT_SIDE);
idealAspectRatio = vertical ? (4.0/32) : (23.5/4); //Vertical reflector 4" wide x 32" tall,horizontal 23.5" wide x 4" tall
//Divide width by height to measure aspect ratio
if(report.boundingRectWidth > report.boundingRectHeight){
//particle is wider than it is tall,divide long by short
aspectRatio = ratioToscore((rectLong/rectShort)/idealAspectRatio);
} else {
//particle is taller than it is wide,divide short by long
aspectRatio = ratioToscore((rectShort/rectLong)/idealAspectRatio);
}
return aspectRatio;
}
/**
* Computes a score (0-100) comparing the aspect ratio to the ideal aspect
* ratio for the target. This method uses the equivalent rectangle sides to
* determine aspect ratio as it performs better as the target gets skewed by
* moving to the left or right. The equivalent rectangle is the rectangle
* with sides x and y where particle area= x*y and particle perimeter= 2x+2y
*
* @param image The image containing the particle to score,and particle number
* @param outer Indicates whether the particle aspect ratio should be
* compared to the ratio for the inner target or the outer
* @return The aspect ratio score (0-100)
*/
private static double scoreAspectRatio(BinaryImage image,boolean vertical) throws NIVisionException {
double rectLong,NIVision.MeasurementType.IMAQ_MT_EQUIVALENT_RECT_SHORT_SIDE);
idealAspectRatio = vertical ? (4.0 / 32) : (23.5 / 4); //Vertical reflector 4" wide x 32" tall,horizontal 23.5" wide x 4" tall
//Divide width by height to measure aspect ratio
if (report.boundingRectWidth > report.boundingRectHeight) {
//particle is wider than it is tall,divide long by short
aspectRatio = ratioToscore((rectLong / rectShort) / idealAspectRatio);
} else {
//particle is taller than it is wide,divide short by long
aspectRatio = ratioToscore((rectShort / rectLong) / idealAspectRatio);
}
return aspectRatio;
}
项目:FRCTesting
文件:ImageUtils.java
/**
* Computes a score (0-100) comparing the aspect ratio to the ideal aspect
* ratio for the target. This method uses the equivalent rectangle sides to
* determine aspect ratio as it performs better as the target gets skewed by
* moving to the left or right. The equivalent rectangle is the rectangle
* with sides x and y where particle area= x*y and particle perimeter= 2x+2y
*
* @param image The image containing the particle to score,100.0))); //force to be in range 0-100
}
项目:FRCTesting
文件:ImageUtils.java
/**
* 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,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;
}
项目:FRCTesting
文件:ImageUtils.java
/**
* 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,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;
}
项目:2014_software
文件:HotGoalDetector.java
public double scoreAspectRatio(BinaryImage image,boolean vertical) throws NIVisionException
{
double rectLong,horizontal 23.5" wide x 4" tall
if (report.boundingRectWidth > report.boundingRectHeight)
{
aspectRatio = ratioToscore((rectLong / rectShort) / idealAspectRatio);
}
else
{
aspectRatio = ratioToscore((rectShort / rectLong) / idealAspectRatio);
}
return aspectRatio;
}
项目:2014_software
文件:HotGoalDetector.java
public double scoreAspectRatioOnRotatedImage(BinaryImage image,NIVision.MeasurementType.IMAQ_MT_EQUIVALENT_RECT_SHORT_SIDE);
idealAspectRatio = vertical ? (32.0 / 4) : (4/23.5); //Vertical reflector 4" wide x 32" tall,horizontal 23.5" wide x 4" tall
if (report.boundingRectWidth > report.boundingRectHeight)
{
aspectRatio = ratioToscore((rectLong / rectShort) / idealAspectRatio);
}
else
{
aspectRatio = ratioToscore((rectShort / rectLong) / idealAspectRatio);
}
return aspectRatio;
}
项目:FRC623Robot2014
文件:VisionController.java
/**
* Computes a score (0-100) comparing the aspect ratio to the ideal aspect
* ratio for the target. This method uses the equivalent rectangle sides to
* determine aspect ratio as it performs better as the target gets skewed by
* moving to the left or right. The equivalent rectangle is the rectangle
* with sides x and y where particle area= x*y and particle perimeter= 2x+2y
*
* @param image The image containing the particle to score,divide short by long
aspectRatio = ratioToscore((rectShort / rectLong) / idealAspectRatio);
}
return aspectRatio;
}
项目:2013ultimate-ascent
文件:GRTVisionTracker.java
/**
* Computes a score (0-100) comparing the aspect ratio to the ideal aspect ratio for the target. This method uses
* the equivalent rectangle sides to determine aspect ratio as it performs better as the target gets skewed by moving
* to the left or right. The equivalent rectangle is the rectangle with sides x and y where particle area= x*y
* and particle perimeter= 2x+2y
*
* @param image The image containing the particle to score,needed to performa additional measurements
* @param report The Particle Analysis Report for the particle,used for the width,and particle number
* @param outer Indicates whether the particle aspect ratio should be compared to the ratio for the inner target or the outer
* @return The aspect ratio score (0-100)
*/
public double scoreAspectRatio(BinaryImage image,boolean outer) throws NIVisionException
{
double rectLong,NIVision.MeasurementType.IMAQ_MT_EQUIVALENT_RECT_SHORT_SIDE);
//idealAspectRatio = outer ? (62/29) : (62/20); //Dimensions of goal opening + 4 inches on all 4 sides for reflective tape
//yonatan - change back
idealAspectRatio = outer ? (62/29) : (62/40); //Dimensions of goal opening + 4 inches on all 4 sides for reflective tape
//Divide width by height to measure aspect ratio
if(report.boundingRectWidth > report.boundingRectHeight){
//particle is wider than it is tall,divide long by short
aspectRatio = 100*(1-Math.abs((1-((rectLong/rectShort)/idealAspectRatio))));
} else {
//particle is taller than it is wide,divide short by long
aspectRatio = 100*(1-Math.abs((1-((rectShort/rectLong)/idealAspectRatio))));
}
return (Math.max(0,100.0))); //force to be in range 0-100
}
项目:2013ultimate-ascent
文件:GRTVisionTracker.java
/**
* 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,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;
}
项目:2013ultimate-ascent
文件:GRTVisionTracker.java
/**
* 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,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;
}
项目:2013-code-v2
文件:TestVision.java
/**
* @param particle the blob found in image processing
* @return target type( Top,Middle)
* calculates type of target based on width to height ratios
*/
String gettargettype(int particle) {
String target = "not set";
try {
ParticleAnalysisReport report = newFilteredImage.getParticleAnalysisReport(particle);
int blobWidth = report.boundingRectWidth;
int blobHeight = report.boundingRectHeight;
if (blobWidth / blobHeight > (topWidth / topHeight - 1) && blobWidth / blobHeight < (topWidth / topHeight + 1)) {
target = "Top target";
} else if (blobWidth / blobHeight > (middleWidth / middleHeight - 1) && blobWidth / blobHeight < (middleWidth / middleHeight + 1)) {
target = "Middle Target";
} else {
target = "Not Top/Middle";
}
} catch (NIVisionException ex) {
ex.printstacktrace();
}
return target;
}
项目:grtframeworkv7
文件:GRTVisionTracker.java
/**
* Computes a score (0-100) comparing the aspect ratio to the ideal aspect ratio for the target. This method uses
* the equivalent rectangle sides to determine aspect ratio as it performs better as the target gets skewed by moving
* to the left or right. The equivalent rectangle is the rectangle with sides x and y where particle area= x*y
* and particle perimeter= 2x+2y
*
* @param image The image containing the particle to score,100.0))); //force to be in range 0-100
}
项目:grtframeworkv7
文件:GRTVisionTracker.java
/**
* 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,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;
}
项目:grtframeworkv7
文件:GRTVisionTracker.java
/**
* 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,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;
}
项目:Team_1482_2013
文件:vision.java
/**
* Computes a score (0-100) comparing the aspect ratio to the ideal aspect ratio for the target. This method uses
* the equivalent rectangle sides to determine aspect ratio as it performs better as the target gets skewed by moving
* to the left or right. The equivalent rectangle is the rectangle with sides x and y where particle area= x*y
* and particle perimeter= 2x+2y
*
* @param image The image containing the particle to score,needed to perform additional measurements
* @param report The Particle Analysis Report for the particle,and particle number
* @param outer Indicates whether the particle aspect ratio should be compared to the ratio for the inner target or the outer
* @return The aspect ratio score (0-100)
*/
public double scoreAspectRatio(BinaryImage image,divide short by long
aspectRatio = ratioToscore((rectShort/rectLong)/idealAspectRatio);
}
return aspectRatio;
}
项目:Aerial-Assist
文件:AxisCameraM1101.java
/**
* Computes the estimated distance to a target using the height of the
* particle in the image. For more information and graphics showing the math
* behind this approach see the Vision Processing section of the
* ScreenStepsLive documentation.
*
* @param image The image to use for measuring the particle estimated
* rectangle.
* @param report The particle analysis report for the particle.
* @param outer True if the particle should be treated as an outer target,* false to treat it as a center target.
* @return The estimated distance to the target in inches.
*/
private double computedistance(BinaryImage image,int particleNumber) throws NIVisionException {
double rectLong,height;
int targetHeight;
rectLong = NIVision.MeasureParticle(image.image,MeasurementType.IMAQ_MT_EQUIVALENT_RECT_LONG_SIDE);
height = Math.min(report.boundingRectHeight,rectLong);
targetHeight = 32;
return Y_IMAGE_RES * targetHeight / (height * 12 * 2
* Math.tan(VIEW_ANGLE * Math.PI / (180 * 2)));
}
项目:Aerial-Assist
文件:AxisCameraM1101.java
/**
* Computes a score (0-100) estimating how rectangular the particle is by
* comparing the area of the particle to the area of the bounding Box that
* surrounds it. A perfect rectangle would cover the entire bounding Box.
*
* @param report The particle analysis report for the particle to score.
* @return The rectangularity score,ranging from 0 to 100.
*/
private double scoreRectangularity(ParticleAnalysisReport report) {
double boundArea = report.boundingRectWidth * report.boundingRectHeight;
if (boundArea != 0) {
return 100 * report.particleArea / boundArea;
} else {
return 0;
}
}
项目:2014RobotCode
文件:CameraDetection.java
double computedistance (BinaryImage image,int particleNumber) throws NIVisionException {
double rectLong,height;
int targetHeight;
rectLong = NIVision.MeasureParticle(image.image,NIVision.MeasurementType.IMAQ_MT_EQUIVALENT_RECT_LONG_SIDE);
//using the smaller of the estimated rectangle long side and the bounding rectangle height results in better performance
//on skewed rectangles
height = Math.min(report.boundingRectHeight,rectLong);
targetHeight = 32;
return Y_IMAGE_RES * targetHeight / (height * 12 * 2 * Math.tan(VIEW_ANGLE*Math.PI/(180*2)));
}
项目:2014RobotCode
文件:CameraDetection.java
/**
* Computes a score (0-100) estimating how rectangular the particle is by comparing the area of the particle
* to the area of the bounding Box surrounding it. A perfect rectangle would cover the entire bounding Box.
*
* @param report The Particle Analysis Report for the particle to score
* @return The rectangularity score (0-100)
*/
double scoreRectangularity(ParticleAnalysisReport report){
if(report.boundingRectWidth*report.boundingRectHeight !=0){
return 100*report.particleArea/(report.boundingRectWidth*report.boundingRectHeight);
} else {
return 0;
}
}
项目:2014_software
文件:HotGoalDetector.java
double computedistance(BinaryImage image,int particleNumber) throws NIVisionException
{
double rectLong,NIVision.MeasurementType.IMAQ_MT_EQUIVALENT_RECT_LONG_SIDE);
height = Math.min(report.boundingRectHeight,rectLong);
targetHeight = 32;
return Y_IMAGE_RES * targetHeight / (height * 12 * 2 * Math.tan(VIEW_ANGLE * Math.PI / (180 * 2)));
}
项目:2014_software
文件:HotGoalDetector.java
项目:2014_software
文件:HotGoalDetector.java
protected double scoreRectangularity(ParticleAnalysisReport report)
{
if (report.boundingRectWidth * report.boundingRectHeight != 0)
{
return 100 * report.particleArea / (report.boundingRectWidth * report.boundingRectHeight);
}
else
{
return 0;
}
}
项目:RobotCode2013
文件:Vision.java
public VisionTarget [] processFrame() {
if (enableVision) {
lastFrame = System.currentTimeMillis();
try {
ColorImage image = camera.getimage();
BinaryImage bImage = image.thresholdRGB(
redLow,redHigh,greenLow,greenHigh,blueLow,blueHigh);
BinaryImage fImage = bImage.particleFilter(cc);
ParticleAnalysisReport [] report = fImage.getorderedParticleAnalysisReports();
VisionTarget [] targets = new VisionTarget[report.length];
for (int i = 0; i < report.length; i++) {
double centerX = report[i].center_mass_x;
double centerY = report[i].center_mass_y;
double width = report[i].boundingRectWidth;
double height = report[i].boundingRectHeight;
int area = (int)report[i].particleArea;
targets[i] = new VisionTarget(centerX,centerY,width,area);
}
frameProcess = System.currentTimeMillis() - lastFrame;
image.free();
bImage.free();
fImage.free();
return targets;
} catch (AxisCameraException e) {
System.out.println("No Image From Camera: ");
frameProcess = System.currentTimeMillis() - lastFrame;
return new VisionTarget[0];
} catch (Exception ex) {
System.out.println("Camera Exception Thrown: " + ex.getMessage());
frameProcess = System.currentTimeMillis() - lastFrame;
return new VisionTarget[0];
}
} else { // Vision is not enabled
return new VisionTarget[0];
}
}
项目:2013-Ultimate-Ascent-Robot
文件:ImageProcesser.java
private void sortReports(SquawkVector blobs,double ratio){
for(int i = 0; i < blobs.size(); i++){
int best = i;
for(int j = i + 1; j < blobs.size(); j++){
if(Math.abs(ratio-((ParticleAnalysisReport)blobs.elementAt(j)).boundingRectWidth / ((ParticleAnalysisReport)blobs.elementAt(j)).boundingRectHeight)
< Math.abs(ratio-((ParticleAnalysisReport)blobs.elementAt(best)).boundingRectWidth / ((ParticleAnalysisReport)blobs.elementAt(best)).boundingRectHeight)) {
best = j;
}
}
Object tmp = blobs.elementAt(i);
blobs.setElementAt(blobs.elementAt(best),i);
blobs.setElementAt(tmp,best);
}
}
项目:2013ultimate-ascent
文件:GRTVisionTracker.java
/**
* Computes the estimated distance to a target using the height of the particle in the image. For more information and graphics
* showing the math behind this approach see the Vision Processing section of the ScreenStepsLive documentation.
*
* @param image The image to use for measuring the particle estimated rectangle
* @param report The Particle Analysis Report for the particle
* @param outer True if the particle should be treated as an outer target,false to treat it as a center target
* @return The estimated distance to the target in Inches.
*/
double computedistance (BinaryImage image,boolean outer) throws NIVisionException {
double rectShort,height;
double targetWidth,targetHeight;
rectShort = NIVision.MeasureParticle(image.image,NIVision.MeasurementType.IMAQ_MT_EQUIVALENT_RECT_SHORT_SIDE);
//using the smaller of the estimated rectangle short side and the bounding rectangle height results in better performance
//on skewed rectangles
//height = Math.min(report.boundingRectHeight,rectShort);
width = report.boundingRectWidth;
height = report.boundingRectHeight;
//targetHeight = outer ? 29 : 21;
//changed by Yonatan Oren//
//need to change this back to 29/21 for for real ultimate ascent//
targetWidth = 16;
targetHeight = 9.75;
////
// System.out.println("rectShort: " + rectShort);
// System.out.println("height: " + height);
// System.out.println("boundingRectHeight: " + report.boundingRectHeight);
//changed by Yonatan Oren//
//return X_IMAGE_RES * targetHeight / (height * 12 * 2 * Math.tan(VIEW_ANGLE*Math.PI/(180*2)));
//return 240.0 * targetWidth / (width * Math.tan(VIEW_ANGLE*Math.PI/(180*2)));
return 360.0 * targetHeight / (height * Math.tan(VIEW_ANGLE*Math.PI/(180*2)));
//4800 / 62 * tan(
}
项目:2013ultimate-ascent
文件:GRTVisionTracker.java
/**
* Computes a score (0-100) estimating how rectangular the particle is by comparing the area of the particle
* to the area of the bounding Box surrounding it. A perfect rectangle would cover the entire bounding Box.
*
* @param report The Particle Analysis Report for the particle to score
* @return The rectangularity score (0-100)
*/
double scoreRectangularity(ParticleAnalysisReport report){
if(report.boundingRectWidth*report.boundingRectHeight !=0){
return 100*report.particleArea/(report.boundingRectWidth*report.boundingRectHeight);
} else {
return 0;
}
}
项目:grtframeworkv7
文件:GRTVisionTracker.java
/**
* Computes the estimated distance to a target using the height of the particle in the image. For more information and graphics
* showing the math behind this approach see the Vision Processing section of the ScreenStepsLive documentation.
*
* @param image The image to use for measuring the particle estimated rectangle
* @param report The Particle Analysis Report for the particle
* @param outer True if the particle should be treated as an outer target,rectShort);
width = report.boundingRectWidth;
height = report.boundingRectHeight;
//targetHeight = outer ? 29 : 21;
//changed by Yonatan Oren//
//need to change this back to 29/21 for for real ultimate ascent//
targetWidth = 16;
targetHeight = 9.75;
////
// System.out.println("rectShort: " + rectShort);
// System.out.println("height: " + height);
// System.out.println("boundingRectHeight: " + report.boundingRectHeight);
//changed by Yonatan Oren//
//return X_IMAGE_RES * targetHeight / (height * 12 * 2 * Math.tan(VIEW_ANGLE*Math.PI/(180*2)));
//return 240.0 * targetWidth / (width * Math.tan(VIEW_ANGLE*Math.PI/(180*2)));
return 360.0 * targetHeight / (height * Math.tan(VIEW_ANGLE*Math.PI/(180*2)));
//4800 / 62 * tan(
}
项目:grtframeworkv7
文件:GRTVisionTracker.java
/**
* Computes a score (0-100) estimating how rectangular the particle is by comparing the area of the particle
* to the area of the bounding Box surrounding it. A perfect rectangle would cover the entire bounding Box.
*
* @param report The Particle Analysis Report for the particle to score
* @return The rectangularity score (0-100)
*/
double scoreRectangularity(ParticleAnalysisReport report){
if(report.boundingRectWidth*report.boundingRectHeight !=0){
return 100*report.particleArea/(report.boundingRectWidth*report.boundingRectHeight);
} else {
return 0;
}
}
项目:Team_1482_2013
文件:vision.java
/**
* Computes the estimated distance to a target using the height of the particle in the image. For more information and graphics
* showing the math behind this approach see the Vision Processing section of the ScreenStepsLive documentation.
*
* @param image The image to use for measuring the particle estimated rectangle
* @param report The Particle Analysis Report for the particle
* @param outer True if the particle should be treated as an outer target,false to treat it as a center target
* @return The estimated distance to the target in Inches.
*/
double computedistance (BinaryImage image,rectLong);
targetHeight = 32;
return Y_IMAGE_RES * targetHeight / (height * 12 * 2 * Math.tan(VIEW_ANGLE*Math.PI/(180*2)));
}
项目:Team_1482_2013
文件:vision.java
/**
* Computes a score (0-100) estimating how rectangular the particle is by comparing the area of the particle
* to the area of the bounding Box surrounding it. A perfect rectangle would cover the entire bounding Box.
*
* @param report The Particle Analysis Report for the particle to score
* @return The rectangularity score (0-100)
*/
double scoreRectangularity(ParticleAnalysisReport report){
if(report.boundingRectWidth*report.boundingRectHeight !=0){
return 100*report.particleArea/(report.boundingRectWidth*report.boundingRectHeight);
} else {
return 0;
}
}
项目:2013-Ultimate-Ascent-Robot
文件:ImageProcesser.java
private boolean isCandidate(ParticleAnalysisReport blob,double ratio,double error){
return blob.boundingRectWidth/blob.boundingRectHeight < ratio*(1+error)
&& blob.boundingRectWidth/blob.boundingRectHeight > ratio*(1-error);
}
private void storetop() throws AxisCameraException {
top = null;
ColorImage ci = getimage();
ParticleAnalysisReport target = null;
if(ci != null) {
try{
System.out.println("Storing top details...");
bi = ci.thresholdRGB(RED_LOW,RED_HIGH,GREEN_LOW,GREEN_HIGH,BLUE_LOW,BLUE_HIGH);
// ci.free();
// ci.image.clear();
// ci.image.free();
bi = bi.convexHull(false);
bi = bi.particleFilter(cc);
bi = bi.removeSmallObjects(true,2);
System.out.println("Got here.");
ParticleAnalysisReport[] reports = bi.getorderedParticleAnalysisReports();
ParticleAnalysisReport tmp;
int lastHighest = 321;
for(int i=0; i<reports.length; i++) {
tmp = reports[i];
if(tmp.center_mass_y < lastHighest) {
lastHighest = tmp.center_mass_y;
target = tmp;
}
}
}
catch(Exception e) {
isProcessing = false;
System.out.println("Error in the processing.");
throw new AxisCameraException("Error: "+e.getMessage());
}
if(target == null) {
isProcessing = false;
throw new AxisCameraException("No targets found that fit the specified criteria.");
}
else {
System.out.println(target.toString());
top = target;
}
// }
// catch(Exception e) {
// isProcessing = false;
// throw new AxisCameraException("Error: "+e.getMessage());
// }
}
else {
isProcessing = false;
throw new AxisCameraException("Couldn't get image.");
}
isProcessing = false;
System.out.println("Finished processing.");
}
项目:2014CataBot
文件:ImagingUtils.java
/**
* Computes the estimated distance to a target using the height of the
* particle in the image. For more information and graphics showing the math
* behind this approach see the Vision Processing section of the
* ScreenStepsLive documentation.
*
* @param image The image to use for measuring the particle estimated
* rectangle
* @param report The Particle Analysis Report for the particle
* @param outer True if the particle should be treated as an outer target,* false to treat it as a center target
* @return The estimated distance to the target in Inches.
*/
public static double computedistance(BinaryImage image,boolean outer) throws NIVisionException {
double rectShort,height;
int targetHeight;
rectShort = NIVision.MeasureParticle(image.image,NIVision.MeasurementType.IMAQ_MT_EQUIVALENT_RECT_SHORT_SIDE);
//using the smaller of the estimated rectangle short side and the bounding rectangle height results in better performance
//on skewed rectangles
height = Math.min(report.boundingRectHeight,rectShort);
targetHeight = outer ? 29 : 21;
return X_IMAGE_RES * targetHeight / (height * 12 * 2 * Math.tan(VIEW_ANGLE * Math.PI / (180 * 2)));
}
项目:2014CataBot
文件:ImagingUtils.java
/**
* Computes a score (0-100) estimating how rectangular the particle is by
* comparing the area of the particle to the area of the bounding Box
* surrounding it. A perfect rectangle would cover the entire bounding Box.
*
* @param report The Particle Analysis Report for the particle to score
* @return The rectangularity score (0-100)
*/
public static double scoreRectangularity(ParticleAnalysisReport report) {
if (report.boundingRectWidth * report.boundingRectHeight != 0) {
return 100 * report.particleArea / (report.boundingRectWidth * report.boundingRectHeight);
} else {
return 0;
}
}
/**
* Computes the estimated distance to a target using the height of the
* particle in the image. For more information and graphics showing the math
* behind this approach see the Vision Processing section of the
* ScreenStepsLive documentation.
*
* @param image The image to use for measuring the particle estimated
* rectangle
* @param report The Particle Analysis Report for the particle
* @param outer True if the particle should be treated as an outer target,* false to treat it as a center target
* @return The estimated distance to the target in Inches.
*/
private static double computedistance(BinaryImage image,NIVision.MeasurementType.IMAQ_MT_EQUIVALENT_RECT_LONG_SIDE);
//using the smaller of the estimated rectangle long side and the bounding rectangle height results in better performance
//on skewed rectangles
height = Math.min(report.boundingRectHeight,rectLong);
targetHeight = 32;
return Y_IMAGE_RES * targetHeight / (height * 12 * 2 * Math.tan(VIEW_ANGLE * Math.PI / (180 * 2)));
}