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

查看:22
本文介绍了使用 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 ........ocvopencvsrccxcorecxarray.cpp, line 2376

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

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" by" 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天全站免登陆