Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Camera Tracking not working? (http://www.chiefdelphi.com/forums/showthread.php?t=72921)

NinJA999 25-01-2009 15:28

Camera Tracking not working?
 
Hi,

We've been working on getting our camera to work for tracking the colored fabrics. We have tried code from several different threads, the manual, and the two color tracking demo. Our current Autonomous code is this:
Code:

void Autonomous(void)
        {
                Dashboard &dashboard = m_ds->GetDashboardPacker();

                Wait(2.0);
                PCVideoServer pc;
                while(IsAutonomous())
                {
                        TrackingThreshold tdata;
                        tdata.hue.minValue=220;//229
                        tdata.hue.maxValue=255;
                        tdata.saturation.minValue=75;//121
                        tdata.saturation.maxValue=255;//182
                        tdata.luminance.minValue=85;//95
                        tdata.luminance.maxValue=255;//141
                        ParticleAnalysisReport par;
                       
                        if(FindColor(IMAQ_HSL, &tdata.hue, &tdata.saturation, &tdata.luminance, &par))
                        {
                                dashboard.Printf("color found at x=%i, y=%i\n", par.center_mass_x_normalized, par.center_mass_y_normalized);
                                dashboard.Printf("color as percent of image: %f\n", par.particleToImagePercent);
                        }
                        else
                        {
                                dashboard.Printf("No color found :(\n");
                        }
                        UpdateDashboard();
                }
        }

Currently, we are attempting to find pink. Do you think it is a problem with our values for HSL, or is it our code itself?

[EDIT]
We figured it out. Apparently, we had two problems in our code:
1. The code was running too fast for the image processor. We added a Wait(1.0/60); to the end of the loop, so it runs at a max rate of 60 executions per second (twice our fps). That allowed us to see that we were finding the color, but it always said it was x=0, y=0. That's when we found out that...
2. There was an error in the C/C++ Programming Guide that we took some of our code from. par.center_mass_x_normalized and par.center_mass_x_normalized are doubles. "%d" is for integers. We changed the printf to say "%f" and it works perfectly.
[/EDIT]


All times are GMT -5. The time now is 02:42.

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