# Distance Calculation Model

14 messages
Open this post in threaded view
|

## Distance Calculation Model

 Hi everyone, i'm kind of a newbye to openCV's, so be patient :) I have to calculate the distance from the camera of a known-size object without using stereoscopy (ie using only the frontal camera). I know that this is possible knowing the item size. I managed to collect some very accurate distance(x)-pixelsize(y) data points (using color blobs), and they seem to behave like an iperbolic function y = a/x + b. Can anyone confirm me that this is the real model for this kind of relation? I tried to fit them statistically and the correlation was not bad, but not exactly accurate..
Open this post in threaded view
|

## Re: Distance Calculation Model

 Hi, I guess that you are willing to retrieve the pose of the item in R^3 knowing the size of the object. Otherwise as someone who deals with 3D reconstruction in vision I have never heard about a method which evaluates depth based on item size. I can tell you that in a canocical stereo setup the disparity (distance between corresponding pixels is diversely related to the metric distance to the object in the scene. I hope this helps. Rami --- In [hidden email], "doctor_omega504" wrote: > > Hi everyone, i'm kind of a newbye to openCV's, so be patient :) > > I have to calculate the distance from the camera of a known-size object without using stereoscopy (ie using only the frontal camera). I know that this is possible knowing the item size. > > I managed to collect some very accurate distance(x)-pixelsize(y) data points (using color blobs), and they seem to behave like an iperbolic function y = a/x + b. > > Can anyone confirm me that this is the real model for this kind of relation? I tried to fit them statistically and the correlation was not bad, but not exactly accurate.. >
Open this post in threaded view
|

## Re: Distance Calculation Model

 In reply to this post by doctor_omega504 Hi, try starting at looking the maths of a pinhole camera http://en.wikipedia.org/wiki/Pinhole_camera_modelRegards doctor_omega504 wrote: > Hi everyone, i'm kind of a newbye to openCV's, so be patient :) > > I have to calculate the distance from the camera of a known-size object without using stereoscopy (ie using only the frontal camera). I know that this is possible knowing the item size. > > I managed to collect some very accurate distance(x)-pixelsize(y) data points (using color blobs), and they seem to behave like an iperbolic function y = a/x + b. > > Can anyone confirm me that this is the real model for this kind of relation? I tried to fit them statistically and the correlation was not bad, but not exactly accurate.. > > > > ------------------------------------ > > Change settings: http://www.yahoogroups.com/mygroups, select >    Get Emails (get all posts) >    Daily Digest (one summary email per day) >    Read on the web (read posts on the web only)Or Unsubscribe by mailing [hidden email] > Yahoo! Groups Links > > > > >
Open this post in threaded view
|

## Re: Distance Calculation Model

 In reply to this post by doctor_omega504 On Tue, 2010-12-21 at 13:23 +0000, doctor_omega504 wrote: > Hi everyone, i'm kind of a newbye to openCV's, so be patient :) > > I have to calculate the distance from the camera of a known-size object without using stereoscopy (ie using only the frontal camera). I know that this is possible knowing the item size. I've done this as a toy application, single camera distance measurement, I tried combining OpenCV (for acquisition and camera calibration) and ARToolKitPlus (for marker detection and pose estimation), but I didn't do any maths, just used what ARToolKitPlus already provides. I've used a fiducial marker, which when printed is exactly 8x8 cm, and the distance it gives me are +- correct (maybe 5% error). If there is any interest, I may share the code.
Open this post in threaded view
|

## calculation of distance of an object from camera using opencv

 i'm  new to opencv i have to do a project for robotics in which there is a need for distance measurement and direction detection of motion of a object so which function should i use to find it ..............pls suggest me how to do it
Open this post in threaded view
|

