On the problem of OPENCV+CUDA+VS+TBB compiling OPENCV

Source: Internet
Author: User

First of all, my computer is Win7 64-bit operating system, installed is 32 for the Vs2008, to compile the OpenCv2.4.3 and TBB4.2;



The process of compiling is a lot of people have said the blog of one of the most detailed, also most comprehensive: http://blog.csdn.net/shuxiao9058/article/details/7529684

The following content I just paste this article, easy to see ( where the green part is different from the original text, but also we need to pay attention to):

Earlier, we talked about how to use OpenCV-2.4.0 to 2005/2008/2010 Normal compilation in Visual Studio, and this article focuses on how to make OPENCV support for CUDA high-speed operations.

The tools we're going to use, in addition to the tools that are routinely compiled, use the Cuda Tookit and the GPU Computing SDK, such as the versions I use for Cudatoolkit_4.2.9_win_64.msi and GPUCOMPUTINGSDK _4.2.9_win_64.exe (My computer is a 64-bit system), the relevant documents can be downloaded from the official website.

After the download is complete and installed to ensure that the bin directory ("C:\ProgramData\NVIDIA corporation\nvidia GPU Computing sdk4.2\c\common\bin") of the Cuda SDK has been added to the environment variable, We started compiling OPENCV that support CUDA high-speed operations.

In the case of visual Studio Professional, the other compilers are, in general, only slightly different in the step of the Intel TBB environment variable configuration, You can refer to the blog: Compile the x86 or x64 platform Visual studio2005/2008/2010 target file using the Opencv-2.4.0.exe file. first, build the project file

Let's say we've put the OpenCV-2.4.0 source code under the "C:\Program files\opencv\src" directory, install the CMake, and add the Ntel TBB executable directory to the system environment variable and make the variable effective. Related section Reference blog: Compile the x86 or x64 platform Visual studio2005/2008/2010 target file using the Opencv-2.4.0.exe file.

Run CMake, as shown in Figure 1, and then click Browse Source on the right side of where is the source code: Navigate to the C:/programfiles/opencv/src folder and click the Where to build The binaries: "Browse build" on the right, browsing to the "C:/Program files/opencv/vs2005" folder (vs2005 folder was created by myself).

Figure 1 Configuring the source code and the build directory

Then click the "Configure" button at the bottom left, and the "Cmake-gui" window pops up, and in the Specify generator for this project Drop-down menu, select "Visual Studio 8 2005", " Usedefault native compilers, click the Finish button, as shown in Figure 2.

Figure 2 Generating Project type selection

After the completion of the above operation Tick "Build_examples", "Cuda_build_cbuin", "Cuda_verbose_build", "WITH_TBB" and "With_cublas", "With_cuda", Note here do not tick "cuda_build_emulation" option, or it will be an error, as shown below.

[plain] view plain copy print? CMake Error at C:/Program Files (x86)/cmake 2.8/share/cmake-2.8/modules/findcuda.cmake:616 (message): Cuda_build_emula  tion is isn't supported in version 3.1 and onwards.  You are must disable it to proceed. You have version 4.2.

This is because at the beginning of the Cuda 4.0 NPP (Nvidia Performance Primitives library, Nvidia basic performance Library) is Cuda tookit part of the surface is no longer provided separately.

Configure TBB related directories (including directories, executable directories, and library directories) for details, refer to my blog: Compile x86 or x64 platform visual studio2005/2008/2010 target files using opencv-2.4.0.exe files. Don't repeat it here.

Click the "Configure" button, all red lines have changed to white, below the information we will see the following information:

[Plain]  View plain copy print? other third-party libraries:     Use IPP:                      NO     Use TBB:                      YES  (ver 4.0 interface 6004)       Use Cuda:                     YES  (ver 4.2)      Use Eigen:                    NO      nvidia cuda:                     (ver 4.2)      use cufft:                    yes     Use CUBLAS:                   YES     NVIDIA GPU arch:              11 12 13 20 21      NVIDIA PTX archs:             11 12 13 20 21     NVIDIA GPU features:          11 12 13 20 20 20  

In particular, there are two words "Use Tbb:yes (Ver 4.0 interface 6004)" and "Use Cuda:yes (ver 4.2)" To prove that we have configured Intel TBB and Cuda correctly.

Finally, click Generate, and the message below will have a "generating done" (as shown in Figure 3), and we have successfully generated the project file (as shown in Figure 4).

Figure 3 "Generating done"

Figure 4 successfully generate project file Two, compile and generate target files iii. organize catalog Four, configure and test OpenCV-2.4.0 function library

Description: Because the second, third and fourth parts and I another blog: the use of opencv-2.4.0.exe files to compile x86 or x64 platform visual studio2005/2008/2010 target files are exactly the same, except that it takes quite a long time to compile. Don't repeat it here.




The above is reproduced content, here to say a few need to pay attention to places:

1. This article uses the Cmake2.8.8 version, I have used 2.8.12 will appear many errors not mentioned in this article;

2. The aforementioned Cuda_build_cbuin "," cuda_verbose_build (as if these), some in fact in the CMake configuration and generation process is not found, but this does not affect the results, can be ignored;

3. Regarding the TBB path x86 and x64 version Lib choice question: If your vs is 32 bit to choose x86 's library, otherwise chooses x64 's library;

4. When loading the compiled header files, libraries, etc. into the program, note that you want to use the compiled release version (in the form of "opencv_gpu243.lib", 243 without D is release version, some is debug version), or it will produce " Application failed to start 0xc000007b "error;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.