building opencv with sfm module issues - opencv

I am trying to build opencv with sfm modules I've built and installed gflags then glog and the ceres-solver. Yet the make logs says: Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags. Even though in earlier lines it says it finds both to these directories.
I've also built and installed VTK though for some reason it doesn't find it even when I manually select the build directory.
Below is the relevant section of my CMake log:
VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
OpenCV Python: during development append to PYTHONPATH: C:/DEV/opencv-4.2.0/builds/python_loader
Caffe: NO
Protobuf: NO
Glog: YES
freetype2: NO
harfbuzz: NO
Module opencv_ovis disabled because OGRE3D was not found
No preference for use of exported gflags CMake configuration set, and no hints for include/library directories provided. Defaulting to preferring an installed/exported gflags CMake configuration if available.
Found installed version of gflags: C:/Program Files (x86)/gflags/lib/cmake/gflags
Detected gflags version: 2.2.2
Checking SFM deps... FALSE
Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags

I managed to get the SFM module to compile finally. I am not 100% on what fixed it but here is what I did: I deleted all versions of gflags, glog, and ceres-solver. I downloaded a slightly older version of ceres-solver (1.14) and VTK (8.2.0). The earlier versions might be related to using opencv4.2 and python 3.7.
I placed gflags and glog in the ceres-solver folder with eigen. Then using CMake and visual studio 2019 I built and installed gflags in debug and release. glog (linking to gflags) only in release. Finally, I built and installed ceres-solver linking to glog, gflags and eigen. Following this tutorial: http://sylvain.duchene.im/how-to-build-ceres-under-windows/
Then when I used CMake to build openCV4.2 with the contribs libraries I found both the sfm module and VTK.

Related

CMake fails to find OpenCV installed via vcpkg under wsl (returns opencv for Windows Conda Environment)

So I am currently trying to get my CMake Project to build after installing packages via vcpkg for the first time.
I am using WSL2 under Win10 with Ubuntu 20.04 for the project, but building throws the following:
philip#DESKTOP-2CHKCMO:/mnt/c/Users/phili/_Documents/Projects/pixelator$ cmake .
-- OpenCV ARCH:
-- OpenCV RUNTIME:
-- OpenCV STATIC: ON
CMake Warning at /mnt/c/Users/phili/anaconda3/Library/opencvConfig.cmake:140 (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:13 (find_package)
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/c/Users/phili/_Documents/Projects/pixelator
This is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.16)
project(pixelator LANGUAGES CXX)
#include("~/vcpkg/scripts/buildsystems/vcpkg.cmake")
set(CMAKE_TOOLCHAIN_FILE "~/vcpkg/scripts/buildsystems/vcpkg.cmake")
set(OpenCV_DIR "~/vcpkg/packages/opencv4_x64-linux/share/opencv")
find_package(protobuf CONFIG REQUIRED)
find_package(opencv CONFIG REQUIRED)
find_package(gflags CONFIG REQUIRED)
add_library(pixeling ${CMAKE_SOURCE_DIR}/source/pixeling.cpp)
target_link_libraries(pixeling ${OpenCV_LIBS})
add_executable(io ${CMAKE_SOURCE_DIR}/source/io.cpp)
target_link_libraries(io pixeling gflags)
The Folder is located in Windows10, but I am building via Ubuntu.
Apparently CMake seems to ignore that I set the OpenCV_DIR and returns an openCV installation for my python anaconda environment (which is not located in wsl, but Windows), which it can't use. Also, I was under the impression that I would not even be required to set the OpenCV_DIR after linking the Toolchain file?
How do I get it to find the right openCV installation?

What is the proper way of adding a local dependency (openCV) in Meson?

I am using OpenCV in one of my projects. Until now, I was using version 3 under Ubuntu 18.04, so in my meson.build I had:
... dependencies: [dependency('opencv')])
Now, I've compiled OpenCV 4 from source and installed to the default dir, /usr/local/, and changed my meson.build to:
... dependencies: [dependency('opencv4')])
Resulting in a not found error (despite this works with Ubuntu 20.04 and the package from the official repos, which is version 4.2). How should I specify the library's location so Meson can find it?
I've seen find_library, but that's deprecated according the docs.
The dependency function is using pkg-config or cmake if pkg-config fails, to find external dependency (installed library).
When you install OpenCV4, please check if there is pkg-config for opencv4. Here is my command:
pkg-config --list-all | grep "opencv4"
and output:
opencv4 OpenCV - Open Source Computer Vision Library
Also, check PKG_CONFIG_PATH environment variable. pkg-config will use that path to search for .pc files.
Edit:
be sure to use -D OPENCV_GENERATE_PKGCONFIG=YES when building opencv with cmake.

Compiling OpenCV-contrib for IOS (especially the SFM-Module)

I've tried to install openCV_contrib for IOS, therefore I execute
python opencv/platforms/ios/build_framework.py "framework_dest"
on my Mac (I need Xcode for compiling openCV for IOS) but all the times, i got the message:
-- Checking SFM deps... FALSE
-- Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags
I need the SFM module, hence I tried installing Glog and Gflags at several ways: using
brew install glog gflags
and brew outputs, that those packages are successfully installed respective already installed.
Later I tried to compile both from GitHub on my own, but with no success, I'm still not able to compile SFM for IOS.
On Linux I could compile openCV including the SFM module, but I can't compile it for IOS, because Xcode is not available for Linux.
I don't know, what to do! Do some of you know how to install glog/gflags on Mac or do you know how to build the IOS-Framework of OpenCV on Linux or maybe how to build the IOS-Framework on my Mac using the binaries created with cmake .. && make in my Linux (because there SFM is compiled)?
There have to be some solution, because Mac is based on Linux, so if it works on Linux, why doesn't it work on my Mac?!
Thanks!

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.

CMake error: BUILD_TBB option supports Windows on ARM only

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.

Resources