## Re: calculation of distance of an object from camera using opencv

 Hi, You cant just call a function and get the distance & direction of an object from a camera image because this is impossible to do without more information, for example if you saw a photo of a red square on a white background then you don't know if the square is 1 inch wide or 100 kilometers wide, because there is not enough information. You can use things like stereo cameras and depth cameras to help, or if you already know the exact size & shape of the object you are tracking then it can be used with a single camera, but it is not always easy. One method is with POSIT (that OpenCV has), but this might not be easy to use for robotics since it gives you a rotation & translation matrix. But another method is the one I used for my Masters Thesis, which you can find at "http://www.shervinemami.info/" or "http://www.shervinemami.co.cc/" Cheers, Shervin Emami. On Mon, Apr 11, 2011 at 12:10 AM, amit.benade <[hidden email]> wrote: > > > i'm new to opencv i have to do a project for robotics in which there is a > need for distance measurement and direction detection of motion of a object > so which function should i use to find it ..............pls suggest me how > to do it > >   >
Open this post in threaded view
|

## Re: calculation of distance of an object from camera using opencv

 Hi i dont thing about we want use the DPI information for object in the frame and map it on real object then we want use the sin formula calculate the distance in 2D ________________________________ From: Shervin Emami <[hidden email]> To: [hidden email] Cc: amit.benade <[hidden email]> Sent: Thu, April 14, 2011 7:39:39 AM Subject: Re: [OpenCV] calculation of distance of an object from camera using opencv     Hi, You cant just call a function and get the distance & direction of an object from a camera image because this is impossible to do without more information, for example if you saw a photo of a red square on a white background then you don't know if the square is 1 inch wide or 100 kilometers wide, because there is not enough information. You can use things like stereo cameras and depth cameras to help, or if you already know the exact size & shape of the object you are tracking then it can be used with a single camera, but it is not always easy. One method is with POSIT (that OpenCV has), but this might not be easy to use for robotics since it gives you a rotation & translation matrix. But another method is the one I used for my Masters Thesis, which you can find at "http://www.shervinemami.info/" or "http://www.shervinemami.co.cc/" Cheers, Shervin Emami. On Mon, Apr 11, 2011 at 12:10 AM, amit.benade <[hidden email]> wrote:   >i'm  new to opencv i have to do a project for robotics in which there is a need >for distance measurement and direction detection of motion of a object so which >function should i use to find it ..............pls suggest me how to do it > >
Open this post in threaded view
|

## Re: calculation of distance of an object from camera using opencv

 I belive that the easy way is: use : distancex = point2.x - point1.x; distancey = point2.y - point1.y; cvSqrt( (float)(distancex*distancex + distancey*distancey)); Before applying this formula you can use scale adjust to compensate the distance from the camera ... Eder de Souza On Thu, Apr 14, 2011 at 2:16 AM, Behzad Lotfi <[hidden email]>wrote: > > > Hi > i dont thing about > we want use the DPI information for object in the frame and map it on real > object then we want use the sin formula calculate the distance in 2D > > > ------------------------------ > *From:* Shervin Emami <[hidden email]> > *To:* [hidden email] > *Cc:* amit.benade <[hidden email]> > *Sent:* Thu, April 14, 2011 7:39:39 AM > *Subject:* Re: [OpenCV] calculation of distance of an object from camera > using opencv > > > > Hi, > > You cant just call a function and get the distance & direction of an object > from a camera image because this is impossible to do without more > information, for example if you saw a photo of a red square on a white > background then you don't know if the square is 1 inch wide or 100 > kilometers wide, because there is not enough information. You can use things > like stereo cameras and depth cameras to help, or if you already know the > exact size & shape of the object you are tracking then it can be used with a > single camera, but it is not always easy. One method is with POSIT (that > OpenCV has), but this might not be easy to use for robotics since it gives > you a rotation & translation matrix. But another method is the one I used > for my Masters Thesis, which you can find at " > http://www.shervinemami.info/" or "http://www.shervinemami.co.cc/" > > Cheers, > Shervin Emami. > > > On Mon, Apr 11, 2011 at 12:10 AM, amit.benade <[hidden email]>wrote: > >> >> >> i'm new to opencv i have to do a project for robotics in which there is a >> need for distance measurement and direction detection of motion of a object >> so which function should i use to find it ..............pls suggest me how >> to do it >> >> > > >   >
