Go to Post There are 10 types of people in the world: those that understand binary and those that do not. - Stephen P [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 25-01-2011, 20:17
jimmyqwerty jimmyqwerty is offline
Registered User
FRC #0068
 
Join Date: May 2010
Location: Michigan
Posts: 10
jimmyqwerty is an unknown quantity at this point
Camera Code

So I worked out some camera code and it is able to tell me the coordinates of the target when it is present, but when the target isn't present it is supposed to display on the dashboard that their is no target. This does not happen because once it finds the target it will say found target and that field never gets reset on the driverstation. so my question is how can you get the dashboard to say no target present.

Here is my sample code.


Code:
public void Camera()
    {
            cam.freshImage();
         try
            {
              ColorImage image = cam.getImage();
              try
              {
                BinaryImage firstColor = image.thresholdRGB(
                120, 160, 170, 210, 240, 260);
                ParticleAnalysisReport[] firstColorHits = firstColor.getOrderedParticleAnalysisReports(3);
                firstColor.free();

                for (int i = 0; i < firstColorHits.length; i++)
                {
                   ParticleAnalysisReport firstTrackReport = firstColorHits[i];
                   if (firstTrackReport.particleToImagePercent < FRC_PARTICLE_TO_IMAGE_PERCENT)
                   {
                       
                       imagepres = false;
                      
                      
                   }
                   else if(firstTrackReport.particleToImagePercent > FRC_PARTICLE_TO_IMAGE_PERCENT)
                   {
                       imagepres = true;
                       foundhorcenter = firstTrackReport.center_mass_x;
                       foundvertcenter = firstTrackReport.center_mass_y; 
                   }
                   if (imagepres == true)
                   {

                       display.println(DriverStationLCD.Line.kUser2, 1, "X coordinate " + Integer.toString(foundhorcenter));
                       display.println(DriverStationLCD.Line.kUser3, 1, "Y coordinate: " + Integer.toString(foundvertcenter));
                       display.println(DriverStationLCD.Line.kUser4, 1, "Target found");
                       display.updateLCD();
                    }
               else 
               {
                   display.updateLCD();
                   display.println(DriverStationLCD.Line.kUser2, 1, "X coordinate na");
                   display.println(DriverStationLCD.Line.kUser3, 1, "Y coordinate: na");
                   display.println(DriverStationLCD.Line.kUser4, 1, "no image");

               }
                }
              }
              catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (image != null) {
                    image.free();
                }
                image = null;
            }
            }
            catch (AxisCameraException e)
            {
            }
            catch (NIVisionException e)
            {
            }
        }
Thanks for your help
Reply With Quote
 


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 08:32.

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