[英]Disparity Map in Emgu.CV
I try to use disparity map calculation in C# using Emgu.CV 我尝试使用Emgu.CV在C#中使用视差图计算
I read the images from this article as bitmapLeft and bitmapRight. 我从这篇文章中读取图像为bitmapLeft和bitmapRight。 For reference I used the example code from here
作为参考,我使用了此处的示例代码
Here is my source code: 这是我的源代码:
bitmapLeft = (Bitmap) mainForm.pictureBoxLeft.Image;
bitmapRight = (Bitmap)mainForm.pictureBoxRight.Image;
Image<Gray, Byte> imageLeft = new Image<Gray, Byte>(bitmapLeft);
Image<Gray, Byte> imageRight = new Image<Gray, Byte>(bitmapRight);
Image<Gray, Byte> imageDisparity = new Image<Gray, Byte>(bitmapLeft.Width, bitmapLeft.Height);
StereoBM stereoBM = new StereoBM(16, 15);
StereoMatcherExtensions.Compute(stereoBM, imageLeft, imageRight, imageDisparity);
Image bitmapDisparity = imageDisparity.ToBitmap();
However, the resulting bitmap is all black. 但是,生成的位图全为黑色。
I think your problem is at the end. 我认为您的问题已经解决了。 The result of calling StereoMatcherExtentions.Comput is a Mat/Image that has a depth of Cv16S, I converted that back to Cv8U and was able to display it.
调用StereoMatcherExtentions.Comput的结果是Mat / Image,其深度为Cv16S,我将其转换回Cv8U并能够显示出来。 Here is my example.
这是我的例子。 I used the same two images.
我使用了相同的两个图像。
Mat leftImage = new Mat(@"C:\Users\jones_d\Desktop\Disparity\LeftImage.png", ImreadModes.Grayscale);
Mat rightImage = new Mat(@"C:\Users\jones_d\Desktop\Disparity\\RightImage.png", ImreadModes.Grayscale);
CvInvoke.Imshow("Left", leftImage);
CvInvoke.Imshow("Right", rightImage);
Mat imageDisparity = new Mat();
StereoBM stereoBM = new StereoBM(16, 15);
StereoMatcherExtensions.Compute(stereoBM, leftImage, rightImage, imageDisparity);
Mat show = new Mat();
imageDisparity.ConvertTo(show, DepthType.Cv8U);
CvInvoke.Imshow("Disparity", show);
CvInvoke.WaitKey(0);
Here are the images: 这是图像:
Which seems to match the result at: Depth Map from Image 似乎与以下结果匹配: 来自图像的深度贴图
Doug 道格
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.