我刚开始尝试使用 OpenCV,并从一本非常简单的书中编写了一个小程序。问题是当我尝试编译它时,我得到了这个错误。我会给你我所有的信息。我使用 Mac OS X 10.7 的自制软件安装了 openCV。
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main(int argc, char *argv[])
{
cv::Mat image = cv::imread("usf.gif");
cv::namedWindow("My Image");
cv::imshow("My Image", image);
cv::waitKey(5000);
return 1;
}
我编译喜欢这个:
g++ -o test opencvtest.cc -lopencv_core -lopencv_imgproc -lopencv_calib3d -lopencv_video -lopencv_features2d -lopencv_ml -lopencv_highgui -lopencv_objdetect -lopencv_contrib -lopencv_legacy
这就是我尝试运行它时得到的结果。
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /tmp/homebrew-opencv-2.4.2-oQmu/OpenCV-2.4.2/modules/core/src/array.cpp, line 2482
terminate called throwing an exceptionAbort trap: 6
再次感谢。