0

I'm new to EmguCV, OpenCV and machine vision in general. I translated the code from this stack overflow question from C++ to C#. I also copied their sample image to help myself understand if the code is working as expected or not.

Mat map = CvInvoke.Imread("C:/Users/Cindy/Desktop/coffee_mug.png", Emgu.CV.CvEnum.LoadImageType.AnyColor | Emgu.CV.CvEnum.LoadImageType.AnyDepth);
CvInvoke.Imshow("window", map);
Image<Gray, Byte> imageGray = map.ToImage<Gray, Byte>();

double min = 0, max = 0; 
int[] minIndex = new int[5], maxIndex = new int[5];

CvInvoke.MinMaxIdx(imageGray, out min, out max, minIndex, maxIndex, null);
imageGray -= min;
Mat adjMap = new Mat();
CvInvoke.ConvertScaleAbs(imageGray, adjMap, 255/(max-min), 0);
CvInvoke.Imshow("Out", adjMap);

Original Image:

Original Image

After Processing:

After processing

This doesn't look like a depth map to me, it just looks like a slightly modified grayscale image, so I'm curious where I went wrong in my code. MinMaxIdx() doesn't work without converting the image to grayscale first, unlike the code I linked above. Ultimately, what I'd like to do is to be able to generate relative depth maps from a single webcamera.

Community
  • 1
  • 1
greentea
  • 347
  • 1
  • 2
  • 12
  • 3
    If you were able to create a depth-map from a single 2D image then some very big companies would like to give you a lot of money for solving a very difficult problem in computer vision. Sad fact is presently you'll need more information (e.g. a time-of-flight camera, a Kinect sensor, stereoscopy, etc) to perform scene-reconstruction with depth information. – Dai Aug 03 '15 at 18:39
  • @Dai: You're right, and I know it's not possible to create absolute depth maps from a single 2D image. I read yesterday it's possible to create a relative depth map though, and I'm still researching that to see what's been done so far. – greentea Aug 03 '15 at 19:16
  • I think you're missing the most important info in that post: _I am using a dataset in which it has images where each pixel is a 16 bit unsigned int storing the depth value of that pixel in mm._. The image used has already depth info, the post is only about presentation – Miki Aug 03 '15 at 20:20
  • @Miki: I was afraid that was the case. Thanks for clarifying, I'm dumb and missed that part. – greentea Aug 04 '15 at 20:24

0 Answers0