@@ -0,0 +1,3127 @@
+%0Apackage edu.wpi.first.wpilibj.templates.commands;%0A%0Aimport edu.wpi.first.wpilibj.camera.AxisCamera;%0Aimport edu.wpi.first.wpilibj.camera.AxisCameraException;%0Aimport edu.wpi.first.wpilibj.image.BinaryImage;%0Aimport edu.wpi.first.wpilibj.image.ColorImage;%0Aimport edu.wpi.first.wpilibj.image.CriteriaCollection;%0Aimport edu.wpi.first.wpilibj.image.NIVision.MeasurementType;%0Aimport edu.wpi.first.wpilibj.image.NIVisionException;%0Aimport edu.wpi.first.wpilibj.image.ParticleAnalysisReport;%0Aimport edu.wpi.first.wpilibj.Timer;%0A%0A/**%0A *%0A * @author Lauren Dierker%0A */%0Apublic class TestVision extends CommandBase %7B%0A    %0A    AxisCamera camera;%0A    CriteriaCollection cc;%0A    %0A%0A    public TestVision() %7B%0A        // Use requires() here to declare subsystem dependencies%0A        // eg. requires(chassis);%0A        requires( vision );%0A    %7D%0A%0A    // Called just before this Command runs the first time%0A    protected void initialize() %7B%0A        %0A        camera = AxisCamera.getInstance();%0A        %0A        //I don't thinnk we have to currently set any criteria%0A        //do we need to set resolution now? We will probably need to for image analysis %0A        %0A        //cc = new CriteriaCollection();%0A        //cc.addCriteria(MeasurementType.IMAQ_MT_BOUNDING_RECT_WIDTH, 20, 400, false);%0A        //cc.addCriteria(MeasurementType.IMAQ_MT_BOUNDING_RECT_HEIGHT, 15, 400, false);%0A        //camera.writeResolution(AxisCamera.ResolutionT.k320x240);%0A        %0A        try %7B%0A            ColorImage image = camera.getImage();%0A            %0A            //we will be using def value this year!%0A            //probably be using same stuff though%0A            %0A            BinaryImage greenThreshold = image.thresholdRGB(0, 187, 189, 255, 0, 225);%0A            //BinaryImage convexHullImage = greenThreshold.convexHull(false);%0A            //BinaryImage noSmallParticles = convexHullImage.removeSmallObjects(false, 5);%0A            //BinaryImage foundParticles = noSmallParticles.particleFilter(cc);%0A%0A            /* what to do with ParticleAnalysisReport:%0A             * want center of particles, number of particles%0A             * we'll just print it for now%0A             */%0A            ParticleAnalysisReport%5B%5D reports = greenThreshold.getOrderedParticleAnalysisReports();  // get list of results%0A            System.out.println( reports );%0A           %0A            %0A            //foundParticles.free();%0A            //noSmallParticles.free();%0A            //convexHullImage.free();%0A            //greenThreshold.free();%0A            //image.free();%0A%0A        %7D catch (AxisCameraException ex) %7B%0A        %7D catch (NIVisionException ex) %7B%0A        %7D%0A%0A         Timer.delay(0.5);%0A        %0A    %7D%0A%0A    // Called repeatedly when this Command is scheduled to run%0A    protected void execute() %7B%0A    %7D%0A%0A    // Make this return true when this Command no longer needs to run execute()%0A    protected boolean isFinished() %7B%0A        return false;%0A    %7D%0A%0A    // Called once after isFinished returns true%0A    protected void end() %7B%0A    %7D%0A%0A    // Called when another command which requires one or more of the same%0A    // subsystems is scheduled to run%0A    protected void interrupted() %7B%0A    %7D%0A%7D%0A

Test Vision code