Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用Opencv:BlobDetector时出现未定义的引用错误_C++_Eclipse_Opencv_Blobs - Fatal编程技术网

C++ 使用Opencv:BlobDetector时出现未定义的引用错误

C++ 使用Opencv:BlobDetector时出现未定义的引用错误,c++,eclipse,opencv,blobs,C++,Eclipse,Opencv,Blobs,当我尝试使用opencv编译程序以检测blob时,出现以下错误: 11:47:34 **** Incremental Build of configuration Debug for project testOpencv Info: Internal Builder is used for build g++ "-IC:\\Development\\opencv\\build\\include" -O0 -g3 -Wall -c -fmessage- length=0 -o "src

当我尝试使用opencv编译程序以检测blob时,出现以下错误:

11:47:34 **** Incremental Build of configuration Debug for project testOpencv 
Info: Internal Builder is used for build
g++ "-IC:\\Development\\opencv\\build\\include" -O0 -g3 -Wall -c -fmessage-      length=0 -o "src\\testOpencv.o" "..\\src\\testOpencv.cpp" 
g++ "-LC:\\Development\\opencv\\MINGW\\x86\\bin" -o testOpencv.exe    "src\\testOpencv.o" -llibopencv_calib3d2410 -llibopencv_contrib2410 -  llibopencv_core2410 -llibopencv_flann2410 -llibopencv_gpu2410 -   llibopencv_highgui2410 -llibopencv_imgproc2410 -llibopencv_ml2410 -  llibopencv_legacy2410 -llibopencv_nonfree2410 -llibopencv_objdetect2410 -  llibopencv_ocl2410 -llibopencv_photo2410 -llibopencv_stitching2410 -  llibopencv_superres2410 -llibopencv_video2410 -llibopencv_videostab2410 -  lopencv_ffmpeg2410 -llibopencv_ml2410 
src\testOpencv.o: In function `main':
C:\Development\Workspace\testOpencv\Debug/../src/testOpencv.cpp:98: undefined     reference to `cv::SimpleBlobDetector::Params::Params()'
C:\Development\Workspace\testOpencv\Debug/../src/testOpencv.cpp:110: undefined reference to     `cv::SimpleBlobDetector::SimpleBlobDetector(cv::SimpleBlobDetector::Params const&)'
C:\Development\Workspace\testOpencv\Debug/../src/testOpencv.cpp:113:    undefined reference to `cv::FeatureDetector::detect(cv::Mat const&,   std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >&, cv::Mat const&) const'
C:\Development\Workspace\testOpencv\Debug/../src/testOpencv.cpp:117: undefined reference to `cv::drawKeypoints(cv::Mat const&,   std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> > const&, cv::Mat&,   cv::Scalar_<double> const&, int)'
src\testOpencv.o: In function `ZN2cv18SimpleBlobDetectorD1Ev':
C:/Development/opencv/build/include/opencv2/features2d/features2d.hpp:615: undefined reference to `vtable for cv::SimpleBlobDetector'
C:/Development/opencv/build/include/opencv2/features2d/features2d.hpp:615:undefined reference to `vtable for cv::SimpleBlobDetector'
C:/Development/opencv/build/include/opencv2/features2d/features2d.hpp:615:undefined reference to `VTT for cv::SimpleBlobDetector'
C:/Development/opencv/build/include/opencv2/features2d/features2d.hpp:615:    undefined reference to `cv::FeatureDetector::~FeatureDetector()'collect2.exe: error: ld returned 1 exit status

11:47:38 Build Finished (took 4s.111ms) >
11:47:34****项目testOpencv配置调试的增量构建
信息:内部生成器用于生成
g++“-IC:\\Development\\opencv\\build\\include“-O0-g3-Wall-c-fmessage-length=0-o”src\\testOpencv.o”“..\\src\\testOpencv.cpp”
g++“-LC:\\Development\\opencv\\MINGW\\x86\\bin”-o testOpencv.exe“src\\testOpencv.o”-llibopencv_Calib3410-llibopencv_contrib2410-llibopencv_Flann241-llibopencv_GPU241-llibopencv_highgui2410-llibopencv_imgproc2410-llibopencv_ml2410-llibopencv_legacy2410-llibopencv_非自由2410-llibopencv_OBJDetec2410-llibopencv_ocl2410-LLIBOPENCU PHOT2410-LLIBOPENCUllibopencv_superres2410-llibopencv_video2410-llibopencv_video2410-lopencv ffmpeg2410-llibopencv_ml2410
src\testOpencv.o:在函数'main'中:
C:\Development\Workspace\testOpencv\Debug/。/src/testOpencv.cpp:98:对“cv::SimpleBlobDetector::Params::Params()”的未定义引用
C:\Development\Workspace\testOpencv\Debug/。/src/testOpencv.cpp:110:对“cv::SimpleBlobDetector::SimpleBlobDetector(cv::SimpleBlobDetector::Params const&)”的未定义引用
C:\Development\Workspace\testOpencv\Debug/。/src/testOpencv.cpp:113:对“cv::FeatureDetector::detect(cv::Mat const&,std::vector&,cv::Mat const&)const”的未定义引用
C:\Development\Workspace\testOpencv\Debug/。/src/testOpencv.cpp:117:cv::drawKeypoints(cv::Mat const&,std::vector const&,cv::Mat&,cv::Scalar_uconst&,int)的未定义引用
src\testOpencv.o:在函数'ZN2cv18SimpleBlobDetectorD1Ev'中:
C:/Development/opencv/build/include/opencv2/features2d/features2d.hpp:615:vtable for cv::SimpleBlobDetector的未定义引用
C:/Development/opencv/build/include/opencv2/features2d/features2d.hpp:615:vtable for cv::SimpleBlobDetector的未定义引用
C:/Development/opencv/build/include/opencv2/features2d/features2d.hpp:615:VTT for cv::SimpleBlobDetector的未定义引用
C:/Development/opencv/build/include/opencv2/features2d/features2d.hpp:615:未定义对'cv::FeatureDetector::~FeatureDetector()'collect2.exe的引用:错误:ld返回1个退出状态
11:47:38构建完成(耗时4.111ms)>
我使用Eclipse、Windows7-64位进行编译,并尝试按照与此链接相反的顺序包含库-。 下面是我的包含文件-

