Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Robotics Algorithm Anyone?
Message
From
09/01/2006 09:28:07
 
 
To
08/01/2006 20:54:37
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01082862
Message ID:
01084680
Views:
35
Hi Dragan,

Hmm, something is not quite right. Can you see where I am going wrong? If I understand polar coordinates correctly, the Origin is the camera len, the Pole is the obstacle, and radius is the distance between the Origin and the Pole, and Theta is the angle joining the semi-infinate line L and the line joining the Origin to the Pole. (L is the x-axis line (left-right of the len).

Here is my code below. The X and Y values don't look right at all! Should Y not be similar to the radius? and should X not be something like 1 cm?
//
// C# code
//
// The input data I am using has been obtained from the following picture
// http://www.simoncragg.com/images/capture3.bmp.  Bascially the pole is a CD case 
// (only using horizontal widths and angles). The pole is 14 cms in actual width, 
// with a pixel width of 123px.  The pole is positioned approxiately 91cms from the 
// camera's len.  The distance in pixels between the center of the image and the center
// of the pole is 27 pixels.


const double MAX_HORZI_ANGLE = 45;
const int MAX_HORIZ_PXS= 640;
const double ACTUAL_POLE_WIDTH = 14;
const double DEGREES_PER_PX = (Math.PI * 180) * (MAX_HORIZ_ANGLE / MAX_HORIZ_PXS);

int polePxWidth = 123 // width of the pole in pixels
double pxOffset = 27; // distance from center of pole and center of image (pixels)

// Calculate the radius
double angle = MAX_HORIZ_ANGLE / 180 * Math.PI * polePixelWidth / MAX_HORIZ_PXS;
double radius = ACTUAL_POLE_WIDTH / Math.Tan(angle);

// Calculate the R-Theta using the pixelOffset and distance.
double theta = pixelOffset * DEGREES_PER_PX;
double x = radius * Math.Cos(theta);
double y = radius * Math.Sin(theta);
results
-------
angle = 0.44914957469291572
radius = 29.04524359178107
x = 18.426107471523718
y = -22.452276916913288
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform