Ask Your Question
0

Need A simple help in Calculation of Object Location

asked 2016-06-13 03:55:00 -0600

nexton001 gravatar image

Hi , I have found the contour of detected object and mean of it in Opencv + c++ . How can i proceed further to find the location / size of the object ? distance ? anything ????

Please Help Best Regards, Harsh

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-06-13 07:11:00 -0600

Missing gravatar image

Hey,

do you mean the location of the object in the image? You can simply calculate the bounding box of the contour and retrieve the coordinates of it.

For measuring the size of the object you can use a reference object of known size in the image. Put a quarter or something else on the image and calculate how many pixels represent the size of the quarter. With this information you can calculate the size of your object. There are plenty examples of that on the internet.

I'm also an OpenCV beginner, but I hope this will help you a little.

Best Regards Daniel

edit flag offensive delete link more

Comments

Thank you so much Daniel for the help and your time. I want to calculate the location of object in real world cordinates or if i can calculate the distance of the detected object from the camera ?

Size cannot be calculated without the ref object in image ?

Thanks, Harsh

nexton001 gravatar imagenexton001 ( 2016-06-15 02:02:17 -0600 )edit

Hi,

if you just have an image or a video you can't simply calculate object sizes or the distance from the camera. One solution is to use an object of a known size. Say for example you take a credit card (which size you know) and take a picure of it from 1 meter distance. Based on the pixel width of the credit card you now can calculate the distance to the camera in a new image. Same for the object size. If you have the credit cad in your image you can calculate the pixel width of it and use this information to calculate other object sizes based on this information.

Another option would be to use depth informaion of the world, for example with a depth camera or a stereo-setup of multiple cameras, but i also have no experience in that.

Best regards, Daniel

Missing gravatar imageMissing ( 2016-06-15 04:35:39 -0600 )edit

Thank you Daniel for that explanation. Is there any C++ code readily available for reference object approach in your knowledge ? Thanks you so much again.

Best Regards, Harsh

nexton001 gravatar imagenexton001 ( 2016-06-15 04:51:35 -0600 )edit

Since i work mainly with Python and OpenCV i don't know about any C++ tutorials or example code, but i am sure you will find something on the web about that.

I you want to read a bit more about that approach you should read this free tutorial from Adrian Rosebrock. It is written in Python, but you should be able to convert it into C++ pretty easily: http://www.pyimagesearch.com/2016/03/...

Best Regards, Daniel

Missing gravatar imageMissing ( 2016-06-15 08:34:31 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-06-13 03:55:00 -0600

Seen: 546 times

Last updated: Jun 13 '16