|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Vision Processing
So my team has been trying to take advantage of our camera for autonomous. We've been using some code from 3313, as seen here, to do the processing. Afterwards the for loop is supposed to print out the area of each particle. The number of particles is inconsistent-I may get many, or I may get none. Any extra green in the scene is sure to throw off the number of particles returned. I also had to set up the code to catch an ArrayIndexOutOfBounds exception, which the for loop seems to be causing. I've tried changing the thresholds for RGB- it doesn't seem to help. I can't get the code posted right now, but does anyone have any tips on improving the consistency of our detection?
|
|
#2
|
|||
|
|||
|
Re: Vision Processing
Code used by 3244, much of which is origionally from 3313 :
Code:
private boolean isGoalHot() {
boolean morePoints;
ColorImage image = null;
BinaryImage thresholdImage = null;
BinaryImage bigObjects = null;
BinaryImage convexHullImage = null;
BinaryImage filteredImage = null;
try {
image = camera.getImage();
thresholdImage = image.thresholdRGB(100, 200, 200, 255, 150, 200);//0, 45, 20, 255, 0, 47
bigObjects = thresholdImage.removeSmallObjects(false, 2);
convexHullImage = bigObjects.convexHull(false);
filteredImage = convexHullImage.particleFilter(data);
ParticleAnalysisReport[] reports = filteredImage.getOrderedParticleAnalysisReports();
for (int i = 0; i < reports.length + 1; i++)
{
String stuff;
stuff = "Area " + i + " is " + reports[i].particleArea;
System.out.println(stuff);
log(stuff);
iterations = i;
}
// for (int i = 0; i< reports.length + 1;, i++;) {
// System.out.println(reports[i].center_mass_y);
// double reflectiveTapeArea = 350;
// if(reports[i].particleArea >= reflectiveTapeArea){
// reflectiveTapeCount++;
// }
// if(reflectiveTapeCount >= 2){
// runAuto = true;
// break;
// }
// }
} catch (AxisCameraException axis) {
} catch (NIVisionException ni) {
} catch (ArrayIndexOutOfBoundsException ex){
System.out.println("Array index went out of bounds.");
System.out.println(" " + iterations + "iterations of for loop.");
iterations = 0;
}
finally {
}
try {
filteredImage.free();
convexHullImage.free();
bigObjects.free();
thresholdImage.free();
image.free();
} catch (NIVisionException ni) {
}
return runAuto;
}
Last edited by wolfspell12 : 17-03-2014 at 19:15. |
|
#3
|
|||
|
|||
|
Re: Vision Processing
We did find one of our problems: "reports.length +1" should drop the adding one-it knocks the array out of bounds. Thanks to a programming mentor for pointing that out-we'll test it tomorrow to be sure.
There's still the issue of why particle 1 in the array is not being returned. I'm wondering if it passes under the minimum area of CriteriaCollection data, which is declared outside of the method, and happens to be set to 150. That's another thing to test tomorrow. If someone could give us some feedback on this, it would still be helpful. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|