View Single Post
  #2   Spotlight this post!  
Unread 17-03-2014, 19:13
wolfspell12 wolfspell12 is offline
Registered User
FRC #3244
 
Join Date: Jan 2014
Location: Minnesota
Posts: 16
wolfspell12 is an unknown quantity at this point
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;

    }
To be clear, we've tried tweaking the values for the threshold from what 3313 had. We are currently dealing with particle areas, and our goal with the commented part is to count how many particles meet a minimum area, and if there are more than two, return a value to start the autonomous. But until we can get consistency, then we don't want to do that.

Last edited by wolfspell12 : 17-03-2014 at 19:15.
Reply With Quote