Having problems building OpenCV 2.0 on CentOS 5? - opencv

I'd been trying to install OpenCV library to my centos system however when i type make and hit enter after configuring with cmake, i get the following error:
[100%] Building CXX object tests/cv/CMakeFiles/cvtest.dir/src/amoments.o
[100%] Building CXX object tests/cv/CMakeFiles/cvtest.dir/src/affine3d_estimator.o
[100%] Building CXX object tests/cv/CMakeFiles/cvtest.dir/src/acontours.o
[100%] Building CXX object tests/cv/CMakeFiles/cvtest.dir/src/areprojectImageTo3D.o
Linking CXX executable ../../bin/cvtest
CMakeFiles/cvtest.dir/src/highguitest.o: In function `CV_HighGuiTest::run(int)':
highguitest.cpp:(.text._ZN14CV_HighGuiTest3runEi+0x15): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
[100%] Built target cvtest
make: *** [all] Error 2
and interesting, once i got this error:
[ 99%] Built target mltest
[ 99%] Generating generated0.i
Traceback (most recent call last):
File "/home/proje/OpenCV-2.1.0/interfaces/python/gen.py", line 43, in ?
if True in has_init and not all(has_init[has_init.index(True):]):
NameError: name 'all' is not defined
make[2]: *** [interfaces/python/generated0.i] Error 1
make[1]: *** [interfaces/python/CMakeFiles/cvpy.dir/all] Error 2
make: *** [all] Error 2
What possibly is the cause of these errors? I need to install opencv immediately on this computer.

I had this problem.. It's the Python Interface...
By Default, Python 2.4 is installed on CentOS, and ot's not easy to upgrade to >2.6.
When OpenCV builds, it is confused by the Python version...
So I've disable the Python interface on "cmake" and it was OK.
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=NO ..
But, of course you can not use OpenCV with Python anymore.

The Python function all() was introduced with version 2.5. You are probably compiling with a version where all() does not exist in the Python language yet.
According to the Python Built-in Functions List, all() is equivalent to:
def all(iterable):
for element in iterable:
if not element:
return False
return True
You may also need to define any(). It is the equivalent of:
def any(iterable):
for element in iterable:
if element:
return True
return False
More than likely though, if the setup script requires Python 2.5, so will the rest of the Python wrapper.

Related

When trying to build Halide on Linux system with llvm-10.0 on release/10.x and master branches, facing the below issue

[ 53%] Linking CXX executable test_function_dag
/bin/ld: ../../libHalide.so.10.0.0: undefined reference to `typeinfo for llvm::SectionMemoryManager'
collect2: error: ld returned 1 exit status
make[2]: *** [src/autoschedulers/adams2019/CMakeFiles/test_function_dag.dir/build.make:134: src/autoschedulers/adams2019/test_function_dag] Error 1
make[1]: *** [CMakeFiles/Makefile2:2328: src/autoschedulers/adams2019/CMakeFiles/test_function_dag.dir/all] Error 2
make: *** [Makefile:182: all] Error 2
I'm using pre-built LLVM binaries and below cmake command to configure
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_DIR=/home/harry/llvm/lib/cmake/llvm ../
Any advice and suggestions will be greatly appreciated.
I cloned Halide from release/10.x, and compiled against the LLVM 10.0.0 binaries obtained here. On Ubuntu 20.04 LTS, I had to also apt install libtinfo5 because these binaries are built against old system libraries.
I noticed that the official binaries are not built with RTTI enabled (ugh) and was able to repro and fix. There's a bug in dependencies/llvm/CMakeLists.txt. Find the line that reads:
$<$<COMPILE_LANG_AND_ID:CXX,GCC,Clang,AppleClang>:-fno-rtti>)
and change GCC to GNU. We don't test with non-RTTI LLVM, which is why this wasn't caught.

namespace SIFT error in making opencv and opencv_contrib 4.3.0 (under ubuntu)

