读取JPG文件在OpenCV中对C#位图 [英] Reading jpg file in OpenCV vs C# Bitmap

查看:609
本文介绍了读取JPG文件在OpenCV中对C#位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过多次实验,我发现阅读的颜色JPG文件中的C ++(OpenCV的):

After many experiments, I found that reading color jpg file in C++ (OpenCV):

自动温度(CV :: imread(XXX.JPG);

不同于使用C#位图读同一文件:

is different from reading the same file using C# bitmap :

变种临时=新位图(XXX.JPG);

的结果是不同势。还有值得注意的是,如果探源我申请了一些算法,它们都喜欢GoodFeatureToTrack。

the results are diffrent. There is notable diffrence if I applied some algorithm on them both like GoodFeatureToTrack.

现在的问题是:
如何能在adoapt OpenCV的C#位图加载方式。所以,我得到了相同的结果,如果我直接在本地部分或从C#包装装入我的形象。

The question is: How can adoapt the way of C# bitmap loading in the OpenCV. So, I got the same result if I load my image directly in the native part or from the C# Wrapper.

感谢

编辑:

这code是一个C ++函数,需要一些结构包含被加载到manged程序(C#),然后装入相同的图像在OpenCV中,并比较他们的图像..有一个不同的!

This code is a c++ function that take some struct that contain an image that was loaded in a manged program (c#) and then load the same image in opencv and compare them.. there is a different!

    extern "C" _declspec (dllexport) void test_diff(authenticator_reference_structure* referecnces){
    auto image(cv::imread("white.jpg"));

    cv::imshow("opencv", image);
    auto wrpped(referecnces->references->images->image.getMat());

    cv::imshow("C#", wrapped);
    cv::Mat ss;
    cv::absdiff(image, wrapped, ss);

    cv::threshold(ss, ss, 1, 255, CV_THRESH_BINARY);
    cv::imshow("Diff", ss);
    cv::waitKey();

}

设置阈值diffrences图像

推荐答案

也许你可以使用的getImage()而不是 getMat()

Maybe you can use getImage() instead of getMat()?

有一个类似的问题正在被(在C#不是C使用的OpenCV ++)这里讨论结果
http://www.emgu.com/forum/viewtopic.php?t=188

A similar question is being addressed here (using openCV in C# not C++)
http://www.emgu.com/forum/viewtopic.php?t=188

这篇关于读取JPG文件在OpenCV中对C#位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