How to build OpenCV 4.5 from source on RaspberryPi 4? - c++

I am trying to compile the OpenCV 4.5 library from source on a fresh install of Raspian and I'm running into a problem regarding the C++ standard. After running the cmake command from the build dir, in order to obtain the required makefiles, I get prompted with the message "OpenCV 4.X requires c++11. I tried modifying the CMakeLists.txt adding the set(CMAKE_CXX_STANDARD 11) and also adfding a building flag using the -D CMAKE_CXX_FLAGS='-std=c++11' option but without luck. All options available here: cmake build command + flags I'm not sure how I could get past this and I could use some advice if someone encountered it before, any suggestions? TIA 😃

Related

Cmake doesn't find boost windows

I'm trying to run this code:
https://github.com/snukky/news-translit-nmt
I've installed boost and got the following messages:
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
C:\Program Files\boost\boost_1_67_0
The following directory should be added to linker library paths:
C:\Program Files\boost\boost_1_67_0\stage\lib
By the comment of #kenba I've added the following environment variables:
Try 1
When I try to run the following cmd:
cmake .. -DCMAKE_BUILD_TYPE=Release
I get:
-- Could NOT find Boost (missing: timer iostreams filesystem system chrono) (found version "1.67.0")
CMake Error at CMakeLists.txt:290 (message):
Cannot find Boost libraries. Terminating.
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Configuring incomplete, errors occurred!
See also "D:/ThesisResources/previous_works/news-translit-nmt-master/tools/marian-dev/build/CMakeFiles/CMakeOutput.log".
Try 2
When I try to give a custom boost by this ref
https://marian-nmt.github.io/docs/#custom-boost:
I run the following cmd:
cmake .. -DBOOST_ROOT="C:\Program Files\boost\boost_1_67_0"
I get the same error.
I've also tried working with Linux WSL (But problems with CUDA installation overthere, their team is working on it), Linux VirtualBox (Not enough resources), and Ubuntu 17.10 I have installed (But Cuda requires Ubuntu 16.04 / 18.04)
What am I missing here? I'm trying any suggestion, stuck on it for a few days. Thanks!
Edit:
I reinstalled Ubuntu 16.04 and the problem was solved. Still don't know how to solve it in windows, but i'll continue use Ubuntu 16.04.
I had this problem earlier while trying to build the Windows version of Marian NMT (the same component that you're having trouble with). I can't remember the exact steps to solve the problem, but the root cause is that the Marian NMT build for Windows does not work with newer versions of Boost, since the source code uses some deprecated calling conventions for timer and chrono libraries (maybe some others as well).
The error message kind of confirms this: it can't find Boost, but on the other hand it says it finds your version 1.67.0. The solution is to use an older version of boost, I've confirmed that it works with 1.60.0.
If you just require a Marian NMT decoder that works in Windows, a project I work on has released a plugin for the Trados Studio translation tool, which contains a compiled marian-decoder executable for Windows: https://object.pouta.csc.fi/fiskmo/TradosStudio/FiskmoTranslationProvider.sdlplugin. You can access the executable by unzipping the sdlplugin file, the StartMtPipe.bat shows how to use the decoder.

How to use compiled wxwidgets with cmake

I'm getting some trouble while trying to use wxwidgets in my project (I'm on linux). It worked well when I was with wxWidget 3.02, but when I tried to use 3.1.0 it stopped to work.
I still have the 3.0.2 (so I can have something working) but I want to use the wxlistctrl::EnableCheckBoxes(), so I get the 3.1.0.
In my CMakeList, I change FIND_PACKAGE(wxWidgets REQUIRED)to FIND_PACKAGE(wxWidgets 3.1.0 REQUIRED)
When i try to cmake ..in my build directory, I got the following error:
... could NOT find wxWidgets: Found unsuitable version "3.0.2", but required is
at least `3.1.0`(found
-L/usr/local/lib//lib/x86_64-linux-gnu; ...
I know that the library is located at /usr/local/lib I tried to ln to the directory, I tried many commands in my cmake, but I don't know how to tell cmake to search in the good library to find th wxWidgets version I want.
I'm pretty sure it's a cmake mistake, but it can be an installation problem too (even if I followed the tutorial here). More, when I type gtk-config --versionI got "3.1.1" (that's what I expected as version number, I get the git version)
If anyone has a question or an idea to solve my problem, I would be haappy to read it =)
Thank's!
CMake saying that your minumum version of cmake, 3.0.2, is lower than the wxWidgets minimum cmake version, 3.1.0.
Try putting the command: cmake_minimum_required(VERSION 3.1.0).
That way your minimum cmake version required will be 3.1.0 so it will be fine.

build opencv with extra modules error ocv_download

I try to build openCV with Extramodules. If I try to configure the projectfiles (vc14 x32 on windows 10) with cmake there's the error:
CMake Error at opencv_contrib-master/modules/xfeatures2d/cmake/download_vgg.cmake:13 (ocv_download):
Unknown CMake command "ocv_download".
Did anyone ever have this problem and knows how to solve it?
The simple answer is you are using incompatible versions of opencv and opencv_contrib, you might be installing current version of opencv_contrib on maybe opencv2.4.xx
Well, the download link for opencv contrib in CMake script https://raw.githubusercontent.com/opencv/opencv_3rdparty/fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d now is 400: Invalid request.
From the commit https://github.com/opencv/opencv_contrib/commit/593e78c5d084aa0a29eb1e0459fc7f7a4dd52ea8 you can try to ignore the added line in CMakeLists include(cmake/download_vgg.cmake) and rebuild.
The below is basing on my experience, I'm not sure it will works for OpenCV 3.0.
Maybe you can try to clone opencv contrib from git, then copy it to somewhere (for example modules directory in opencv source code). Then use CMAKE to set OPENCV_EXTRA_MODULES_PATH. If the hash is correct then it won't download and use the offline package.
I have try and build success OpenCV 2.x with IPP.
Hope it help.
Just follow instructions here.
Make sure you have active internet connection while building Opencv with contrib module.
When you hit config button on cmake(gui), it downloads other files like
vgg_generated_...
boostdesc_binboost_...
boostdesc_lbgm.i
P.S: i compiled Opencv 3.1 with contrib. Cmake downloaded required files & configure was Done.

Can I use biicode for C++ on ubuntu 14.04 with Cmake 2.8.12.2?

I just downloaded biicode and tried to follow the getting started instructions but received an error about the Cmake 3.0 or higher being required.
However, ubuntu 14.4 uses "cmake version 2.8.12.2"
Is there a way to use biicode with 2.8 or am I stuck installing the newer version of CMake?
TIA!
No, biicode requires cmake > 3.0. There is a setup command that helps installing it:
$ bii setup:cpp
This will install CMake >3.0 in /home/user/biicode_env, and add it to the path, so it doesnt interfere/overwrite your current 2.8 installation. Biicode needs that executing "cmake" in the console actually uses 3.0, so it should be first in the path. You can manage it very easily in two different ways, with a symbolic link (/usr/bin) that you redirect as needed or adding/removing an entry in the path before executing biicode.
This is a different thing, but I woiuld like to say that I have migrated existing projects from cmake 2.8 to 3.0 without any problems, and 3.0 runs great and has useful new features. So I would recommend regular cmake users to upgrade if possible.
No, there isn't any way to change this requirement because internal biicode CMake has features, like the use of INTERFACE libraries, which are only available on CMake 3.0 or later. However, don't worry about upgrading CMake version, this one always keeps a exhaustive compatibility with older versions ;)

Qt + VTK + Cmake

I'm running OSX 10.6 (Snow Leopard), Qt 4.6, VTK 5.4, and Cmake 2.8. I installed Qt, then VTK and Cmake. I configured VTK to use QT 4.6 (turned on VTK_USE_GUISUPPORT and VTK_USE_QVTK). The configuration and installation worked painlessly but if I run Cmake with Qt references the compilation fails during the subsequent make process because of failed dependency resolution.
As an example, I tried to build the Qt ImageViewer example (VTK/Examples/GUI/Qt/ImageViewer) and it failed to find qapplication.h (and all other qt headers). Any ideas about why this might be happening would be greatly appreciated!
CMake finds Qt by looking for qmake (ironic, eh?). Make sure qmake is in your path.
Also, make sure VTK and Qt 4.6 were compiled with the same version of gcc/g++. Weird runtime errors (like cout not working) can result.
First you should set DESIRED_QT_VERSION to 4. When it's ready, you could chose QT_QMAKE_EXECUTABLE to your qmake binary.
I find that the CMakeCache.txt in your build folder for cmake tends to have all the necessary diagnostics info for stuff like this. Almost certainly there's a string field for the include path that is blank right now due to not being found.