Open this post in threaded view
|

## Re: Distance Calculation Model

 In reply to this post by Michal Kottman yes please could you share the code .t thanks --- In [hidden email], Michal Kottman wrote: > > On Tue, 2010-12-21 at 13:23 +0000, doctor_omega504 wrote: > > Hi everyone, i'm kind of a newbye to openCV's, so be patient :) > > > > I have to calculate the distance from the camera of a known-size object without using stereoscopy (ie using only the frontal camera). I know that this is possible knowing the item size. > > I've done this as a toy application, single camera distance measurement, > I tried combining OpenCV (for acquisition and camera calibration) and > ARToolKitPlus (for marker detection and pose estimation), but I didn't > do any maths, just used what ARToolKitPlus already provides. > > I've used a fiducial marker, which when printed is exactly 8x8 cm, and > the distance it gives me are +- correct (maybe 5% error). > > If there is any interest, I may share the code. >
Open this post in threaded view
|

## Re: calculation of distance of an object from camera using opencv

 In reply to this post by Eder Souza Hi! I am working on a same project: Markerless tracking with a monocular camera for tracking objects. I use Planar textured object and SURF for detection. Then I calibrate th system computing the camera pose from a known distance from the target and using this ratio to correct the pose: computed distance/measured distance. Is it correct? Are there better solution? --- In [hidden email], Eder Souza wrote: > > I belive that the easy way is: > > > use : > > > distancex = point2.x - point1.x; > distancey = point2.y - point1.y; > cvSqrt( (float)(distancex*distancex + distancey*distancey)); > > > Before applying this formula you can use scale adjust to compensate the > distance from the camera ... > > Eder de Souza > > > > On Thu, Apr 14, 2011 at 2:16 AM, Behzad Lotfi wrote: > > > > > > > Hi > > i dont thing about > > we want use the DPI information for object in the frame and map it on real > > object then we want use the sin formula calculate the distance in 2D > > > > > > ------------------------------ > > *From:* Shervin Emami > > *To:* [hidden email] > > *Cc:* amit.benade > > *Sent:* Thu, April 14, 2011 7:39:39 AM > > *Subject:* Re: [OpenCV] calculation of distance of an object from camera > > using opencv > > > > > > > > Hi, > > > > You cant just call a function and get the distance & direction of an object > > from a camera image because this is impossible to do without more > > information, for example if you saw a photo of a red square on a white > > background then you don't know if the square is 1 inch wide or 100 > > kilometers wide, because there is not enough information. You can use things > > like stereo cameras and depth cameras to help, or if you already know the > > exact size & shape of the object you are tracking then it can be used with a > > single camera, but it is not always easy. One method is with POSIT (that > > OpenCV has), but this might not be easy to use for robotics since it gives > > you a rotation & translation matrix. But another method is the one I used > > for my Masters Thesis, which you can find at " > > http://www.shervinemami.info/" or "http://www.shervinemami.co.cc/" > > > > Cheers, > > Shervin Emami. > > > > > > On Mon, Apr 11, 2011 at 12:10 AM, amit.benade wrote: > > > >> > >> > >> i'm new to opencv i have to do a project for robotics in which there is a > >> need for distance measurement and direction detection of motion of a object > >> so which function should i use to find it ..............pls suggest me how > >> to do it > >> > >> > > > > > >   > > >
Open this post in threaded view
|

## Re: calculation of distance of an object from camera using opencv

 This post has NOT been accepted by the mailing list yet. In reply to this post by amit.benade i am working on this project so ,i want code of opencv to calculate the distance of the perticular obejct
Open this post in threaded view
|

## Re: Distance Calculation Model

 This post has NOT been accepted by the mailing list yet. This post was updated on . In reply to this post by doctor_omega504  How to find distance between two pixels in an image..help please...i m using opencv2.4.....c++