Ask Your Question
0

Is't possible to find depth of a 2D image with opencv...?

asked 2013-02-26 22:34:08 -0600

Dhanraj gravatar image

Hi friends,

I'm new to opencv.

---->I was stuck while tracking object from a 2D images. ---->Is't possible to find depth of a 2D image(images taken from camara *.jpg file) with opencv or not .....?

  Can you post the code.
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
5

answered 2013-02-27 02:46:28 -0600

Ben gravatar image

The short answer: no.

A 2D image contains - hence the name - only 2-dimensional information. You can't get 3-dimensional (depth) information from that.

Unless... you have additional information.

  • If, for example you know there is a face in the image, you roughly know what a face looks like in 3d, so you can extract 3-dimensional information by analysing shadows, head pose etc...

  • Another way to get an object's 3d model from a 2d image is to project some known structure (e.g. a grid) onto the object and to use the grid's deformation to compute the surface.

  • in case of a video you can use successive images to detect corresponding points and compute 3-dimensional information from that.

edit flag offensive delete link more

Comments

oh, ofc. i took it as 'color depth'

berak gravatar imageberak ( 2013-02-27 03:19:28 -0600 )edit

Since you are tracking objects, you should have succesive frames containing 2D information. Best way to go then is to apply the stereo principle and create a 3D point cloud based on the two successive images like Ben suggested.

Use some feature descriptor like SIFT or SURF combined with RANSAC to find corresponding featuere points in both images. Then use this information to recreate the actual 3D point cloud, giving you information of the depth.

It's actually the same principle as the human perception, using left and right eye image.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-02-27 04:44:42 -0600 )edit
0

answered 2013-02-27 01:45:27 -0600

berak gravatar image
Mat img = imread("my.jpeg");
cout << img.rows << " " << img.cols << " " << img.channels() << " " << img.type() << endl;

so, img.channels() holds the depth, img.type() the type of one channel(uchar, int, float, etc)

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-02-26 22:34:08 -0600

Seen: 5,210 times

Last updated: Feb 27 '13