用于IplImage工作的cvLoadImage,但cv :: imread for cv :: Mat not workign [英] cvLoadImage for IplImage working, but cv::imread for cv::Mat not workign

查看:520
本文介绍了用于IplImage工作的cvLoadImage,但cv :: imread for cv :: Mat not workign的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临一个奇怪的问题,我无法使用 cv :: imread 从文件系统中读取基本图像文件。因此,下面的结果是imageInput有空数据,行和列设置为0.

I am facing a weird issue where I am unable to read a basic image file from the filesystem using cv::imread. Hence the below results into imageInput having null data, with rows and cols set to 0.

cv::Mat imageInput =  cv::Mat();
imageInput = cv::imread("abc.jpg",cv::IMREAD_COLOR);

有趣的是,在注释掉上面的代码后,下面的代码能够读取iamge:

Interestingly, after commenting out the above code, the below code is able to read the iamge:

//cv::Mat imageInput =  cv::Mat();
//imageInput = cv::imread("abc.jpg",cv::IMREAD_COLOR);
IplImage *rImg;
rImg = cvLoadImage("abc.jpg", CV_LOAD_IMAGE_COLOR);

rImg 的宽度为3296,如预期的那样高度为2256.

我无法知道这是怎么回事。请帮忙。
两种情况下的构建似乎都没问题。我尝试使用opencv-2.4.5和opencv-2.4.6

rImg gets a width of 3296, and height of 2256 as expected.
I am clueless how this is possible. Please help. The build seems to be fine in both cases. I tried using both opencv-2.4.5 and opencv-2.4.6

推荐答案

我现在能够找出问题所在。$
问题提到了发布构建静态库而不是调试构建静态库。

之前VC ++项目,我在调试模式中包含了以下lib依赖项: code> opencv_core245.lib; opencv_highgui245.lib; opencv_imgproc245.lib; opencv_video245.lib

I have been able to figure out the issue now.
The issue was mention of release build static libraries instead of debug-build static libraries.
Earlier for the VC++ project, I was including the following lib dependencies in debug mode : opencv_core245.lib;opencv_highgui245.lib;opencv_imgproc245.lib;opencv_video245.lib

将其更改为 opencv_core245d.lib; opencv_highgui245d.lib; opencv_imgproc245d.lib; opencv_video245d.lib ,我可以使用imread读取图片,没有任何问题。

Upon changing it to opencv_core245d.lib;opencv_highgui245d.lib;opencv_imgproc245d.lib;opencv_video245d.lib, I am able to read images using imread without any issues.

这篇关于用于IplImage工作的cvLoadImage,但cv :: imread for cv :: Mat not workign的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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