c# - CvInvoke.Canny() - 在不同的计算机上给出不同的结果

标签 c# opencv image-processing emgucv canny-operator

当尝试对完全相同的图像文件执行一些二进制操作时,但在不同的计算机(和监视器)上,使用 CvInvoke.Canny() 方法时我会得到不同的结果。
在调用此方法之前,我使用了几种操作方法,例如:CvInvoke.Threshold()CvInvoke.Erode()CvInvoke.Dilate() 还有更多... 所有这些的结果总是相等的。
就在我打电话的时候:

UMat inputImageUMAT = new Image<Gray, byte>(inputImageBitmap).ToUMat();
UMat imageUmat = new UMat();
CvInvoke.Threshold(imageInputUMAT, imageUmat, threshold, 255, 
Emgu.CV.CvEnum.ThresholdType.Binary);

// clear noises with Erode & Dilate:
CvInvoke.Erode(imageUmat, imageUmat, null, new Point(-1, -1), 1, 
BorderType.Constant, CvInvoke.MorphologyDefaultBorderValue);
CvInvoke.Dilate(imageUmat, imageUmat, null, new Point(-1, -1), 1, 
BorderType.Constant, CvInvoke.MorphologyDefaultBorderValue);

//use image pyr to remove noise:
UMat pyrDown = new UMat();
CvInvoke.PyrDown(imageUmat, pyrDown);
CvInvoke.PyrUp(pyrDown, imageUmat);

 // set cannyEdges to hold the outlines of the shapes detected in the image 
(according to threshold) 
UMat cannyEdges = new UMat();
CvInvoke.Canny(imageUmat, cannyEdges, threshold, threshold);

不同的电脑输出总是有差异的。
尽管如此,每台计算机总是给出完全相同的结果 - 一次又一次。

可能是什么导致了这个问题?
我必须在任何地方都有完全相同的结果......

附注
我使用 C# block :EMGU.CV v3.3.0.2824

编辑:
我拿了原始文件:original
并跳过所有操作并立即执行 Canny:

UMat inputImageUMAT = new UMat(fileName, ImreadModes.Grayscale);
UMat cannyEdges = new UMat();
CvInvoke.Canny(imageInputUMAT, cannyEdges, threshold, threshold, 3, true);
cannyEdges.Save(outputFileName);

阈值 210 机器 1 的结果:result_1
阈值 210 机器 2 的结果:result_2
-- 2个结果之间有1个像素的差异

最佳答案

我已经写信给 EMGU 的支持,这是他们惊人的答复:

I reviewed your code and it is using UMat. That means that the code will using OpenCL (GPU) to speed up the processing when it is available and fall back to CPU for workstation where there is no compatible OpenCL driver / device.
My suspicion is that the result produced by the OpenCL path is slightly different from the CPU path. Can you the following line before calling any of the Emgu CV function in your code and check if that make the result consistent across the machines:

CvInvoke.UseOpenCL = false

The above code will disable OpenCL and force all the code to run on CPU

毫不奇怪 - 他们是对的。 它确实解决了问题

关于c# - CvInvoke.Canny() - 在不同的计算机上给出不同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48569518/

相关文章:

c# - 获取 Silverlight 5 部署路径(在浏览器中以完全信任模式运行时)

c# - 如何访问 LINQ 查询结果中的特定数据?

c# - ASP.NET 和 Facebook Connect - 如何使用 Graph API 发布到用户的墙上?

c++ - opencv中的Vec4i是什么

opencv - opencv中网络摄像头的使用

ios - 如何转换从 VNFaceLandmarkRegion2D 检索到的归一化点

c++ - 使用 C++ 获取 vector<cv::Vec3b> 中出现次数最多的值

c# - 从 watch 或即时窗口打破无限循环

c++ - OpenCV VideoCapture 支持的最大分辨率

c# - 获取图像中每种颜色的使用百分比