【发布时间】:2020-03-30 12:25:53
【问题描述】:
我正在尝试使用 OpenCvSharp 从两个立体图像创建视差图像。
这是我目前的代码:
Mat left = new Mat(fileName1, ImreadModes.IgnoreOrientation);
Mat right = new Mat(fileName2, ImreadModes.IgnoreOrientation);
Mat output = new Mat();
right = right.Resize(left.Size());
MessageBox.Show($"Type left: {left.Type()}, type right: {right.Type()}");
StereoBM bm = StereoBM.Create(16, 15);
OutputArray outArr = OutputArray.Create(output);
bm.Compute((InputArray) left, (InputArray) right, outArr);
Cv2.ImShow("output", outArr.GetMat());
我正在显示带有垫子类型的消息框,因为我曾经收到此错误:
"两个输入图像都必须有 CV_8UC1"
我更改了 ImreadMode 直到它起作用,并且 IgnoreOrientation 出于某种原因起作用。
现在我收到此错误:
">不支持的输入图像深度:
'VDepth::contains(depth)'
在哪里
“深度”为 3 (CV_16S)
"
在最后一行。
那么会接受哪种深度?以及我如何相应地设置输出的深度?
(我有大约 4 小时的 OpenCv 经验,如果这个问题很简单,我很抱歉,我在 google 上没有找到任何相关信息)
【问题讨论】:
标签: c# opencv mat depth opencvsharp