Go to Post Note: Please don't actually mob them or cause them any harm. It's just a saying people. :) - CalTran [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #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
  #2   Spotlight this post!  
Unread 03-02-2013, 16:53
joelg236 joelg236 is offline
4334 Retired Mentor & Alumni
AKA: Joel Gallant
no team
Team Role: Mentor
 
Join Date: Dec 2011
Rookie Year: 2012
Location: Calgary
Posts: 733
joelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond repute
Re: How to view a binary image

Just as a guess, you could use ObjectMemorySerializer.save() to save a serialized image to the CRIO's memory, then FTP to get it and find a way to convert it from a desktop setting. I'm sure you aren't talking about converting it onboard the computer right? You wouldn't be opening ms paint during competition. As to how to convert it, you could use a java library that allows you to construct jpeg/bmp/png/gif/etc using pure data and use the wpilibj.jar to access the serialized object you saved. Probably a complex answer, but I've never done it so I don't know a better way.
__________________
All opinions are my own.
Reply With Quote
  #3   Spotlight this post!  
Unread 03-02-2013, 18:54
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: How to view a binary image

It's way easier than what Joel suggested. Just call ImageName.write(/ImageName.bmp) then FTP to the cRIO (no client needed, jut type FTP://10.XX.YY.2 in Windows Explorer) to get the image. Replace ImageName with the name of your image and you should be good to go. Note that .jpeg does not appear to work with binary images, but .bmp does.
Reply With Quote
  #4   Spotlight this post!  
Unread 03-02-2013, 23:20
joelg236 joelg236 is offline
4334 Retired Mentor & Alumni
AKA: Joel Gallant
no team
Team Role: Mentor
 
Join Date: Dec 2011
Rookie Year: 2012
Location: Calgary
Posts: 733
joelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond repute
Re: How to view a binary image

Quote:
Originally Posted by RufflesRidge View Post
It's way easier than what Joel suggested. Just call ImageName.write(/ImageName.bmp) then FTP to the cRIO (no client needed, jut type FTP://10.XX.YY.2 in Windows Explorer) to get the image. Replace ImageName with the name of your image and you should be good to go. Note that .jpeg does not appear to work with binary images, but .bmp does.
Go with this. I've never touched image manipulation stuff in the wpilibj/squawk libraires so I didn't know where to look.
__________________
All opinions are my own.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:04.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi