CMake error: BUILD_TBB option supports Windows on ARM only - opencv

I am trying to build libraries with CMake for a vision detection system to be built in OpenCV using Visual Studio 2012's C++ compiler. After a lot of fixing of configurations, installation of Qt 5 and also Openni, I am still getting the following errors from the CMake configuration step:
Checking for Windows (Phone) Platform SDK 8.0/8.1
Checking for Visual Studio 2012/2013
WARNING, OpenNI library directory (set by OPENNI_LIB_DIR variable) is not found or does not have OpenNI libraries.
WARNING, OpenNI include directory (set by OPENNI_INCLUDE_DIR variable) is not found or does not have OpenNI include files.
WARNING, PrimeSensor Module binaries directory (set by OPENNI_PRIME_SENSOR_MODULE_BIN_DIR variable) is not found or does not have PrimeSensor Module binaries.
Looking for Mfapi.h
Looking for Mfapi.h - found
Warning at cmake/OpenCVFindIntelPerCSDK.cmake:17 (message):
Intel Perceptual Computing SDK library directory (set by INTELPERC_LIB_DIR
variable) is not found or does not have Intel Perceptual Computing SDK
libraries.
Call Stack (most recent call first):
cmake/OpenCVFindLibsVideo.cmake:291 (include)
CMakeLists.txt:482 (include)
CMake Error at 3rdparty/tbb/CMakeLists.txt:5 (message):
BUILD_TBB option supports Windows on ARM only!
Use regular official TBB build instead of the BUILD_TBB option!
Configuring incomplete, errors occurred!
See also "C:/OpenCV/opencv/lib/CMakeFiles/CMakeOutput.log".

From cmake_gui, you can quickly disable BUILD_TBB variable. If you want TBB, you have to build it separately by yourself, and then you can use this guide to activate it in OpenCV.

Related

OpenCV Crosscompile for ARM: highgui error (GTK2+)

I'm have build the OpenCV library from source for Zynq (ARM). But, OpenCV was build on the same PC for x86 (PC) also. Firstly, I can execute every example on my PC without any issues. Secondly, I am able to crosscompile and execute every program on the arm target, except the ones including highgui libraries, where I receive the following error:
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /home/hristov/workspace/opencv/modules/highgui/src/window.cpp, line 534
terminate called after throwing an instance of 'cv::Exception'
what(): /home/user/workspace/opencv/modules/highgui/src/window.cpp:534: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage
Yes, I have gone through the forum for solutions for this issue but some answers were unclear and I would like some more detail into this. I have created the OpenCV build for ARM build WITH_GTK and GTK2. Also installed libgtk2.0-dev, pkg-config
However, From another topic on this forum, I learned that the problem lies in setting up the pkg-config: http://answers.opencv.org/question/57945/opencv-gui-with-gtk-2-solved/
Q) Based on the above solution, Do you set the path for PKG_CONFIG_PATH on your ARM platform (Zynq) or on the PC platform (Ubuntu PC)? Because, it is already set to the described path on the ARM platform whereas it is different on the PC Linux platform. More details of the current path is shown below:
PKG_CONFIG_PATH in PC(Ubuntu):
/usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
PKG_CONFIG_PATH in ARM (Embedded platform):
/usr/local/lib/arm-linux-gnueabihf/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/arm-linux-gnueabihf/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
If the pkg-config must be changed on my PC, to the /usr/lib/arm-linux-gnueabihf/pkgconfig/ location, I cannot find any pkg-config in that location. Should I create a new one, by copying the folder from my target?
Q) Also, Should the GTK libraries also be installed in the Target Embedded system (ARM)?
Hope someone can help me with this solution as I have rebuild the libraries umpteen times with many different solutions, but to no avail. Thanks!

Why doesn't CLion link my project with OpenCV for Windows?

I'm attempting to use OpenCV for Windows as supplied by opencv.org in a project I'm building with JetBrains' CLion IDE. I've installed the opencv library and configured CLion (set(OpenCV_DIR) to reference the build directory under it, but CMake issues the warning:
Found OpenCV Windows Pack but it has no binaries compatible with your configuration.
You should manually point CMake variable OpenCV_DIR to your build of OpenCV library.
I've tried some of the older distributions from opencv.org with the same results. It appears CMake is locating the OpenCV libraries, but doesn't want to use them. Why, and how do I get the OpenCV libraries to work under CLion?
The short answer is, you will probably need to build OpenCV from source in order to use it with CLion. But given the number and range of partially answered and unanswered questions here* and elsewhere on using JetBrains' CLion IDE with the OpenCV library, I think an overview is needed (my notes are from CLion 2016.3 and OpenCV 3.1, YMMV):
Though not produced by JetBrains, CMake is very central to CLion's operation. Understanding CMake therefore helps greatly in diagnosing CLion build problems. In particular CMake maintains a disk "cache" of settings which you may need to clear to incorporate changes to your environment (Tools->CMake->Reset Cache and Reload Project).
To make use of OpenCV in your build you must specify it in your project's CMakeLists.txt file. You request that CMake locate your OpenCV location and link it to your TARGET. An example of a sequence of commands from CMakeLists.txt for an executable named mushroom follows:
add_executable(mushroom ${SOURCE_FILES})
FIND_PACKAGE(OpenCV REQUIRED)
TARGET_LINK_LIBRARIES(mushroom ${OpenCV_LIBS})
(For more on FIND_PACKAGE, see CMake:How To Find Libraries.)
FIND_PACKAGE for package XXX works either by way of FindXXX.cmake files located at CMake's Modules directory, or by consulting environment variable XXXX_DIR. On my system, no FindOpenCV.cmake file was present, so I relied on the OpenCV_DIR environment variable instead. This must be set, not to the root of your OpenCV installation, but to the build folder beneath it. I used an entry in CMakeLists.txt to set this variable, e.g.:
set(OpenCV_DIR C:/Users/myacct/AppData/Local/opencv-3.0.0/build)
To link with OpenCV, CMake uses either FindOpenCV.cmake or OpenCV_DIR (see previous point above) to locate a file named OpenCVConfig.cmake. This file is generated by and ships with a particular build of OpenCV in order to document what components are present and where they are located.
Problems may occur when variable names used by OpenCVConfig.cmake conflict with those CLion has stored in its environment. In particular, if your OpenCV was built by Microsoft Visual C (MSVC), as is the Windows distribution from opencv.org, it won't work with CLion.
Because CLion's build toolchain (ControlAltS-toolchain) uses either MinGW or Cygwin, OpenCVConfig.cmake will search for OpenCV binaries under a subdirectory named mingw or cygwin and will find none because the binaries were built with MSVC (it will look in a directory like vc11 or vc12 instead). This probably means you will need to build OpenCV from source in order to use it with CLion.
Would reconfiguring OpenCVConfig.cmake to point to the MSVC binaries make this work? you may ask. Unfortunately the answer is still no, because libraries built with one compiler typically cannot be linked with another one.
OpenCVConfig.cmake or FindOpenCV.cmake likely contain diagnostic messages, but when CLion executes CMake for you, message(STATUS) calls are not displayed. To make them display, change them to message(WARNING) or message(FATAL_ERROR). But CLion 2016.3 EAP relieves this problem; see https://stackoverflow.com/a/39398373/5025060.
CLion does not indicate which .cmake script issued which diagnostics; don't assume they all come from the same script.
Hopefully this provides some general guidance on resolving CLion / CMake / OpenCV compatibility problems. Note that this does not cover compiler or linker issues; these will not appear until CMake completes its initial makefile build. Compiler or linker issues occur at a later stage and are controlled by include*(), link*() and other commands in CMakeLists.txt.
*Some related SO questions:
OpenCV Windows setup with CLion
OpenCV CLion (Cmake) linking issue - cmake reports a strange error
use OpenCV with Clion IDE on Windows
Compiling OpenCV on Windows with MinGW
Could not find module FindOpenCV.cmake ( Error in configuration process)
CMake: Of what use is find_package() if you need to specify CMAKE_MODULE_PATH anyway?

Error configuring OpenCV project with CMake on Windows

I used the prebuilt OpenCV 3.0.0 version. It works when I create a Visual Studio project directly, and when I add include and library directories.
Now I am making a CMakeList.txt file (so that I can run the same code on different systems). It will be used to create the Visual Studio project on Windows, and Makefile on Unixes, etc.
cmake_minimum_required(VERSION 2.8)
project( Facade )
find_package( OpenCV REQUIRED )
add_executable( Facade grammar.cpp )
target_link_libraries( Facade ${OpenCV_LIBS} )
When I generate the Visual Studio file on Windows, I got the following error:
CMake Warning at C:/opencv/build/OpenCVConfig.cmake:166 (message):
Found OpenCV Windows Pack but it has no binaries compatible with your
configuration.
You should manually point CMake variable OpenCV_DIR to your build of OpenCV
library.
Call Stack (most recent call first):
CMakeLists.txt:3 (find_package)
CMake Error at CMakeLists.txt:3 (find_package):
Found package configuration file:
C:/opencv/build/OpenCVConfig.cmake
but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be
NOT FOUND.
Currently, OpenCV_DIR is C:\opencv\build, where it holds the CMake files. If I point OpenCV_DIR to C:\opencv\build\x64\vc12, it says, can't find CMake files.
How do I fix this?
What generator string did you use for the CMake configuration step? For VC12 x64, you need to use -G "Visual Studio 12 Win64" (if you were using CMake 3, you would use -G "Visual Studio 12 2013 Win64"). Note that you need to include Win64 at the end to get the x64 platform.
It is rather convenient that the OpenCV CMake config script is checking to make sure you are using the x64 binaries. You configured CMake to build 32-bit binaries, which would cause a runtime error if you were able to get an executable built.
Just in case anybody else has this problem, I got it from using old CMake config scripts. With VS2017 installed, I was getting this error- turns out that some auto-generated CMAKE configs have something like this:
elseif(MSVC_VERSION EQUAL 1910)
set(OpenCV_RUNTIME vc15)
I checked MSVC_VERSION and it was 1916, which is still VC15, but the files erroneously missed that. I changed to:
elseif((MSVC_VERSION EQUAL 1910) OR (MSVC_VERSION GREATER 1910))
set(OpenCV_RUNTIME vc15)
and it worked like a charm.

OpenCV 2.4.9 and CUDA 6.5

I recently upgraded to CUDA 6.5, and I recompiled succefully OpenCV 2.4.9 on Ubuntu 14.04.
However when I recompiled my project using OpenCV and cmake, I got the following configuration error:
-- GCC detected, adding compile flags
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find CUDA: Found unsuitable version "6.5", but required is exact
version "6.0" (found /usr/local/cuda-6.5)
Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:313 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-2.8/Modules/FindCUDA.cmake:806 (find_package_handle_standard_args)
/usr/local/share/OpenCV/OpenCVConfig.cmake:215 (find_package)
CMakeLists.txt:9 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/andrey/Data/Projects/Groups_code/Lulu/build-Ubuntu/CMakeFiles/CMakeOutput.log".
How to fix this one? Do I need to reinstall cmake, or upgrade Modules file in cmake?
Try delete cmake cache.
"File"->"Delete Cache". Then "Configure" , "Generate" as usual.
In my experience, when OpenCV is built with a certain version of CUDA it specifies that in the file /usr/local/share/OpenCV/OpenCVConfig.cmake. If you have changed your version of CUDA after you built OpenCV then rebuilding OpenCV with the new CUDA version should fix this. That will basically rewrite the new version to /usr/local/share/OpenCV/OpenCVConfig.cmake.
In addition, it seems that you are calling find_package(CUDA) after calling find_package(OpenCV). That enforces cmake to look for the version of CUDA with which OpenCV was built. If you call find_package(CUDA) before find_package(OpenCV) you will likely see something like:
-- Found CUDA: /usr/local/cuda-6.5 (found version "6.5")
CMake Error at /usr/local/share/OpenCV/OpenCVConfig.cmake:222 (message):
OpenCV static library was compiled with CUDA 6.0 support. Please, use the
same version or rebuild OpenCV with CUDA 6.5
Call Stack (most recent call first):
CMakeLists.txt:49 (find_package)
OpenCV source has been changing over the years with different versions of CUDA and so a version mismatch there can cause things to break. So the recommended way to fix this is to rebuild OpenCV.

How to find in CMAKE file if OpenCV is compiled with CUDA

i am using opencv with another library. So i would like to compile a class if OpenCV has CUDA.
i need to acheive this in Cmake file. But i cannot find any variable that tells whether OpenCV
has CUDA or not.
FindOpenCV.cmake defines these variables
OpenCV_FOUND
OpenCV_LIBS
OpenCV_INCLUDE_DIR
OpenCV_VERSION
now how can i find out if OpenCV is compiled with CUDA or not from this cmake file?
Here is the list of CMake variables, that can help you:
OpenCV_COMPUTE_CAPABILITIES - compute capability from which OpenCV has been compiled, can be added to nvcc flags.
list(APPEND CUDA_NVCC_FLAGS ${OpenCV_COMPUTE_CAPABILITIES})
OpenCV_CUDA_VERSION - CUDA toolkit version which was used to build OpenCV, if OpenCV was built without CUDA support, the variable is empty. You can check this variable:
if(OpenCV_CUDA_VERSION)
# Have CUDA support
endif()
OpenCV_USE_CUBLAS - true if OpenCV was built with CUBLAS support
OpenCV_USE_CUFFT - true if OpenCV was built with CUFFT support
OpenCV_USE_NVCUVID - true if OpenCV was built with NVCUVID support

Resources