Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Two Color Tracking Demo (http://www.chiefdelphi.com/forums/showthread.php?t=72066)

PhilBot 20-01-2009 19:48

Re: Two Color Tracking Demo
 
Also.... Don't forget to ADD the Servo power jumpers next to the two servos plugs you are using on the Digital Sidecar.

btgdaniel 20-01-2009 20:13

Re: Two Color Tracking Demo
 
Quote:

Originally Posted by laultima (Post 803931)
Heres the code we're using for target tracking, using the color values from the TwoColorTrackDemo. All variables are doubles declared before the While loop, and pan and tilt are servos.

Code:

if (FindColor(IMAQ_HSL, &redData.hue, &redData.saturation,
                                        &redData.luminance, &aRed) && FindColor(IMAQ_HSL,
                                        &greenData.hue, &greenData.saturation,
                                        &greenData.luminance, &aGreen)) {
                                redX = aRed.center_mass_x_normalized;
                                redY = aRed.center_mass_y_normalized;
                                greenX = aGreen.center_mass_x_normalized;
                                greenY = aGreen.center_mass_y_normalized;
                                centerX = (redX + greenX)/2;
                                centerY = (redY + greenY)/2;
                                panMove = (tan((PI/4)*centerX))/8;
                                tiltMove= (tan((PI/4)*centerY))/8;
                                pan->Set(pan->Get()+panMove);
                                tilt->Set(tilt->Get()-tiltMove);
                        }


Much appreciated, although in all honesty I have an admission to make: If all else fails, read the directions. "This demo assumes that the camera is set up as follows: White balance: Fluorescent 1, Auto Exposure on, Brightness: 40". Ouch. ==> Now it works as advertised. :)

rcoren22 20-01-2009 20:24

Re: Two Color Tracking Demo
 
Thank you PhilBot....the jumper cable was the problem. (As for now...)

kyungjin 20-01-2009 23:57

Re: Two Color Tracking Demo
 
To the people that have this working in WindRiver...

We've been having some problems trying to get this as a workable project. How do you set this up to work? Do you just drag the extracted folder into the workspace?

I've tried creating a New project from a workspace in an external location and linking it but I seem to get problems with finding "AxisCamera.h". When that's removed or moved somewhere else, the next header file in the #include statements seem to suffer the same problem...

Can anyone give step-by-step instructions for getting this to work? Any help would be much appreciated.

Obscuriti 21-01-2009 22:37

Re: Two Color Tracking Demo
 
Hey all,

We have the camera tracking both tilt and pan, and we re-engineered it to be functional in our Robot Main vi, what I would like to do is convert the % Area output to a distance measurement. Has anyone successfully done this or have any ideas on how...

Thanks Much,

RyanW 22-01-2009 00:31

Re: Two Color Tracking Demo
 
Quote:

Originally Posted by Obscuriti (Post 805642)
what I would like to do is convert the % Area output to a distance measurement. Has anyone successfully done this or have any ideas on how...

I would suggest simply creating a look-up table of a few values (get the %area output at 1 foot, 2 feet, 3 feet, or something like that). Depending on the resolution you want (to the nearest foot? 6 inches? inch?), you could either just find the closest table value to what you are seeing, or else try to create a distance formula based on your data points.

Alternatively, since you know exactly how high off the ground the targets will be, and you presumably know the position of the camera on your robot, you could try measuring the tilt angle and using trigonometry to find the distance as follows:
tan(tilt) = height of target above camera / horizontal distance from camera to object, where tilt is the angle above or below the horizontal plane. This would require finding another kind of data, namely the relationship between servo outputs and degree or radian values.

Obscuriti 22-01-2009 01:29

Re: Two Color Tracking Demo
 
thanks for the quick response,

Ive been working on a distance formula and I must be a bit rusty on this seemingly simple math.

I sampled a number of data points and fitted a line to it that should be close enough for any practical purposes

I measured feet vs % Area and when graphed and fitted with the line the equation was roughly: y being pixels and x being feet y=80,000x^-2.0, assuming that with a resolution of 320x240 there are 76,800 pixels and the percent area is the amount of pixels that the mask is tracking as the object.


I get 2 equations as follows... they work independently but not when set equal to each other.
pixels=76800(.01(%Area))
pixels=80,000(feet^-2.0)

so 76800(.01(%Area))=80,000(feet^-2.0) right?
simplifying to feet^-2=.0096(% Area)

when solved for x I end up with a messy

feet=e^((ln(.0096(% Area)))/-2))

??? idk maybe it does work, id still like a check and some input pls.

Thanks Again

dani190 22-01-2009 22:45

