I am trying to get this running https://github.com/Katou2/Optical_Flow_GPU_Opencv3 but am facing an issue where make does not detect my opencv_contrib module. Here are the steps that I have done up till cmake.
conda create -n opticalflow python=3.6 anaconda
conda activate opticalflow
git clone https://github.com/Katou2/Optical_Flow_GPU_Opencv3
cd Optical_Flow_GPU_Opencv3
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -D BUILD_TIFF=ON ..
And this is the output that I get with no error.
-- version: 4.2.0
-- OPENCV include: /home/haziq/anaconda3/pkgs/libopencv-4.2.0-py36_3/include/opencv4
-- OPENCV libs dir:
-- OPENCV libs: opencv_calib3dopencv_coreopencv_dnnopencv_features2dopencv_flannopencv_gapiopencv_highguiopencv_imgcodecsopencv_imgprocopencv_mlopencv_objdetectopencv_photoopencv_stitchingopencv_videoopencv_videoioopencv_arucoopencv_bgsegmopencv_bioinspiredopencv_ccalibopencv_cvvopencv_datasetsopencv_dnn_objdetectopencv_dnn_superresopencv_dpmopencv_faceopencv_freetypeopencv_fuzzyopencv_hdfopencv_hfsopencv_img_hashopencv_line_descriptoropencv_optflowopencv_phase_unwrappingopencv_plotopencv_qualityopencv_regopencv_rgbdopencv_saliencyopencv_shapeopencv_stereoopencv_structured_lightopencv_superresopencv_surface_matchingopencv_textopencv_trackingopencv_videostabopencv_xfeatures2dopencv_ximgprocopencv_xobjdetectopencv_xphoto
-- Configuring done
-- Generating done
-- Build files have been written to: /home/haziq/Optical_Flow_GPU_Opencv3/build
The problem comes when I run make.
Scanning dependencies of target compute_flow_autogen
[ 25%] Automatic MOC for target compute_flow
[ 25%] Built target compute_flow_autogen
Scanning dependencies of target compute_flow
[ 50%] Building CXX object CMakeFiles/compute_flow.dir/compute_flow.o
/home/haziq/Optical_Flow_GPU_Opencv3/compute_flow.cpp:38:10: fatal error: opencv2/cudaoptflow.hpp: No such file or directory
#include "opencv2/cudaoptflow.hpp"
^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/compute_flow.dir/build.make:62: recipe for target 'CMakeFiles/compute_flow.dir/compute_flow.o' failed
make[2]: *** [CMakeFiles/compute_flow.dir/compute_flow.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/compute_flow.dir/all' failed
make[1]: *** [CMakeFiles/compute_flow.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
So the error mentions that the file opencv2/cudaoptflow.hpp is not found and I read through https://github.com/open-mmlab/mmaction/issues/39 says that the error is due to the opencv_contrib module not having been installed. However, I am certain that I already have opencv_contrib installed because I have this command executed.
pip install opencv-contrib-python
and have also verified it as I am able to call the cv2.xfeatures2d method which requires opencv_contrib to run.
import cv2
help(cv2.xfeatures2d) # cv2.xfeatures2d requires opencv_contrib
I am new to cmake though not to make. This question is different from Could not build OpenCV Android sample project since that other question is about a single project and this one is looking at the overall CMakeLists.txt.
Speaking of which: consider the CMakeLists.txt in ${OPENCVDIR}/samples :
I followed basic process for cmake:
cd "${OPENCVDIR}/samples"
mkdir build
cd build
cmake ..
But at the last step I have:
$ cmake ..
CMake Error at CMakeLists.txt:72 (find_package):
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "/git/opencv/samples/CMakeFiles/CMakeOutput.log".
Line 72 has this: find_package(OpenCV REQUIRED PATHS "..")
I looked at the error log and it was not informative.
Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out"
The CXX compiler identification is GNU, found in "/git/opencv/samples/CMakeFiles/3.13.4/CompilerIdCXX/a.out"
Determining if the C compiler works passed with the following output:
Change Dir: /git/opencv/samples/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_26f76/fast"
/usr/bin/make -f CMakeFiles/cmTC_26f76.dir/build.make CMakeFiles/cmTC_26f76.dir/build
make[1]: Entering directory '/git/opencv/samples/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_26f76.dir/testCCompiler.c.o
/usr/bin/cc -o CMakeFiles/cmTC_26f76.dir/testCCompiler.c.o -c /git/opencv/samples/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_26f76
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_26f76.dir/link.txt --verbose=1
/usr/bin/cc -rdynamic CMakeFiles/cmTC_26f76.dir/testCCompiler.c.o -o cmTC_26f76
make[1]: Leaving directory '/git/opencv/samples/CMakeFiles/CMakeTmp'
Detecting C compiler ABI info compiled with the following output:
"/git/opencv/samples/CMakeFiles/CMakeOutput.log" 706 lines, 48095 characters
Feature record: CXX_FEATURE:0cxx_defaulted_move_initializers
Feature record: CXX_FEATURE:0cxx_delegating_constructors
Feature record: CXX_FEATURE:0cxx_deleted_functions
Feature record: CXX_FEATURE:0cxx_digit_separators
Feature record: CXX_FEATURE:0cxx_enum_forward_declarations
Feature record: CXX_FEATURE:0cxx_explicit_conversions
Feature record: CXX_FEATURE:0cxx_extended_friend_declar
etc ..
What is the correct way to build these examples - hopefully using the CMakeLists.txt already provided?
It seems the installation directory of OpenCV couldn't be found by cmake. Try to provide the value through the argument:
cmake -DCMAKE_PREFIX_PATH=/home/someone/src/opencv/install ..
Ff it works, you could define this in the top-level CMakeLitst.txt:
list(APPEND CMAKE_PREFIX_PATH /home/someone/src/opencv/install)
This should provide CMake the place where it should look to.
$ opencv_version
3.4.16
$ cd OpenCV/samples/
$ cmake -B build
$ cmake --build build
JPEG display
$ build/cpp/example_cpp_image data/lena.jpg
USB camera capture
$ build/cpp/example_cpp_videocapture_basic
$ build/cpp/example_cpp_videocapture_camera
Recognition by AI
$ build/tapi/example_tapi_hog
I am trying to compile Opencv on Ubuntu 18.04. I installed many dependencies packages but when I run make I get the error:
grfmt_jpeg2000.cpp:59:10: fatal error: jasper/jasper.h: No such file or directory
#include <jasper/jasper.h>
^~~~~~~~~~~~~~~~~
compilation terminated.
I had already jasper installed and installed libjasperreports-java. However the file jasper.h cannot still be found in my system. Is there any library I can install with apt install to get that file? Or am I missing any other library?
EDIT 1
I tried also downloading the opencv_contrib to install extra moduels of openCV but first of all jaspar is not present and secondly setting the build with
cmake -D CMAKE_INSTALL_PREFIX=./ -D CMAKE_BUILD_TYPE=Debug -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ../openCV
returns the error:
Make Error at cmake/OpenCVModule.cmake:352 (message):
Duplicated modules NAMES has been found
while CMakeError.log contains many errors of the type:
Build output check failed:
Regex: 'command line option .* is valid for .* but not for C\+\+'
Output line: 'cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++'
I have just started exploring NiftyNet.I am getting the following error when I try to run the autocontext_mr_ct_model_zoo.
When I run the following command:
python net_regress.py train \ -c ~/niftynet/extensions/autocontext_mr_ct/net_autocontext.ini \
--starting_iter 0 --max_iter 500*
I get the following error message:
ValueError: Unknown keywords in config file: [error_map] -- all possible choices are ['', u'loss_border', 'output', 'image', 'weight', 'sampler', u'cuda_devices', u'num_threads', u'num_gpus', u'model_dir', u'dataset_split_file', u'name', u'activation_function', u'batch_size', u'decay', u'reg_type', u'volume_padding_size', u'window_sampling', u'queue_length', u'multimod_foreground_type', u'histogram_ref_file', u'norm_type', u'cutoff', u'foreground_type', u'normalisation', u'whitening', u'normalise_foreground_only', u'weight_initializer', u'bias_initializer', u'weight_initializer_args', u'bias_initializer_args', u'optimiser', u'sample_per_volume', u'rotation_angle', u'rotation_angle_x', u'rotation_angle_y', u'rotation_angle_z', u'scaling_percentage', u'random_flipping_axes', u'lr', u'loss_type', u'starting_iter', u'save_every_n', u'tensorboard_every_n', u'max_iter', u'max_checkpoints', u'validation_every_n', u'validation_max_iter', u'exclude_fraction_for_validation', u'exclude_fraction_for_inference', u'inference_iter', u'save_seg_dir', u'output_interp_order', u'border', u'csv_file', u'path_to_search', u'filename_contains', u'filename_not_contains', u'interp_order', u'pixdim', u'axcodes', u'spatial_window_size'].
I'm not quite sure what I've messed up here, any advice welcomed.
Looks like the source code you downloaded is out-of-date, are you running the command with the latest version of NiftyNet?
The pip package is slightly out-of-date at the moment,
you could have the latest source code by running
git clone https://github.com/NifTK/NiftyNet.git
# installing dependencies from the list of requirements
cd NiftyNet/
pip install -r requirements-gpu.txt
# run command from the source code folder
python net_regress.py train \
-c ~/niftynet/extensions/autocontext_mr_ct/net_autocontext.ini \
--starting_iter 0 --max_iter 500
I am trying to install OpenCV3.1 on my Ubuntu 16.04 for development in QT5. Sadly, building it from source always errors out due to undefined references (see below).
I used the following:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_FFMPEG=ON -D WITH_OPENGL=ON -D BUILD_TIFF=ON -D WITH_VTK=ON..
And it works fine. But building it always produces this error
../../lib/libopencv_viz.so.3.1.0: undefined reference to `vtkSTLReader::New()'
../../lib/libopencv_viz.so.3.1.0: undefined reference to `vtkOBJReader::New()'
collect2: error: ld returned 1 exit status
modules/viz/CMakeFiles/opencv_test_viz.dir/build.make:232: recipe for target 'bin/opencv_test_viz' failed
make[2]: *** [bin/opencv_test_viz] Error 1
CMakeFiles/Makefile2:3358: recipe for target 'modules/viz/CMakeFiles/opencv_test_viz.dir/all' failed
make[1]: *** [modules/viz/CMakeFiles/opencv_test_viz.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Of course I googled and tried everything I found. Tried several different cmake flags (or rather, without any), tried reinstalling libvtk5-dev and also tried libvtk6-dev and even build vtk7.1 from source, since I am assuming something is missing from there.
I also tried adding the opencv_contrib via
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_FFMPEG=ON -D WITH_OPENGL=ON -D BUILD_TIFF=ON -D WITH_VTK=ON -D BUILD_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=/home/user/opencv/opencv-3.1.0/opencv_contrib/modules ..
But that already produced the following error
CMake Error at opencv_contrib/modules/text/CMakeLists.txt:22 (ocv_add_testdata): `Unknown CMake command "ocv_add_testdata".
Also please note that I did upgrade/update all the packages that are listed here and here
So basically after two days randomly trying all the possible solutions I could find via google, I am now asking here.
Hopefully someone knows how to fix this, thank you!
Edit: I only get these problems with OpenCV3.1. I do have a working OpenCV 2.4.13
Same happend with me. It was working and suddenly I got the same error. I re-pulled OpenCV 3.1 and it worked again.
It seems that the guys updated something both in Extra Modules and in OpenCV and you have just pull the extra modules.
For the second part, it looks like someone messed up the opencv_contrib/modules/text/CMakeLists.txt
Just edit this file and remove the lines at the end:
ocv_add_testdata(samples/ contrib/text
FILES_MATCHING PATTERN "*.xml" PATTERN "*.xml.gz" REGEX "scenetext[0-9]+.jpg"
COMPONENT "tests"
)
just switch opencv_contrib repository to 3.1.0 tag after clone.
git checkout 3.1.0
and try to build again.
First, make sure you have successfully built and installed vtk on your system;
Then,by using command "locate STLReader" or "locate vtkOBJReader" to ensure "vtkOBJReader" or "STLReader" libs are found in some specific directories. If vtkOBJReader or STLReader related files are found. It means that vtk has changed its structure in the new version, e.g. move vtkOBJReader into a sub library vtkIOGeometry, so you have to tell cmake to find vtkIOGeometry if you want to use that class.
Last, modify opencv3/cmake/OpenCVDetectVTK.cmake, for every find_package(VTK QUIET COMPONENTS ... add an entry vtkIOGeometry.
Success!