Distance Calculation Model

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Distance Calculation Model

doctor_omega504
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..

Reply | Threaded
Open this post in threaded view
|

Re: Distance Calculation Model

rami.bena-2
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" <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..
>


Reply | Threaded
Open this post in threaded view
|

Re: Distance Calculation Model

Estereo en Garra
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_model

Regards

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
>
>
>
>
>  

Reply | Threaded
Open this post in threaded view
|

Re: Distance Calculation Model

Michal Kottman
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.

Reply | Threaded
Open this post in threaded view
|

calculation of distance of an object from camera using opencv

amit.benade
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

Reply | Threaded
Open this post in threaded view
|

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

Shervin Emami
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
>
>  
>
Reply | Threaded
Open this post in threaded view
|

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

behzad.lotfi@ymail.com
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
>
>



 
Reply | Threaded
Open this post in threaded view
|

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

Eder Souza
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
>>
>>
>
>
>  
>
Reply | Threaded
Open this post in threaded view
|

Re: Distance Calculation Model

tina
In reply to this post by Michal Kottman
yes please could you share the code .t
thanks

--- In [hidden email], Michal Kottman <k0mpjut0r@...> 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.
>


Reply | Threaded
Open this post in threaded view
|

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

alelr7
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 <ederwander@...> 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 <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 <shervin.emami@...>
> > *To:* [hidden email]
> > *Cc:* amit.benade <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 <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
> >>
> >>
> >
> >
> >  
> >
>


Reply | Threaded
Open this post in threaded view
|

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

ajinkya bandurkar
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
Reply | Threaded
Open this post in threaded view
|

Re: Distance Calculation Model

Devaprakash
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++
Reply | Threaded
Open this post in threaded view
|

Re: Distance Calculation Model

kan2008tnptc
This post has NOT been accepted by the mailing list yet.
In reply to this post by Michal Kottman
hey can you pls share the code
Reply | Threaded
Open this post in threaded view
|

Re: Distance Calculation Model

BanudevaReddy
This post has NOT been accepted by the mailing list yet.
In reply to this post by Michal Kottman
Hi Michal,

How are you doing? I have seen once of your post distance calculation and much impressed to see the source code because i am also doing similar project. If possible, can you please share it to my mail-id banudevareddy.bandi@gmail.com.

Thanks & regards,
Banudeva Reddy. B