【发布时间】:2014-07-28 02:45:53
【问题描述】:
我正在尝试在我的 Mac 上设置 openCV(随 homebrew 安装)并运行以下命令。
g++ $(pkg-config --cflags --libs opencv) test.cpp -o Test& ./test
但是,我收到了这个错误:
[1] 7834
dyld: Library not loaded: lib/libopencv_calib3d.2.4.dylib
Referenced from: /usr/local/Cellar/opencv/2.4.9/include/./test
Reason: image not found
Trace/BPT trap: 5
对于 openCV 和 C++ 来说非常新手,我不确定如何处理这个问题。
下面显示了文件结构。 test.cpp 文件与图片一起位于右侧第二个。我看不出程序如何找不到文件,因为名称和位置似乎是正确的。
test.cpp:
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, const char** argv )
{
cout << "test output line" << endl;
Mat img = imread("MyPic.JPG", CV_LOAD_IMAGE_UNCHANGED); //read the image data in the file "MyPic.JPG" and store it in 'img'
if (img.empty()) //check whether the image is loaded or not
{
cout << "Error : Image cannot be loaded..!!" << endl;
//system("pause"); //wait for a key press
return -1;
}
namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); //create a window with the name "MyWindow"
imshow("MyWindow", img); //display the image which is stored in the 'img' in the "MyWindow" window
waitKey(0); //wait infinite time for a keypress
destroyWindow("MyWindow"); //destroy the window with the name, "MyWindow"
return 0;
}
【问题讨论】: