View Single Post
  #1   Spotlight this post!  
Unread 03-02-2013, 13:49
Gmercer Gmercer is offline
Registered User
None #1631
 
Join Date: Jan 2013
Location: Las Vegas
Posts: 15
Gmercer is an unknown quantity at this point
How to view a binary image

I'm working on refining my auto aim code and noticed a couple bugs when the robot is looking from a certain angle. Is there a way i can save the binary image to the robot in a format maybe MS paint could open so i could view the image and check to make sure my code it right? Here is what i have for my camera function:

Code:
public void cameraCapture() throws AxisCameraException, NIVisionException {
        if (joy2.getRawButton(3)) {
            //Color Image will be our MAIN image, Binary image will be the manipulated data
            ColorImage initImg;
            BinaryImage dataImg;
            //array of particles to pass into aim function, plus the target count of particles
            ParticleAnalysisReport[] particle;
            int trgCnt;
            SmartDashboard.putString("Taken Picture", "Picture begun...");
            //if camera is 'fresh'
            if (camera.freshImage()) {
                //grab an image, set binaryImg to it and start manipulating the image
                initImg = camera.getImage();
                dataImg = initImg.thresholdRGB(0, 144, 153, 243, 34, 167);   //set threshold to bright colors(UNFINISHED)
                dataImg = dataImg.removeSmallObjects(false, 1);     //remove small pixles from image
                dataImg = dataImg.convexHull(false);                //fill in rectangles selected
                dataImg = dataImg.particleFilter(critCollection);   //filter rectangles
                trgCnt = dataImg.getNumberParticles();
                //if there are any particles, aim at them
                if (trgCnt > 0) {
                    //assign particle array of values
                    particle = dataImg.getOrderedParticleAnalysisReports();
                    SmartDashboard.putString("Taken Picture", "binary mapping finished....calling Aim");
                    Aim(particle);
                } else {
                    SmartDashboard.putString("Taken Picture", "No particles to manipulate, picture was not taken?");
                }
                //free images used
                dataImg.free();
                initImg.free();
            }
        }
    }
Criteria collection params:
Code:
critCollection.addCriteria(MeasurementType.IMAQ_MT_BOUNDING_RECT_WIDTH, 30, 400, false);
        critCollection.addCriteria(MeasurementType.IMAQ_MT_BOUNDING_RECT_HEIGHT, 20, 400, false);
Reply With Quote