如何使用 TBB 构建 OpenCV?

发布于 2024-12-13 14:31:40 字数 644 浏览 0 评论 0原文

我正在尝试让 opencv_traincascade 使用多个线程,但失败了。我能找到的唯一文档说“使用 TBB 构建 OpenCV”。我不确定我是否无法使用 TBB 成功构建 OpenCV,或者是否需要为 opencv_traincascade 设置一些标志。

我已经下载了 OpenCV 版本 2.3.1 windows superpack 和 tbb40_20111003oss_win.zip,并将其解压到 C:\tbb40_20111003oss。然后我使用 CMake 生成 VC8 .sln.proj 文件,设置

WITH_TBB:开启

TBB_INCLUDE_DIR:PATH=C:\tbb40_20111003oss\include

TBB_LIB_DIR:PATH=C:/tbb40_20111003oss/lib/intel64/vc8

OpenCV 然后构建没有错误,但是当我运行时opencv_traincascade 它是单线程的。有谁知道我做错了什么?

I'm trying and failing to make opencv_traincascade use multiple threads. The only documentation I can find says to "build OpenCV with TBB". I'm not sure if I'm failing to successfully build OpenCV with TBB, or whether there's some flag I need to set for opencv_traincascade.

I've downloaded the OpenCV version 2.3.1 windows superpack and tbb40_20111003oss_win.zip, which I extracted to C:\tbb40_20111003oss. I then generated VC8 .sln and .proj files using CMake, setting

WITH_TBB: ON

TBB_INCLUDE_DIR:PATH=C:\tbb40_20111003oss\include

TBB_LIB_DIR:PATH=C:/tbb40_20111003oss/lib/intel64/vc8

OpenCV then builds without errors, but when I run opencv_traincascade it's singlethreaded. Does anyone know what I'm doing wrong?

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

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

发布评论

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

评论(7

初与友歌 2024-12-20 14:31:41

如果您使用的是 Mac,则可以使用 homebrew 执行此操作:

brew tap homebrew/science
brew install opencv --with-tbb

或者如果您已经安装了 homebrew:

brew uninstall opencv
brew install opencv --with-tbb

此外,info 命令会告诉您有关您可能感兴趣的其他标志,例如 -- with-java

brew info opencv 

If you are on Mac you can do this with homebrew:

brew tap homebrew/science
brew install opencv --with-tbb

Or if you have already installed with homebrew:

brew uninstall opencv
brew install opencv --with-tbb

Also, the info command tells you about other flags you might be interested in, e.g. --with-java

brew info opencv 
狼性发作 2024-12-20 14:31:41

我知道这是一个旧线程,但我认为问题是您正在使用带有 Haart 功能的 Traincascade,而不是与使用整数而不是浮点的 LBP 功能一起使用,并且工作速度快了 3 倍。

有关更多信息,请参阅此问题中的评论作者提供的有关此的信息。快速总结:Haart 训练很难并行化,但 LBP 更容易并利用大量处理器。

希望有帮助!

I know this is an old thread but I think the problem is that you are using Traincascade with Haart feature insdead of using with the LBP features which uses integer instead of floating point and are working 3 times faster.

See the comment in this question for more information from the author about this. Quick summary: Haart training is difficult to paralelize but LBP is much easier and take advantage of a lot of processors.

Hope it help!

第七度阳光i 2024-12-20 14:31:41

对于 Linux,执行以下操作:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON BUILD_TBB=ON ..

For linux, do:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON BUILD_TBB=ON ..
暮色兮凉城 2024-12-20 14:31:41

尝试使用 setNumThreads(),并将处理器核心的数量作为参数。有一个帮助函数可以找到最佳线程数(等于核心数),但我不记得了。

并确保您还重建了 train_cascade exe

Try setNumThreads(), with the number of your processor cores as parameters. There is a helper function to find the optimum number of threads (equals the number of cores), but I cannot remember it.

And make sure you also rebuild the train_cascade exe

一萌ing 2024-12-20 14:31:41

构建 tbb 二进制文件后,请确保您的路径正确地将可执行文件定向到 tbb dll。您可能正在加载非 tbb dll(这发生在我身上),并且它们不会提供多线程。

After building the tbb binaries, make sure your path is correctly directing your executable to the tbb dlls. It is possible that you are loading the non-tbb dlls (this happened to me) and these will provide no multithreading.

酷到爆炸 2024-12-20 14:31:41

此外,一个接触点是在系统上安装 Intel TBB:

$ sudo apt-get install libtbb-dev

Also, one touch point is the installation of Intel TBB on the system:

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