使用imshow的OpenCV 2.0 C ++ API:返回未处理的异常和“错误标志". [英] OpenCV 2.0 C++ API using imshow: returns unhandled exception and "bad-flag"

查看:453
本文介绍了使用imshow的OpenCV 2.0 C ++ API:返回未处理的异常和“错误标志".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在MS Visual C ++ 2008中使用新的OpenCV 2.0 API,并编写了以下简单程序:

I'm trying to use the new OpenCV 2.0 API in MS Visual C++ 2008 and wrote this simple program:

cv::Mat img1 = cv::imread("image.jpg",1);
cv::namedWindow("My Window", CV_WINDOW_AUTOSIZE);
cv::imshow("My Window", img1);

Visual Studio返回未处理的异常,控制台返回:

Visual Studio returnes an unhandled exception and the Console returns:

OpenCV Error: bad flag (parameter or structure field) 
(Unrecognized or unsupported array type) in unknown function, 
file ..\..\..\..\ocv\opencv\src\cxcore\cxarray.cpp, line 2376

不显示图像.此外,我的窗口"窗口有一个奇怪的标题:ÌÌÌÌ我的窗口",它与名称无关.

The image is not displayed. Furthermore the window "My Window" has a strange caption: "ÌÌÌÌMy Window", which is not dependent on the name.

使用诸如cvLoadImage,cvNamedWindow或cvShowImage之类的命令的旧" C API可以对同一图像文件毫无问题地工作.我尝试了很多不同的东西,但都没有成功.

The "old" C API using commands like cvLoadImage, cvNamedWindow or cvShowImage works without any problem for the same image file. I tried a lot of different stuff without success.

在此感谢您的帮助.

康拉德

推荐答案

此问题有帮助.

解决方案是,链接器中通常建议的opencv库文件无法正常工作.而是尝试通过以下方式使用调试库文件:

The solution is, that the usual proposed opencv library files in the linker are not working properly. Instead try to use the debug library files by this:

在Visual C ++中:

In Visual C++:

转到项目"->属性"(或Alt-F7) 配置属性->链接器->输入->其他依赖项

go to Project->Properties (or Alt-F7) Configuration Properties->Linker->Input->Additional Dependencies

代替通常的 "cv210.lib cxcore210.lib highgui210.lib"的作者 "cv210d.lib cxcore210d.lib highgui210d.lib"-这是调试库.

replace the usual " cv210.lib cxcore210.lib highgui210.lib" by " cv210d.lib cxcore210d.lib highgui210d.lib" - which are the debugging libraries.

OpenCv 2.0 API命令现在应该可以使用.

The OpenCv 2.0 API commands should work now.

这篇关于使用imshow的OpenCV 2.0 C ++ API:返回未处理的异常和“错误标志".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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