#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include <iostream>
string imageName("image/Picture7.jpg");
if( argc > 1)
{
    imageName = argv[1];
}

Mat image,grey_image, src;
src = imread("image/lena512color.jpg");

image = imread(imageName.c_str(), IMREAD_COLOR);

//resizing to make it a normal size
resize(image, image, src.size());

namedWindow( "Display window", WINDOW_AUTOSIZE ); 
imshow( "Display window", image ); 
// to display the image in greyscale
cvtColor(image, grey_image, CV_RGB2GRAY);//CV_BGR2GRAY);
imwrite( "savedImage/Gray_image.jpg", grey_image );
namedWindow("Gray window", WINDOW_AUTOSIZE);
imshow("Gray window", grey_image);
// Reduce the noise so we avoid false circle detection
GaussianBlur( grey_image, grey_image, Size(9, 9), 2, 2 );
SimpleBlobDetector::Params params;
 params.maxThreshold= 200;
 params.minThreshold = 10;
 params.filterByArea= true;
 params.minArea = 1500;
 params.filterByCircularity= true;
 params.minCircularity = 0.1;
 params.filterByConvexity= true;
 params.minConvexity = 0.87;
 params.filterByInertia= true;
 params.minInertiaRatio= 0.01;

 SimpleBlobDetector detector(params);

 vector<KeyPoint> keypoints;
 detector.detect(grey_image, keypoints);

 //Draw detected blobs as red circles
 Mat blob_circles;
 drawKeypoints(grey_image, keypoints, blob_circles,Scalar(0,0,255), DrawMatchesFlags:: DRAW_RICH_KEYPOINTS);
 imshow("Keypoints", blob_circles);

waitKey(0);
return 0;
}
#包括“opencv2/calib3d/calib3d.hpp”
#包括“opencv2/features2d/features2d.hpp”
#包括“opencv2/imgproc/imgproc.hpp”
#包括“opencv2/core/core.hpp”
#包括“opencv2/highgui/highgui.hpp”
#包括“opencv/cv.h”
#包括“opencv/highgui.h”
#包括
字符串imageName(“image/Picture7.jpg”);
如果(argc>1)
{
imageName=argv[1];
}
Mat图像、灰色图像、src;
src=imread(“image/lena512color.jpg”);
image=imread(imageName.c_str(),imread_COLOR);
//调整大小使其成为正常大小
调整大小(image,image,src.size());
namedWindow(“显示窗口”,窗口自动调整大小);
imshow(“显示窗口”,图像);
//以灰度显示图像的步骤
CVT颜色(图像、灰色图像、CV\U RGB2GRAY)//CV_bgr2(灰色);
imwrite(“savedImage/Gray_image.jpg”,Gray_image);
namedWindow(“灰色窗口”,窗口自动调整大小);
imshow(“灰色窗口”,灰色图像);
//减少噪音,避免假圆检测
高斯模糊(灰度图像,灰度图像,大小(9,9),2,2);
SimpleBlobDetector::Params Params;
参数maxThreshold=200;
params.minThreshold=10;
params.filterByArea=true;
参数s.minArea=1500;
参数filterByCircularity=true;
参数最小圆度=0.1;
参数filterByConvexity=true;
params.min凸度=0.87;
参数filterByInertia=true;
参数minInertiaRatio=0.01;
SimpleBlobDetector检测器(params);
矢量关键点;
检测器。检测(灰度图像、关键点);
//将检测到的斑点绘制为红色圆圈
Mat-blobu圆;
drawKeypoints(灰色图像、关键点、斑点圆、标量(0,0255)、DrawMatchesFlags::DRAW\u RICH\u关键点);
imshow(“关键点”,水滴形圆圈);
等待键(0);
返回0;
}

如何避免这些错误?

在链接器选项中:根据您的
opencv
版本名称添加
-llibopencv\u功能2D2410.lib
-llibopencv\u objdetect2410.lib

此外,库的路径似乎不正常:


“-LC:\\Development\\opencv\\MINGW\\x86\\bin”
应该是
“-LC:\\Development\\opencv\\MINGW\\x86\\lib”

您的项目似乎缺少依赖项。