无法编译 Haartraining 教程中的 mergevec.cpp

发布于 2024-11-08 15:27:08 字数 572 浏览 3 评论 0 原文

我一直在关注本教程( http://note.sonots.com/SciSoftware/haartraining.html< /a> ) 进行一些 Haar 训练。我目前正致力于创建训练样本,特别是 .vec 文件的组合。我提供了这个( http://note.sonots.com/SciSoftware/haartraining /mergevec.cpp.html )文件以及如何为 Linux (Ubuntu 11.04) 构建它的描述。这就是我的问题,我无法构建 mergevec 代码。唯一的错误是“致命错误:cvhaartraining.h:没有这样的文件或目录。”我已检查以确保 cvhaartraining.h 与 mergevec 位于同一目录中,但发现一切都在我期望的位置。此时,我不知道如何解决这个问题,所以任何帮助将不胜感激。

I have been following this tutorial ( http://note.sonots.com/SciSoftware/haartraining.html ) to do some Haar training. I am currently stuck on creating the training samples, specifically the combining of the .vec files. I am provided with this ( http://note.sonots.com/SciSoftware/haartraining/mergevec.cpp.html ) file and a description of how to build it for Linux (Ubuntu 11.04). Here lies my problem, I am unable to build the mergevec code. The only error is "fatal error: cvhaartraining.h: No such file or directory." I have checked to make sure that cvhaartraining.h is in the same directory as mergevec but have found everything to be right where I would expect it. At this point, I am at a loss of how to solve this, so any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

染火枫林 2024-11-15 15:27:08

为了构建 mergevec,我发现最简单的方法是编辑 CMake 配置文件。在 OpenCV 2.3.1 中,haartraining 目录位于 modules/haartraining 中,而在 2.4.5 中,它位于 apps/haartraining 中。无论哪种方式,您有兴趣编辑的文件名为 CMakeLists.txt

最简单的方法是为 mergevec 添加一个特殊部分,如下所示:

# -----------------------------------------------------------
#  mergevec
# -----------------------------------------------------------
add_executable(opencv_mergevec mergevec.cpp)
set_target_properties(opencv_mergevec PROPERTIES
                      DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
                      OUTPUT_NAME "opencv_mergevec")

您可以将其添加到安装部分之前。然后将mergevec.cpp放入haartraining目录中,正常构建OpenCV,您将得到一个opencv_mergevec二进制文件,即mergevec。 cpp 可执行文件。

For building mergevec I found that the easiest way was to edit CMake configuration files. In OpenCV 2.3.1, the haartraining directory is in modules/haartraining whereas in 2.4.5 it is in apps/haartraining. Either way, the file you are interested in editing is called CMakeLists.txt.

The easiest thing to do is to add a special section for mergevec, as follows:

# -----------------------------------------------------------
#  mergevec
# -----------------------------------------------------------
add_executable(opencv_mergevec mergevec.cpp)
set_target_properties(opencv_mergevec PROPERTIES
                      DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
                      OUTPUT_NAME "opencv_mergevec")

You can add this right before the installation section. Then place mergevec.cpp into the haartraining directory, build OpenCV normally, and you will have an opencv_mergevec binary which is the mergevec.cpp executable.

乙白 2024-11-15 15:27:08

对于其他在 Ubuntu 上遇到此问题的人,请将标志移至调用末尾,如下所示:

g++ -I. -o mergevec mergevec.cpp cvboost.cpp cvcommon.cpp cvsamples.cpp cvhaarclassifier.cpp cvhaartraining.cpp `pkg-config --libs --cflags opencv`

For others struggling with this on Ubuntu, move the flags to the end of the invocation, like this:

g++ -I. -o mergevec mergevec.cpp cvboost.cpp cvcommon.cpp cvsamples.cpp cvhaarclassifier.cpp cvhaartraining.cpp `pkg-config --libs --cflags opencv`
各空 2024-11-15 15:27:08

要解决您的问题,请输入以下内容:

g++ `pkg-config --libs --cflags opencv` -I. -o mergevec mergevec.cpp cvboost.cpp cvcommon.cpp cvsamples.cpp cvhaarclassifier.cpp haartraining.cpp   -lopencv_core -lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_objdetect

祝你好运
易卜拉欣

To fix your problem type the following:

g++ `pkg-config --libs --cflags opencv` -I. -o mergevec mergevec.cpp cvboost.cpp cvcommon.cpp cvsamples.cpp cvhaarclassifier.cpp haartraining.cpp   -lopencv_core -lopencv_calib3d -lopencv_imgproc -lopencv_highgui -lopencv_objdetect

Good Luck
Ibrahim

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文