在eclipse上使用c/c++中的opencv进行对象检测

object_detection using opencv in c/c++ on eclipse

本文关键字:opencv 中的 检测 对象 c++ eclipse      更新时间:2023-10-16

我正在尝试从网络摄像头拍摄的视频中检测人脸和眼睛。我在ubuntu 11.10上使用eclipse和openv -2.3.1。我想用C/c++写这个代码。我通过查看教程配置了eclipse。我在网上得到的代码是objectDetection.cpp

我得到的错误如下:

> **** Build of configuration Release for project opencv_try **** make all 
> Building file: ../objectDetection2.cpp 
> Invoking: GCC C++ Compiler 
> g++ -I/home/vidula/OpenCV-2.3.1/include/opencv -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"objectDetection2.d" -MT"objectDetection2.d" -o"objectDetection2.o" "../objectDetection2.cpp" 
> Finished building: ../objectDetection2.cpp  
> Building target: opencv_try 
> Invoking: GCC C++ Linker 
> g++ -L/usr/lib -L/home/vidula/OpenCV-2.3.1/lib -L/home/vidula/OpenCV-2.3.1/modules/imgproc/include/opencv2/imgproc -o"opencv_try"  ./objectDetection2.o   -lopencv_core -lopencv_highgui 
> /usr/bin/ld: ./objectDetection2.o: undefined reference to symbol 'cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)' 
> /usr/bin/ld: note: 'cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)' is defined in DSO /usr/local/lib/libopencv_imgproc.so.2.3 so try adding it to the linker command line 
> /usr/local/lib/libopencv_imgproc.so.2.3: could not read symbols: Invalid operation collect2: ld returned 1 exit status make:
> *** [opencv_try] Error 1

我试着把它链接到链接器,但我不知道我做错了什么。谁能帮我弄清楚出了什么问题吗?

它看起来像是在告诉你,你需要的cv::cvtColor符号在libopencv_imgproc库中,所以你需要用-lopencv_imgproc选项将它添加到你的链接器选项中,就像你对corehighgui所做的那样