我在使用imgproc.hpp文件中的cornerSubPix方法时遇到了麻烦。 我不明白哪个库丢失或错误是什么。 我在OS X 10.10.3上使用Qt 5.4.1,并使用OpenCV 3.0.0 C ++库。
这是我的代码:
#include <opencv2/opencv.hpp>
#include <opencv2/core/types.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <vector>
#include <stdio.h>
#include "cameraparams.h"
#include <iostream>
[...]
vector< vector <Point2f> > left_2D_points, right_2D_points;
for( int i=0;i<left_images.size();i++){
Mat left_image = left_images[i];
Mat rig
ht_image = right_images[i];
std::vector<cv::Point2f> left_im_points,right_im_points;
bool found_left = findChessboardCorners(left_image,Size(width,height),left_im_points,CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE+ CALIB_CB_FAST_CHECK);
bool found_right = findChessboardCorners(right_image,Size(width,height),right_im_points,CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE+ CALIB_CB_FAST_CHECK);
if( found_left && found_right){
Size winSize = Size( 7, 7 );
Size zeroZone = Size( -1, -1 );
TermCriteria criteria = TermCriteria( TermCriteria::EPS + TermCriteria::MAX_ITER, 40, 0.001 );
cv::cornerSubPix(left_image,left_im_points,winSize,zeroZone,criteria);
}
}
这是我的* .pro文件:
INCLUDEPATH += /usr/local/include/ \
/usr/local/include/pcl-1.7/ \
/usr/local/include/eigen3/ \
/usr/local/include/vtk-6.2/
LIBS += -L/usr/local/lib \
-lopencv_core \
-lopencv_imgcodecs \
-lopencv_highgui \
-lopencv_imgproc \
-lopencv_objdetect \
-lopencv_calib3d \
-lopencv_features2d \
-lopencv_flann \
-lopencv_ml \
-lopencv_photo \
-lopencv_shape \
-lopencv_stitching \
-lopencv_superres \
-lopencv_ts \
-lopencv_video \
-lopencv_videoio \
-lopencv_videostab
所以我想在我的棋盘上更准确地检测角落。但是当我编译时,我得到了这个错误:
Undefined symbols for architecture x86_64:
"cv::_InputArray::getMatVector(std::vector<cv::Mat, std::allocator<cv::Mat> >&) const", referenced from:
vtable for cv::_InputOutputArray in calibrator.o
"cv::_InputArray::getUMatVector(std::vector<cv::UMat, std::allocator<cv::UMat> >&) const", referenced from:
vtable for cv::_InputOutputArray in calibrator.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Classification] Error 1
我正在寻找几天后的答案,而且我已经被封锁了。 感谢所有人提前做好准备!
答案 0 :(得分:0)
上次使用相同配置时遇到了同样的问题(Mac OS 10.10.3,Qt 5.4.1,OpenCV 3.0)。似乎编译器clang与opencv 3.0不兼容。
使用旧版本的opencv(例如2.4.10)可以解决问题。
玩得开心,祝你好运:)
答案 1 :(得分:0)
此问题首先发生reported here。它似乎与您的编译器正在使用的C ++标准库的版本有关。在该主题上已经讨论了一些解决方法。
但是,another answer on Stackoverflow似乎解决了这个问题。