Re: Two Color Tracking Demo
 
well in physics we have this range forumla that splits basically a 3rd year university problem into 2 parts that a grade 12 physics student can do. It essentially is using orthogonal components...
Maybe that would also work?

also guys if i take the code and transplant it into my existing robot code... What is required to be modified so that the camera will start tracking while its driving?

LinuxMercedes 22-01-2009 23:36

Re: Two Color Tracking Demo
 
Ok...I feel really dumb. Especially after reading how you all have the code working...

I can't get it to compile. I've reinstalled all the WindRiver updates, but when I compile WPI's sample code, I get 100+ errors in nivision.h. Do I have to grab the latest WPILib source code and compile that to make this work, or am I missing something uber-obvious?

Thanks so much =]

warpling 23-01-2009 21:15

Re: Two Color Tracking Demo
 
@Obscurity
That is exactly what I have been trying to do for the past 3 hours. I'm a rookie programmer and labview has a nice steep learning curve. I have our test robot's camera gimble tracking a board with the colors, but I cant figure out how to get outputs and change them into something that can drive our two jaguar motors.
Also that trig idea is amazing I can't wait to try that out if things get working! :yikes:

XXShadowXX 23-01-2009 21:50

Re: Two Color Tracking Demo
 
We had an issue with the lab view 2 color tracking demo from usfirst.org giving us the incorrect servo values in the y axis. When the target would move vertically the tracking would move in the opposite direction...

if this happens to anyone else here the solution
|170-Y|= out put
use that forumal, you really don't need the absolute value, but that should fix the problem

Mikesername 23-01-2009 22:13

Re: Two Color Tracking Demo
 
Quote:

Originally Posted by warpling (Post 806853)
@Obscurity
That is exactly what I have been trying to do for the past 3 hours. I'm a rookie programmer and labview has a nice steep learning curve. I have our test robot's camera gimble tracking a board with the colors, but I cant figure out how to get outputs and change them into something that can drive our two jaguar motors.
Also that trig idea is amazing I can't wait to try that out if things get working! :yikes:

Yea, we were trying to do that and one of our mentors said that it's pretty complicated.. and a little over the heads of a rookie team.

:\

XXShadowXX 23-01-2009 22:23

Re: Two Color Tracking Demo
 
Quote:

thanks for the quick response,

Ive been working on a distance formula and I must be a bit rusty on this seemingly simple math.

I sampled a number of data points and fitted a line to it that should be close enough for any practical purposes

I measured feet vs % Area and when graphed and fitted with the line the equation was roughly: y being pixels and x being feet y=80,000x^-2.0, assuming that with a resolution of 320x240 there are 76,800 pixels and the percent area is the amount of pixels that the mask is tracking as the object.


I get 2 equations as follows... they work independently but not when set equal to each other.
pixels=76800(.01(%Area))
pixels=80,000(feet^-2.0)

so 76800(.01(%Area))=80,000(feet^-2.0) right?
simplifying to feet^-2=.0096(% Area)

when solved for x I end up with a messy

feet=e^((ln(.0096(% Area)))/-2))

??? idk maybe it does work, id still like a check and some input pls.

Thanks Again
(height of divide in trailer - height of camera) *COT (input angle) = distance

or (72-Camera height) cot (y) = distance in a horizontal line from you to trailer.

Our distance is accurate to about an inch currently using pretty inaccurate numbers for camera height and trailer divide height since the trailer isn't mounted onto the robot, it kind of leans on the hitch on the ground...

y is what the angle of vertical servo is called in the tracking program released by FIRST

ikhana870 25-01-2009 18:58

Re: Two Color Tracking Demo
 
Quote:

Originally Posted by RKElectricalman (Post 802479)
Can anyone explain to me how to open up the project in Wind River?

Also, when I was working with Labview, I couldn't get it to track. I figured out how to power the servos with the jumpers included, but I couldn't get the camera to actually autonomously move and track the colors, even though it did see it in the VI. Has any one had any issues similar to this?

Quote:

Originally Posted by kyungjin (Post 804959)
To the people that have this working in WindRiver...

We've been having some problems trying to get this as a workable project. How do you set this up to work? Do you just drag the extracted folder into the workspace?

I've tried creating a New project from a workspace in an external location and linking it but I seem to get problems with finding "AxisCamera.h". When that's removed or moved somewhere else, the next header file in the #include statements seem to suffer the same problem...

Can anyone give step-by-step instructions for getting this to work? Any help would be much appreciated.

our team is also having some issues with this...anyone get it working yet?


All times are GMT -5. The time now is 18:32.

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