我在使用从mac端口安装的openCV 2.3.1时遇到了问题。对于xcode项目的安装和配置,我使用了this post from Salem's blog。文章中显示的示例代码运行得很好。但是,如果我将mail.cpp文件更改为仅显示图像,则会失败。下面是我的示例代码:
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main (int argc, const char * argv[])
{
cv::Mat img = cv::imread("Lena.jpg");
cv::namedWindow("Image");
cv::imshow("Image", img);
}我得到的错误如下:
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/OpenCV-2.3.1/modules/core/src/array.cpp, line 2482
terminate called throwing an exception(lldb) 现在我有点困惑了,因为我也不太熟悉c++。
有什么建议吗?
发布于 2012-04-27 01:59:08
崩溃有可能是由于imread()在磁盘上找不到镜像造成的:
cv::Mat img = cv::imread("Lena.jpg");
if (!img.data)
{
// print error and abort execution
}除非你开始安全地编码,否则你永远不会知道。
https://stackoverflow.com/questions/10336033
复制相似问题