the error broke during the make period
this is the procedure before the error came out
1.download the source code from github of opencv and opencv_contrib 4.3.0
2.creat a dir under opencv source code dir name opencv_contrib
3.enter the build dir and enter the code
cmake -D CMAKE_INSTALL_PREFIX=/usr/local -D CMAKE_BUILD_TYPE=Release -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ..
some of the files to download while cmake didn't download but I manually download those and all of the fail-to-download files are copied to the required route
then begin to make
make -j7
error break while making
Scanning dependencies of target opencv_test_xfeatures2d
[ 90%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/test/test_detectors.cpp.o
[ 90%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/internal/gapi_transactions_test.cpp.o
[ 90%] Building CXX object modules/gapi/CMakeFiles/opencv_test_gapi.dir/test/own/conc_queue_tests.cpp.o
[ 90%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/test/test_features2d.cpp.o
[ 90%] Building CXX object modules/xfeatures2d/CMakeFiles/opencv_perf_xfeatures2d.dir/perf/perf_surf.ocl.cpp.o
/home/wang/Documents/opencv-4.3.0/opencv_contrib/modules/xfeatures2d/test/test_features2d.cpp: In member function ‘virtual void opencv_test::{anonymous}::Features2d_SIFTHomographyTest_regression_Test::Body()’:
/home/wang/Documents/opencv-4.3.0/opencv_contrib/modules/xfeatures2d/test/test_features2d.cpp:366:88: error: ‘SIFT’ has not been declared
TEST(Features2d_SIFTHomographyTest, regression) { CV_DetectPlanarTest test("SIFT", 80, SIFT::create()); test.safe_run(); }
^~~~
/home/wang/Documents/opencv-4.3.0/opencv_contrib/modules/xfeatures2d/test/test_features2d.cpp: In member function ‘virtual void opencv_test::{anonymous}::Features2d_SIFT_using_mask_regression_Test::Body()’:
/home/wang/Documents/opencv-4.3.0/opencv_contrib/modules/xfeatures2d/test/test_features2d.cpp:435:39: error: ‘SIFT’ has not been declared
FeatureDetectorUsingMaskTest test(SIFT::create());
reference websites
https://www.cnblogs.com/fx-blog/p/8213704.html
https://blog.csdn.net/u011736771/article/details/85960300
I had the same problem with the 4.3.0 release, SIFT was moved out of xfeatures2d but I dont think it was inserted in the main branch for the 4.3.0 release. Just download the master (development) branch and the problem is solved

How to fix error with CMake while installing LuaDist on Windows 10

I've been trying to install Luadist, but an error with CMake always happens and in the end it doesn't install because of it.
This seems to be a common issue on Windows 10. I've followed the instructions from https://github.com/LuaDist/Repository/wiki/LuaDist%3A-Installation and https://github.com/LuaDist/Repository/wiki/Installation-of-System-Dependencies#microsoft-windows . I've tried uninstalling it and installing it again, but it didn't work. I tried installing Lua on the same drive as LuaDist, but it still doesn't work. I think the error might be because I also have LuaRocks installed, I don't know if they are compatible together.
[ 37%] Performing configure step for 'luafilesystem'
loading initial cache file C:/Users/User/_bootstrap/_bootstrap/tmp/config.cmake
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.15/Modules/CMakeMinGWFindMake.cmake:12 (message):
sh.exe was found in your PATH, here:
C:/Program Files/Git/usr/bin/sh.exe
For MinGW make to work correctly sh.exe must NOT be in your path.
Run cmake from a shell that does not have sh.exe in your PATH.
If you want to use a UNIX shell, then use MSYS Makefiles.
Call Stack (most recent call first):
CMakeLists.txt:7 (project)
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
CMakeFiles\luafilesystem.dir\build.make:106: recipe for target 'luafilesystem/src/luafilesystem-stamp/luafilesystem-configure' failed
mingw32-make.exe[3]: *** [luafilesystem/src/luafilesystem-stamp/luafilesystem-configure] Error 1
CMakeFiles\Makefile2:114: recipe for target 'CMakeFiles/luafilesystem.dir/all' failed
mingw32-make.exe[2]: *** [CMakeFiles/luafilesystem.dir/all] Error 2
CMakeFiles\Makefile2:175: recipe for target 'CMakeFiles/install.dir/rule' failed
mingw32-make.exe[1]: *** [CMakeFiles/install.dir/rule] Error 2
Makefile:156: recipe for target 'install' failed
mingw32-make.exe: *** [install] Error 2
## Bootstrap done, building LuaDist using LuaDist
'C:\Users\User\_bootstrap\_bootstrap\bin\luadist.exe' is not recognized as an internal or external command,
operable program or batch file.
## LuaDist is now built and can be found in C:\Users\User\_bootstrap\_install
At the end it says that LuaDist is built in C:\Users\User_bootstrap_intall , but that folder doens't exist after the installation.

OpenCV 3.2 Make Error

OpenCV => 3.2
Operating System / Platform => Ubuntu 64 bit
Compiler => make
Detailed description
I am having some trouble installing OpenCV 3.2. I followed the example given on Milq's github: https://github.com/milq/milq/blob/master/scripts/bash/install-opencv.sh; however upon typing the command "make -j4", the process stopped at 23% due to a make error. I then tried this solution: http://www.ozbotz.org/opencv-installation, using the same OpenCV 3.2 zip file from the first solution. However, it stopped again, and I got the following error:
Scanning dependencies of target opencv_cudaarithm
[ 18%] [ 18%] [ 18%] [ 18%] Building CXX object
modules/cudaarithm/CMakeFiles/opencv_cudaarithm.dir/src/core.cpp.o
Building CXX object modules /cudaarithm/CMakeFiles/opencv_cudaarithm.dir/src/element_operations.cpp.o
Building CXX object modules/cudaarithm/CMakeFiles/opencv_cudaarithm.dir/src/reductions.cpp.o
Building CXX object modules/cudaarithm/CMakeFiles/opencv_cudaarithm.dir/src/arithm.cpp.o
Linking CXX shared library ../../lib/libopencv_cudaarithm.so
[ 18%] Built target opencv_cudaarithm
make: *** [all] Error 2
Does anyone have any suggestion or solution to fix this? I have tried recreating it nearly 5 times, and everytime I receive the same error. I believe it has something to do with cudaarithm. I am pretty new to these types of installations, but I trying my best to learn. I have been able to figure out most things myself and by trial and error, but I am at a loss here.

QT Creator links different library than command line

I have a problem I am unable to understand.
I am trying to code a project using openCV 3.1. I want to code inside the QT Creator Environment, because I'm used to that. I do not necessarily need any QT specific features at the moment, I'm working with Ubuntu 14.04.
The problem is, that whenever I try to build inside the QT Creator, it does not build with the following error, but it works if I build from the command line.
10:57:36: Starting: "/usr/bin/cmake" --build . --target all
Linking CXX executable arucoTest
CMakeFiles/arucoTest.dir/PoseEstimator.cpp.o: In function `PoseEstimator::generateMarkers(std::string, int)':
PoseEstimator.cpp:(.text+0x56): undefined reference to `cv::aruco::getPredefinedDictionary(cv::aruco::PREDEFINED_DICTIONARY_NAME)'
PoseEstimator.cpp:(.text+0xb7): undefined reference to `cv::aruco::drawMarker(cv::Ptr<cv::aruco::Dictionary>&, int, int, cv::_OutputArray const&, int)'
PoseEstimator.cpp:(.text+0x1a9): undefined reference to `cv::imwrite(cv::String const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
CMakeFiles/arucoTest.dir/PoseEstimator.cpp.o: In function `cv::String::~String()':
PoseEstimator.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0x14): undefined reference to `cv::String::deallocate()'
CMakeFiles/arucoTest.dir/PoseEstimator.cpp.o: In function `cv::String::String(std::string const&)':
PoseEstimator.cpp:(.text._ZN2cv6StringC2ERKSs[_ZN2cv6StringC5ERKSs]+0x69): undefined reference to `cv::String::allocate(unsigned long)'
collect2: error: ld returned 1 exit status
make[2]: *** [arucoTest] Error 1
make[1]: *** [CMakeFiles/arucoTest.dir/all] Error 2
make: *** [all] Error 2
10:57:36: The process "/usr/bin/cmake" exited with code 2.
So it is some kind of linker error. When I inspect my cmake file and output, I see this:
Running "/usr/bin/cmake /XYZ/arucoTest '-GCodeBlocks - Unix Makefiles'" in /XYZ/arucoTest/testbuild.
-- OpenCV library status:
-- version: 2.4.8
-- libraries: opencv_videostab;opencv_video;opencv_ts;opencv_superres;opencv_stitching;opencv_photo;opencv_ocl;opencv_objdetect;opencv_ml;opencv_legacy;opencv_imgproc;opencv_highgui;opencv_gpu;opencv_flann;opencv_features2d;opencv_core;opencv_contrib;opencv_calib3d
-- include path: /usr/include/opencv;/usr/include
-- Configuring done
-- Generating done
-- Build files have been written to: /XYZ/arucoTest/testbuild
As you can see, it only finds openCV 2.4.8, which I still need because of old ROS Indigo projects. However, if I execute the exact same cmake file and build from the commandline, it works perfectly:
username#pc:/XYZ/arucoTest/build$ cmake ..
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- OpenCV library status:
-- version: 3.1.0
-- libraries: opencv_xphoto;opencv_xobjdetect;opencv_ximgproc;opencv_xfeatures2d;opencv_tracking;opencv_text;opencv_surface_matching;opencv_structured_light;opencv_stereo;opencv_saliency;opencv_rgbd;opencv_reg;opencv_plot;opencv_optflow;opencv_line_descriptor;opencv_fuzzy;opencv_face;opencv_dpm;opencv_dnn;opencv_datasets;opencv_ccalib;opencv_bioinspired;opencv_bgsegm;opencv_aruco;opencv_viz;opencv_videostab;opencv_videoio;opencv_video;opencv_superres;opencv_stitching;opencv_shape;opencv_photo;opencv_objdetect;opencv_ml;opencv_imgproc;opencv_imgcodecs;opencv_highgui;opencv_flann;opencv_features2d;opencv_core;opencv_calib3d
-- include path: /usr/local/include/opencv;/usr/local/include
-- Configuring done
-- Generating done
-- Build files have been written to: /XYZ/arucoTest/build
veith#roethlinLT:/XYZ/arucoTest/build$ make
Scanning dependencies of target arucoTest
[100%] Building CXX object CMakeFiles/arucoTest.dir/PoseEstimator.cpp.o
Linking CXX executable arucoTest
[100%] Built target arucoTest
As you can see I'm building in 2 different folders, because I found that if I cmake in the same folder, it does not work, even if I remove everything in that folder and cmake again from the command line. Also notice, that it finds 2 different include paths depending on where I start the cmake from.
My makefile looks like this (not very crazy), I'm using this exact same file for both cases.
project(arucoTest)
cmake_minimum_required(VERSION 2.8)
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
set(HEADER_LIST PoseEstimator.h)
set(SRC_LIST PoseEstimator.cpp)
add_executable(${PROJECT_NAME} ${SRC_LIST})
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
Using ccmake and the QT build in inspection window, I see that the OpenCV_DIR variable is set to 2 different things: On command line:
OpenCV_DIR /usr/local/share/OpenCV
In QT Creator:
OpenCV_DIR /ust/share/OpenCV
How do I set this to automatically select the right folder inside QT Creator as well? I really have no idea what could cause this!
Thanks!
Cache variable OpenCV_DIR is set by searching with command find_package (in config mode). While search mechanism is fully deterministic (it is described in the doc), it uses some envorinment variables which may differ under your shell and in QT Creator.
Just a guess, QT Creator may set CMAKE_PREFIX_PATH environment variable to contain /usr directory, so it finds an installation under /usr before one under /usr/local.
For choose specific OpenCV installation, just set OpenCV_DIR cache variable accordingly and rerun configuration process.

Resources