OpenCV 3.2 Make Error - opencv

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.

Related

fatal error: opencv2/core/core.hpp: No such file or directory when compiling caffe

I kept getting this error:
PROTOC src/caffe/proto/caffe.proto
CXX .build_release/src/caffe/proto/caffe.pb.cc
CXX src/caffe/layer.cpp
CXX src/caffe/blob.cpp
CXX src/caffe/syncedmem.cpp
CXX src/caffe/solver.cpp
CXX src/caffe/data_transformer.cpp
src/caffe/data_transformer.cpp:1:10: fatal error: opencv2/core/core.hpp: No such file or directory
1 | #include <opencv2/core/core.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:525: .build_release/src/caffe/data_transformer.o] Error 1
I don't understand where I go wrong. I'm using OpenCV 4.4.0 but it kept saying fatal error on opencv2. I also have installed all the dependencies that needed. does anyone have any idea about it? please help me.
If your opencv is correctly compiled and installed, it should be just a redundant directory. There is a directory opencv2 in the directory named opencv4, and then the specific classification file. That's what caffe compiling needs and why it kept saying fatal error on opencv2.
Solution: Put the entire copy of the opencv2 folder under the directory /usr/local/include/opencv4, and put it in the upper directory /usr/local/include, to compile Caffe normally (although there are other problems).
I encountered the same problem in the Ubuntu18 system with opencv4.2.0. It seems that opencv4 is too high to compile caffe. If you go on with it, there will be more errors because of it. I suggest you compile caffe with cuda8 and opencv3.X.

Compiling ROS Kinetec from source fails when building opencv

I'm using an Arch machine and trying to compile ROS desktop full from source. The build fails when image_proc is trying to link executable.
Here is the error log:
[ 23%] Built target image_proc_gencfg
[ 84%] Built target image_proc
[ 92%] Linking CXX executable /home/alphayed/ROS/ros_catkin_ws/devel_isolated/image_proc/lib/image_proc/image_proc
/home/alphayed/ROS/ros_catkin_ws/install_isolated/lib/libopencv_viz3.so.3.1.0: undefined reference to `vtkSTLReader::New()'
/home/alphayed/ROS/ros_catkin_ws/install_isolated/lib/libopencv_viz3.so.3.1.0: undefined reference to `vtkOBJReader::New()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/image_proc_exe.dir/build.make:219: /home/alphayed/ROS/ros_catkin_ws/devel_isolated/image_proc/lib/image_proc/image_proc] Error 1
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/image_proc_exe.dir/all] Error 2
make: *** [Makefile:139: all] Error 2
I think the problem is related to opencv3. I removed it from the system and recompiled it from source but that didn't solve the issue. Can you please help?
I have found a fix as per this thread. You need to modify opencv3/cmake/OpenCVDetectVTK.cmake, for every find_package(VTK QUIET COMPONENTS ... add an entry vtkIOGeometry

Segmentation fault when running compiled file from Cmake

I am trying to compile a project that depends on PCL and OpenCV.
The CMakeLists.txt looks like:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(pcl_visualizer_viewports)
find_package(PCL 1.2 REQUIRED)
find_package(OpenCV REQUIRED)
message("this is my message " ${OpenCV_LIBRARIES} )
message("this is my message " ${OpenCV_INCLUDE_DIRS} )
message("this is my message " ${OpenCV_INSTALL_PATH} )
include_directories(${PCL_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable (pcl_visualizer_demo pcl_visualizer_demo.cpp readInputFile.cpp readInputFile.h defines.h helper.cpp helper.h Image_Safety.h Image_Safety.cpp)
target_link_libraries (pcl_visualizer_demo ${PCL_LIBRARIES} ${OpenCV_LIBRARIES})
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
The result is however a segmentation fault and core dumped. I have read through the Cmake tutorial, but I have not found the issue. CMake generates the object files for all:
Scanning dependencies of target pcl_visualizer_demo
[ 20%] Building CXX object CMakeFiles/pcl_visualizer_demo.dir/Image_Safety.cpp.o
[ 40%] Building CXX object CMakeFiles/pcl_visualizer_demo.dir/helper.cpp.o
[ 60%] Building CXX object CMakeFiles/pcl_visualizer_demo.dir/image_converter.cpp.o
[ 80%] Building CXX object CMakeFiles/pcl_visualizer_demo.dir/readInputFile.cpp.o
[100%] Building CXX object CMakeFiles/pcl_visualizer_demo.dir/pcl_visualizer_demo.cpp.o
Linking CXX executable pcl_visualizer_demo
Looking at the linking verbose information, the different object files are mentioned and I interpret this as they are linked.
What am I missing?
update
Weird so the error occurs in some part of the code using basic opencv functions cv::waitKey and cv::imshow, it may seem to be an issue with QT according to this and this.
I had a similar issue. In the end I had to build PCL without QT (I also found several posts which stated interference, but found no solution)

I cannot obtain the rpm of ContextBroker

I have tried to obtain the rpm associated to ContextBroker component (https://github.com/telefonicaid/fiware-orion.git) but I have obtained the following error after executing make rpm.
[ 98%] Building CXX object src/lib/mongoBackend/CMakeFiles/mongoBackend.dir/mongoNotifyContextAvailability.cpp.o
Linking CXX static library libmongoBackend.a
make[4]: Leaving directory `/home/develenv/app/jenkins/config-history/jobs/ContextBroker-Build/fiware-orion/rpm/BUILD/contextBroker-0.14.1_next/BUILD_RELEASE'
[ 98%] Built target mongoBackend
make[3]: Leaving directory `/home/develenv/app/jenkins/config-history/jobs/ContextBroker-Build/fiware-orion/rpm/BUILD/contextBroker-0.14.1_next/BUILD_RELEASE'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/develenv/app/jenkins/config-history/jobs/ContextBroker-Build/fiware-orion/rpm/BUILD/contextBroker-0.14.1_next/BUILD_RELEASE'
make[1]: *** [release] Error 2
make[1]: Leaving directory `/home/develenv/app/jenkins/config-history/jobs/ContextBroker-Build/fiware-orion/rpm/BUILD/contextBroker-0.14.1_next'
error: Bad exit status from /var/tmp/rpm-tmp.NPtnCN (%build)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.NPtnCN (%build)
make: *** [rpm] Error 1
Previously to this stage I compiled and executed the unit tests as well as functional tests with no problems I am working on Red Hat 4.4.7-3 with repo/branch:
https://github.com/telefonicaid/fiware-orion/tree/release/iotplatform-v1
Thanks for your help
UPDATE:
The linux distribution used was CentOS 6.4
This problems is solved if you install cantcoap and COAP client, as described in the Orion README.md file, then execute make rpm.
Note that although COAP stuff is optional to build the code itself with make release or make debug the RPM building target needs them by the time being (we probably fix this in the future).
UPDATE: the fix of the RPM makefile target is being dealed at this Github.com issue: https://github.com/telefonicaid/fiware-orion/issues/579

Having problems building OpenCV 2.0 on CentOS 5?

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.

Resources