【问题标题】:Disparity Map in Emgu.CVEmgu.CV 中的视差图
【发布时间】:2017-08-19 07:05:51
【问题描述】:

我尝试使用 Emgu.CV 在 C# 中使用视差图计算

我从 article 读取图像作为 bitmapLeft 和 bitmapRight。作为参考,我使用了来自here的示例代码

这是我的源代码:

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();

但是,生成的位图是全黑的。

【问题讨论】:

    标签: c# opencv emgucv


    【解决方案1】:

    我认为你的问题到了最后。调用 StereoMatcherExtentions.Comput 的结果是一个具有 Cv16S 深度的 Mat/Image,我将其转换回 Cv8U 并能够显示它。这是我的例子。我使用了相同的两张图片。

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

    图片如下:

    这似乎与结果相匹配:Depth Map from Image

    道格

    【讨论】:

      猜你喜欢
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 2020-01-11
      • 2015-06-11
      • 2012-08-11
      • 1970-01-01
      • 2013-07-10
      • 2013-12-19
      相关资源
      最近更新 更多