Eu instalei duas versões do openCV: uma é openCV3 e outra uma openCV2.4 na minha máquina Ubuntu 16.04 e preciso de ambas. No entanto, agora sou incapaz de compilar o código C ++, que é destinado a openCV3. Eu recebo uma tonelada de erros de linker ao tentar compilar meu código que sempre compilou perfeitamente bem antes de instalar o openvc2.4
O tipo de erro que recebo:
In file included from main.cpp:10:0:
/usr/local/include/opencv2/imgproc.hpp:4090:5: note: previous declaration ‘cv::ColormapTypes COLORMAP_PINK’
COLORMAP_PINK = 10, //!< ![pink](pics/colormaps/colorscale_pink.jpg)
^
In file included from /usr/local/include/opencv2/opencv.hpp:59:0,
from include/faceDetection.h:6,
from main.cpp:11:
/usr/local/include/opencv2/contrib/contrib.hpp:980:24: error: redeclaration of ‘COLORMAP_HOT’
COLORMAP_HOT = 11
^
In file included from main.cpp:10:0:
/usr/local/include/opencv2/imgproc.hpp:4091:5: note: previous declaration ‘cv::ColormapTypes COLORMAP_HOT’
COLORMAP_HOT = 11, //!< ![hot](pics/colormaps/colorscale_hot.jpg)
^
main.cpp: In function ‘int main(int, char**)’:
main.cpp:89:65: error: call of overloaded ‘createFisherFaceRecognizer()’ is ambiguous
Ptr<BasicFaceRecognizer> model = createFisherFaceRecognizer();
^
In file included from /usr/local/include/opencv2/face.hpp:373:0,
from main.cpp:8:
/usr/local/include/opencv2/face/facerec.hpp:99:39: note: candidate: cv::Ptr<cv::face::BasicFaceRecognizer> cv::face::createFisherFaceRecognizer(int, double)
CV_EXPORTS_W Ptr<BasicFaceRecognizer> createFisherFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
^
In file included from /usr/local/include/opencv2/opencv.hpp:59:0,
from include/faceDetection.h:6,
from main.cpp:11:
/usr/local/include/opencv2/contrib/contrib.hpp:963:38: note: candidate: cv::Ptr<cv::FaceRecognizer> cv::createFisherFaceRecognizer(int, double)
CV_EXPORTS_W Ptr<FaceRecognizer> createFisherFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
^
main.cpp:93:48: error: no matching function for call to ‘cv::face::BasicFaceRecognizer::train(std::vector<cv::Mat>&, std::vector<int>&)’
model->train(trainImages, labelsTrainImages);
^
In file included from main.cpp:8:0:
/usr/local/include/opencv2/face.hpp:207:26: note: candidate: virtual void cv::face::FaceRecognizer::train(int, int)
CV_WRAP virtual void train(InputArrayOfArrays src, InputArray labels) = 0;
^
/usr/local/include/opencv2/face.hpp:207:26: note: no known conversion for argument 1 from ‘std::vector<cv::Mat>’ to ‘int’
main.cpp:123:64: error: no matching function for call to ‘cv::face::BasicFaceRecognizer::predict(cv::Mat&, int&, double&)’
model->predict(face, predictedLabel, confidence);
^
In file included from main.cpp:8:0:
/usr/local/include/opencv2/face.hpp:259:35: note: candidate: int cv::face::FaceRecognizer::predict(int) const
CV_WRAP_AS(predict_label) int predict(InputArray src) const;
O comando com o qual eu compilo:
g++ src/faceDetection.cpp src/faceRecognition.cpp main.cpp -L/usr/local/lib -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dpm -lopencv_fuzzy -lopencv_line_descriptor -lopencv_optflow -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_plot -lopencv_dnn -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core -o main
Isso é o que / usr / local / include parece:
$ ls /usr/local/include/
folly opencv opencv2 wangle
$ls /usr/local/include/opencv
cvaux.h cvaux.hpp cv.h cv.hpp cvwimage.h cxcore.h cxcore.hpp cxeigen.hpp cxmisc.h highgui.h ml.h
$ ls /usr/local/include/opencv2
aruco contrib dpm.hpp fuzzy.hpp imgproc.hpp ocl plot.hpp stereo.hpp text videostab
aruco.hpp core face gpu legacy opencv.hpp reg stitching text.hpp videostab.hpp
bgsegm.hpp core.hpp face.hpp hdf line_descriptor opencv_modules.hpp rgbd stitching.hpp tracking xfeatures2d
bioinspired cvconfig.h features2d hdf.hpp line_descriptor.hpp optflow rgbd.hpp structured_light tracking.hpp xfeatures2d.hpp
bioinspired.hpp cvv features2d.hpp highgui ml optflow.hpp saliency structured_light.hpp ts ximgproc
calib3d cvv.hpp flann highgui.hpp ml.hpp phase_unwrapping saliency.hpp superres video ximgproc.hpp
calib3d.hpp datasets flann.hpp imgcodecs nonfree phase_unwrapping.hpp shape superres.hpp video.hpp xobjdetect.hpp
ccalib dnn freetype.hpp imgcodecs.hpp objdetect photo shape.hpp surface_matching videoio xphoto
ccalib.hpp dnn.hpp fuzzy imgproc objdetect.hpp photo.hpp stereo surface_matching.hpp videoio.hpp xphoto.hpp
conteúdo de / usr / lib / x86_64-linux-gnu: link .