CPP 中的 OpenCV 库(特别是文件 letter_recog.cpp)
Posted
技术标签:
【中文标题】CPP 中的 OpenCV 库(特别是文件 letter_recog.cpp)【英文标题】:OpenCV Libraries in CPP (Specifically, file letter_recog.cpp) 【发布时间】:2017-09-14 21:56:06 【问题描述】:我只是想从 opencv 库中为 cpp 编译/构建/运行示例代码,当我尝试构建它时遇到了问题。
我已经按照http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html 正确安装了opencv 以及将 opencv 包含文件从框架文件移动到 /usr/local/include/opencv2 的包含中 将框架中的 opencv 包含文件移动到该文件夹中解决了我的大部分问题(未找到 opencv2 文件),但构建文件 letter_recog.cpp 的问题不起作用。通过不工作,我的意思是它有很多构建错误。
文件的代码如下: https://github.com/opencv/opencv/blob/master/samples/cpp/letter_recog.cpp
构建错误如下:
g++ -g -std=c++14 -Wall -Wextra -pedantic -lpthread -o "letter_recog" "letter_recog.cpp" (in directory: /home/courtneymaroney/opencv/samples/cpp)
/tmp/ccUbgW02.o: In function `read_num_class_data(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, cv::Mat*, cv::Mat*)':
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:74: undefined reference to `cv::Mat::push_back(cv::Mat const&)'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:77: undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
/tmp/ccUbgW02.o: In function `prepare_train_data(cv::Mat const&, cv::Mat const&, int)':
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:100: undefined reference to `cv::Mat::zeros(int, int, int)'
/tmp/ccUbgW02.o: In function `prepare_train_data(cv::Mat const&, cv::Mat const&, int)':
/usr/local/include/opencv2/core/mat.hpp:1110: undefined reference to `cv::noArray()'
/tmp/ccUbgW02.o: In function `prepare_train_data(cv::Mat const&, cv::Mat const&, int)':
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:102: undefined reference to `cv::Mat::setTo(cv::_InputArray const&, cv::_InputArray const&)'
/tmp/ccUbgW02.o: In function `prepare_train_data(cv::Mat const&, cv::Mat const&, int)':
/usr/local/include/opencv2/core/mat.hpp:1110: undefined reference to `cv::noArray()'
/tmp/ccUbgW02.o: In function `prepare_train_data(cv::Mat const&, cv::Mat const&, int)':
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:106: undefined reference to `cv::Mat::setTo(cv::_InputArray const&, cv::_InputArray const&)'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:110: undefined reference to `cv::noArray()'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:110: undefined reference to `cv::noArray()'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:110: undefined reference to `cv::ml::TrainData::create(cv::_InputArray const&, int, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&)'
/tmp/ccUbgW02.o: In function `test_and_save_classifier(cv::Ptr<cv::ml::StatModel> const&, cv::Mat const&, cv::Mat const&, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/local/include/opencv2/ml.hpp:349: undefined reference to `cv::noArray()'
/tmp/ccUbgW02.o: In function `build_rtrees_classifier(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:187: undefined reference to `cv::ml::RTrees::create()'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:208: undefined reference to `cv::sum(cv::_InputArray const&)'
/tmp/ccUbgW02.o: In function `build_boost_classifier(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/local/include/opencv2/core/mat.hpp:1110: undefined reference to `cv::noArray()'
/tmp/ccUbgW02.o: In function `build_boost_classifier(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:277: undefined reference to `cv::Mat::setTo(cv::_InputArray const&, cv::_InputArray const&)'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:281: undefined reference to `cv::noArray()'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:281: undefined reference to `cv::noArray()'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:281: undefined reference to `cv::noArray()'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:281: undefined reference to `cv::ml::TrainData::create(cv::_InputArray const&, int, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&)'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:287: undefined reference to `cv::ml::Boost::create()'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:314: undefined reference to `cv::noArray()'
/tmp/ccUbgW02.o: In function `build_mlp_classifier(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:383: undefined reference to `cv::Mat::zeros(int, int, int)'
/tmp/ccUbgW02.o: In function `build_mlp_classifier(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/local/include/opencv2/ml.hpp:285: undefined reference to `cv::noArray()'
/usr/local/include/opencv2/ml.hpp:285: undefined reference to `cv::noArray()'
/usr/local/include/opencv2/ml.hpp:284: undefined reference to `cv::noArray()'
/usr/local/include/opencv2/ml.hpp:284: undefined reference to `cv::noArray()'
/tmp/ccUbgW02.o: In function `build_mlp_classifier(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:408: undefined reference to `cv::ml::TrainData::create(cv::_InputArray const&, int, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&)'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:411: undefined reference to `cv::ml::ANN_MLP::create()'
/tmp/ccUbgW02.o: In function `build_knearest_classifier(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:440: undefined reference to `cv::ml::KNearest::create()'
/tmp/ccUbgW02.o: In function `build_nbayes_classifier(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:467: undefined reference to `cv::ml::NormalBayesClassifier::create()'
/tmp/ccUbgW02.o: In function `build_svm_classifier(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:504: undefined reference to `cv::ml::SVM::create()'
/tmp/ccUbgW02.o: In function `main':
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:524: undefined reference to `cv::CommandLineParser::CommandLineParser(int, char const* const*, cv::String const&)'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:526: undefined reference to `cv::CommandLineParser::has(cv::String const&) const'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:528: undefined reference to `cv::CommandLineParser::has(cv::String const&) const'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:530: undefined reference to `cv::CommandLineParser::has(cv::String const&) const'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:532: undefined reference to `cv::CommandLineParser::has(cv::String const&) const'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:534: undefined reference to `cv::CommandLineParser::has(cv::String const&) const'
/tmp/ccUbgW02.o:/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:536: more undefined references to `cv::CommandLineParser::has(cv::String const&) const' follow
/tmp/ccUbgW02.o: In function `main':
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:557: undefined reference to `cv::CommandLineParser::~CommandLineParser()'
/home/courtneymaroney/opencv/samples/cpp/letter_recog.cpp:524: undefined reference to `cv::CommandLineParser::~CommandLineParser()'
/tmp/ccUbgW02.o: In function `cv::String::String(char const*)':
/usr/local/include/opencv2/core/cvstd.hpp:618: undefined reference to `cv::String::allocate(unsigned long)'
/tmp/ccUbgW02.o: In function `cv::String::~String()':
/usr/local/include/opencv2/core/cvstd.hpp:660: undefined reference to `cv::String::deallocate()'
/tmp/ccUbgW02.o: In function `cv::Mat::Mat(int, int, int, void*, unsigned long)':
/usr/local/include/opencv2/core/mat.inl.hpp:413: undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
/tmp/ccUbgW02.o: In function `cv::Mat::~Mat()':
/usr/local/include/opencv2/core/mat.inl.hpp:556: undefined reference to `cv::fastFree(void*)'
/tmp/ccUbgW02.o: In function `cv::Mat::row(int) const':
/usr/local/include/opencv2/core/mat.inl.hpp:591: undefined reference to `cv::Mat::Mat(cv::Mat const&, cv::Range const&, cv::Range const&)'
/tmp/ccUbgW02.o: In function `cv::Mat::rowRange(int, int) const':
/usr/local/include/opencv2/core/mat.inl.hpp:603: undefined reference to `cv::Mat::Mat(cv::Mat const&, cv::Range const&, cv::Range const&)'
/tmp/ccUbgW02.o: In function `cv::Mat::colRange(int, int) const':
/usr/local/include/opencv2/core/mat.inl.hpp:615: undefined reference to `cv::Mat::Mat(cv::Mat const&, cv::Range const&, cv::Range const&)'
/tmp/ccUbgW02.o: In function `cv::Mat::create(int, int, int)':
/usr/local/include/opencv2/core/mat.inl.hpp:648: undefined reference to `cv::Mat::create(int, int const*, int)'
/tmp/ccUbgW02.o: In function `cv::Mat::release()':
/usr/local/include/opencv2/core/mat.inl.hpp:667: undefined reference to `cv::Mat::deallocate()'
/tmp/ccUbgW02.o: In function `cv::FileStorage::getFirstTopLevelNode() const':
/usr/local/include/opencv2/core/persistence.hpp:1167: undefined reference to `cv::FileStorage::root(int) const'
/tmp/ccUbgW02.o: In function `cv::FileNode::begin() const':
/usr/local/include/opencv2/core/persistence.hpp:1184: undefined reference to `cv::FileNodeIterator::FileNodeIterator(CvFileStorage const*, CvFileNode const*, unsigned long)'
/tmp/ccUbgW02.o: In function `cv::FileNode::end() const':
/usr/local/include/opencv2/core/persistence.hpp:1185: undefined reference to `cv::FileNode::size() const'
/usr/local/include/opencv2/core/persistence.hpp:1185: undefined reference to `cv::FileNodeIterator::FileNodeIterator(CvFileStorage const*, CvFileNode const*, unsigned long)'
/tmp/ccUbgW02.o: In function `cv::String::String(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/usr/local/include/opencv2/core/cvstd.inl.hpp:81: undefined reference to `cv::String::allocate(unsigned long)'
/tmp/ccUbgW02.o: In function `cv::String cv::CommandLineParser::get<cv::String>(cv::String const&, bool) const':
/usr/local/include/opencv2/core/utility.hpp:682: undefined reference to `cv::CommandLineParser::getByName(cv::String const&, bool, int, void*) const'
/tmp/ccUbgW02.o: In function `cv::Mat::Mat<int>(std::vector<int, std::allocator<int> > const&, bool)':
/usr/local/include/opencv2/core/mat.inl.hpp:469: undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
/tmp/ccUbgW02.o: In function `cv::Mat::Mat<double>(std::vector<double, std::allocator<double> > const&, bool)':
/usr/local/include/opencv2/core/mat.inl.hpp:469: undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
/tmp/ccUbgW02.o: In function `cv::Ptr<cv::ml::RTrees> cv::Algorithm::load<cv::ml::RTrees>(cv::String const&, cv::String const&)':
/usr/local/include/opencv2/core.hpp:2972: undefined reference to `cv::FileStorage::FileStorage(cv::String const&, int, cv::String const&)'
/usr/local/include/opencv2/core.hpp:2973: undefined reference to `cv::FileStorage::operator[](cv::String const&) const'
/usr/local/include/opencv2/core.hpp:2974: undefined reference to `cv::ml::RTrees::create()'
/usr/local/include/opencv2/core.hpp:2972: undefined reference to `cv::FileStorage::~FileStorage()'
/usr/local/include/opencv2/core.hpp:2972: undefined reference to `cv::FileStorage::~FileStorage()'
/tmp/ccUbgW02.o: In function `cv::Ptr<cv::ml::Boost> cv::Algorithm::load<cv::ml::Boost>(cv::String const&, cv::String const&)':
/usr/local/include/opencv2/core.hpp:2972: undefined reference to `cv::FileStorage::FileStorage(cv::String const&, int, cv::String const&)'
/usr/local/include/opencv2/core.hpp:2973: undefined reference to `cv::FileStorage::operator[](cv::String const&) const'
/usr/local/include/opencv2/core.hpp:2974: undefined reference to `cv::ml::Boost::create()'
/usr/local/include/opencv2/core.hpp:2972: undefined reference to `cv::FileStorage::~FileStorage()'
/usr/local/include/opencv2/core.hpp:2972: undefined reference to `cv::FileStorage::~FileStorage()'
/tmp/ccUbgW02.o: In function `cv::Ptr<cv::ml::ANN_MLP> cv::Algorithm::load<cv::ml::ANN_MLP>(cv::String const&, cv::String const&)':
/usr/local/include/opencv2/core.hpp:2972: undefined reference to `cv::FileStorage::FileStorage(cv::String const&, int, cv::String const&)'
/usr/local/include/opencv2/core.hpp:2973: undefined reference to `cv::FileStorage::operator[](cv::String const&) const'
/usr/local/include/opencv2/core.hpp:2974: undefined reference to `cv::ml::ANN_MLP::create()'
/usr/local/include/opencv2/core.hpp:2972: undefined reference to `cv::FileStorage::~FileStorage()'
/usr/local/include/opencv2/core.hpp:2972: undefined reference to `cv::FileStorage::~FileStorage()'
/tmp/ccUbgW02.o: In function `cv::Ptr<cv::ml::SVM> cv::Algorithm::load<cv::ml::SVM>(cv::String const&, cv::String const&)':
/usr/local/include/opencv2/core.hpp:2972: undefined reference to `cv::FileStorage::FileStorage(cv::String const&, int, cv::String const&)'
/usr/local/include/opencv2/core.hpp:2973: undefined reference to `cv::FileStorage::operator[](cv::String const&) const'
/usr/local/include/opencv2/core.hpp:2974: undefined reference to `cv::ml::SVM::create()'
/usr/local/include/opencv2/core.hpp:2972: undefined reference to `cv::FileStorage::~FileStorage()'
/usr/local/include/opencv2/core.hpp:2972: undefined reference to `cv::FileStorage::~FileStorage()'
collect2: error: ld returned 1 exit status
Compilation failed.
我正在为 Ubuntu 16.04 使用一个名为“Geany”的 IDE。
granny 的编译/构建命令如下: 编译: g++ -std=c++14 -Wall -c "%f" 建造: g++ -g -std=c++14 -Wall -Wextra -pedantic -lpthread -o "%e" "%f"
我在互联网上寻找可能的解决方案。似乎有些人遇到了这个问题,但还没有人找到解决方案,或者至少没有人为此分享过解决方案。
echo $(pkg-config --libs opencv) 的输出 [我对其进行了格式化以使其更具可读性]:
echo $(pkg-config --libs opencv)
/usr/lib/x86_64-linux-gnu/libopencv_calib3d.so
-lopencv_calib3d
/usr/lib/x86_64-linux-gnu/libopencv_contrib.so
-lopencv_contrib
/usr/lib/x86_64-linux-gnu/libopencv_core.so
-lopencv_core
/usr/lib/x86_64-linux-gnu/libopencv_features2d.so
-lopencv_features2d
/usr/lib/x86_64-linux-gnu/libopencv_flann.so
-lopencv_flann
/usr/lib/x86_64-linux-gnu/libopencv_gpu.so
-lopencv_gpu
/usr/lib/x86_64-linux-gnu/libopencv_highgui.so
-lopencv_highgui
/usr/lib/x86_64-linux-gnu/libopencv_imgproc.so
-lopencv_imgproc
/usr/lib/x86_64-linux-gnu/libopencv_legacy.so
-lopencv_legacy
/usr/lib/x86_64-linux-gnu/libopencv_ml.so
-lopencv_ml
/usr/lib/x86_64-linux-gnu/libopencv_objdetect.so
-lopencv_objdetect
/usr/lib/x86_64-linux-gnu/libopencv_ocl.so
-lopencv_ocl
/usr/lib/x86_64-linux-gnu/libopencv_photo.so
-lopencv_photo
/usr/lib/x86_64-linux-gnu/libopencv_stitching.so
-lopencv_stitching
/usr/lib/x86_64-linux-gnu/libopencv_superres.so
-lopencv_superres
/usr/lib/x86_64-linux-gnu/libopencv_ts.so
-lopencv_ts
/usr/lib/x86_64-linux-gnu/libopencv_video.so
-lopencv_video
/usr/lib/x86_64-linux-gnu/libopencv_videostab.so
-lopencv_videostab
【问题讨论】:
你必须链接你正在使用的 OpenCV 库。 我试过了。它消除了一些问题,但它说找不到 imgcodecs。还有没有更快的方法或命令行每次都可以轻松完成? "没有人找到解决方案" -- 知道如何编译和链接你的代码是一项基本技能,我无法想象任何有能力的人觉得有必要为每个人写一篇单独的文章网络上散布着一段代码。您只需要了解一般原则,以及如何应用它们。 |您使用的是哪个版本的 OpenCV? 2.4 分支中可用的模块与 3.x 分支中的模块不同。 |关于命令行问题——我更喜欢使用 CMake。我建议阅读它是什么以及如何使用它。 为了详细说明最后一部分,为了编译重要的代码,您通常使用一些其他程序来驱动编译,并为它提供一些您想要构建的内容以及如何构建的描述。在类 unix 系统上,它通常是一个名为“make”的程序(对于简单的事情,您可以编写一个 shell 脚本)。但是,编写 makefile 有点痛苦,因此在此之上还有一个抽象层次——CMake 就是这样一种情况。它允许您以更一般的方式描述事物,然后生成使用特定工具包构建代码所需的文件。 这是 OpenCV 3.0 【参考方案1】:我不明白您是如何在系统上安装opencv
的,如果您真的手动复制了系统路径中的标头,那么我可能不想知道。另外我对IDE过敏,还是用更友好的终端吧。
通常最好的选择是在您的存储库中安装一个。在您的情况下(从您问题的标签来看,它显示为 ubuntu 16.10):
sudo apt update
sudo apt install libopencv-dev
这将修复有助于编译的pkg-config
文件。 (免责声明手动复制的标头的存在可能会干扰安装过程。如果您将它们放在/usr/include
中,我建议您在发出这两个命令之前将其删除)
现在对于letter_recog.cpp
的编译,以这种方式调用编译器就足够了:
g++ $(pkg-config --cflags --libs opencv) letter_recog.cpp -o letter_recog
如果你愿意,你也可以添加你的标志(-Wall -pedantic
等),但我建议你检查pkg-config
的作用:
echo $(pkg-config --cflags opencv)
echo $(pkg-config --libs opencv)
尤其是第二个是您显然错过的(要链接的库)。
最后,为了在 Geany 中进行修复,我怀疑您必须放置以下内容:
g++ -std=c++14 -Wall $(pkg-config --cflags opencv) -c "%f"
和
g++ -g -std=c++14 -Wall -Wextra -pedantic -lpthread $(pkg-config --libs opencv) -o "%e" "%f"
但是这个解决方案是有问题的(比如-lpthread
而不是-pthread
;而且你不需要它们来编写代码)。
长话短说:听听 Dan Mašek 的第一条评论:他是对的。
(抱歉打错了,我的保险丝很晚)
【讨论】:
谢谢。会尝试一下,然后回复你们。 接下来的几个小时我会处于 AFK 状态。 我试过了,但它根本不起作用。我仍然遇到同样的错误。看来基本上任何与 opencv (cv::) 相关的东西都有错误。echo $(pkg-config --libs opencv)
的输出是什么?
Mh 从输出中可以清楚地看出您的安装有问题。它应该只打印出-lopencv...
的序列,其中...
是特定opencv 元素的名称。请仔细描述您为安装 opencv 所做的一切。【参考方案2】:
已修复:使用本指南重新安装:
https://medium.com/@debugvn/installing-opencv-3-3-0-on-ubuntu-16-04-lts-7db376f93961
仅使用 g++ $(pkg-config --cflags --libs opencv) letter_recog.cpp -o letter_recog
无法正常工作,因此我必须添加一些标志 (-lopencv_name_of_library)
我对 makefile 有点不熟悉。一旦我找到了用 Makefiles 用文件名替换变量的方法,我将在此处提供一个自定义 makefile(作为编辑)来编译/构建项目,但到目前为止,因为我使用的是一个名为 Geany的 IDE >,我正在使用 build 命令(对于所有项目,不管是哪个)
g++ $(pkg-config --cflags --libs opencv) %f -o %e -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_photo -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_img_hash -lopencv_line_descriptor -lopencv_optflow -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_ml -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_flann -lopencv_xobjdetect -lopencv_imgcodecs -lopencv_objdetect -lopencv_xphoto -lopencv_imgproc -lopencv_core
感谢大家的帮助。最有用的评论是建议我安装不正确的评论。希望我的发现对其他人有所帮助。 (相信我,这是地狱,在尝试了不同的安装指南后,尝试安装 nvidia 驱动程序并损坏了我的整个操作系统,所以我不得不卸载该操作系统,重新安装操作系统,然后重新开始(失去了所有我的文件正在处理中))
希望你们不必经历我遇到的麻烦。这是地狱,但我认为 opencv 非常值得。
【讨论】:
以上是关于CPP 中的 OpenCV 库(特别是文件 letter_recog.cpp)的主要内容,如果未能解决你的问题,请参考以下文章
opencv源代码分析之二:cvhaartraining.cpp