OpenCV的新手,我已经在Java OpenCV中做了一些东西,但是对于这个lib有限,我很难迈向C / C ++!
我已经成功构建并运行了C OpenCV项目,但看到大多数教程在C ++版本上运行,我正在尝试制作一个简单的“HelloCV”:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main()
{
Mat img = imread("c:/lenna.png", CV_LOAD_IMAGE_COLOR);
namedWindow("MyWindow", CV_WINDOW_AUTOSIZE);
imshow("MyWindow", img);
waitKey(0);
return 0;
}
我总是遇到以下错误:
../src/mainCPP.cpp:12: undefined reference to `cv::imread(std::string const&, int)'
../src/mainCPP.cpp:14: undefined reference to `cv::namedWindow(std::string const&, int)'
../src/mainCPP.cpp:15: undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
../src/mainCPP.cpp:15: undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
../src/mainCPP.cpp:17: undefined reference to `cv::waitKey(int)'
src\maincpp.o: In function `ZN2cv3MatD1Ev':
C:/OpenCV_2.4.9/opencv/build/include/opencv2/core/mat.hpp:278: undefined reference to `cv::fastFree(void*)'
src\maincpp.o: In function `ZN2cv3Mat7releaseEv':
C:/OpenCV_2.4.9/opencv/build/include/opencv2/core/mat.hpp:367: undefined reference to `cv::Mat::deallocate()'
collect2.exe: error: ld returned 1 exit status
我已经关注了大约4-5次安装tuto,但我只是成功地破坏了我的项目!
我的“工作”设置:
我添加了环境变量:C:\ OpenCV_2.4.9 \ opencv \ build \ x86 \ vc11 \ bin(它不仅适用于M $ Visual Studio吗?!)
答案 0 :(得分:0)
似乎openCV没有正确安装。尝试使用Chocolatey,它可以在Windows上干净地安装最新版本的OpenCV。