Go to Post IMHO, [the driver's] job is to drive the robot. The coaches job is to monitor everything in a match that isn't your robot. - 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 16-03-2014, 23:41
cogbrained3244 cogbrained3244 is offline
Registered User
FRC #3244
 
Join Date: Nov 2012
Location: St.Cloud MN
Posts: 5
cogbrained3244 is an unknown quantity at this point
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?
Reply With Quote
  #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
  #3   Spotlight this post!  
Unread 21-03-2014, 00:03
cogbrained3244 cogbrained3244 is offline
Registered User
FRC #3244
 
Join Date: Nov 2012
Location: St.Cloud MN
Posts: 5
cogbrained3244 is an unknown quantity at this point
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.
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 09:10.

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