gpt4 book ai didi

c++ - OpenCV:无法加载库 libopencv_calib3d.2.4.dylib 时出错

转载 作者:行者123 更新时间:2023-11-28 02:44:11 25 4
gpt4 key购买 nike

我正在尝试在我的 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 文件与图片一起从右数第二个。我不明白程序是如何找不到文件的,因为名称和位置似乎是正确的。

enter image description here

测试.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;
}

最佳答案

想通了。从 /usr/local/Cellar/opencv/2.4.9/lib 中复制 .dylib 文件并将它们粘贴到 /usr/lib 中。

关于c++ - OpenCV:无法加载库 libopencv_calib3d.2.4.dylib 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24987797/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com