opencv2/intensity_transform.hpp: No such file or directory - opencv

I'm quite a noob using cmake and compilers, I have compiled opencv-4.4.0 with contrib on my desktop, while facing the issue opencv2/intensity_transform.hpp: No such file or directory when I'm trying to include such file using:
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/intensity_transform.hpp>
#include <opencv2/imgproc.hpp>
#include "opencv2/imgcodecs.hpp"
The opencv is installed to default /usr/local directory, so opencv2 could be found in /usr/local/include/ directory. Only intensity_transform failed, with error message:
Scanning dependencies of target srobot
[ 25%] Building CXX object src/CMakeFiles/srobot.dir/img_aug_OPENCV/image_enhance_by_opencv.cpp.o
${ROOD_DIR}/src/img_aug_OPENCV/image_enhance_by_opencv.cpp:4:10: fatal error: opencv2/intensity_transform.hpp: No such file or directory
#include <opencv2/intensity_transform.hpp>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
src/CMakeFiles/srobot.dir/build.make:62: recipe for target 'src/CMakeFiles/srobot.dir/img_aug_OPENCV/image_enhance_by_opencv.cpp.o' failed
make[2]: *** [src/CMakeFiles/srobot.dir/img_aug_OPENCV/image_enhance_by_opencv.cpp.o] Error 1
CMakeFiles/Makefile2:85: recipe for target 'src/CMakeFiles/srobot.dir/all' failed
make[1]: *** [src/CMakeFiles/srobot.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Here is the CMakeLists.txt:
# CMakeLists from src directory
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
add_definitions(-DUSE_OPENCV)
# using mkl/cuda
set(MKL_DIR /opt/intel/mkl)
set(CUDA_DIR /usr/local/cuda)
include_directories(${MKL_DIR}/include ${CUDA_DIR}/include ${PROJECT_SOURCE_DIR}/src)
link_directories(${MKL_DIR}/lib/intel64 ${CUDA_DIR}/lib64)
# this command recursively add *.cpp files in src and add them to list: srcs
file(GLOB_RECURSE srcs ${PROJECT_SOURCE_DIR}/src/img_aug_OPENCV/image_enhance_by_opencv.cpp)
message(STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR})
message(STATUS "srcs: " ${srcs})
add_library(srobot SHARED ${srcs})
set(OPENCV_LIBS opencv_core opencv_imgproc opencv_imgcodecs)
target_link_libraries(srobot mkl_core ${OPENCV_LIBS})
Actually I'm facing this with original opencv-3.5.4, it is also installed from source. Here is the cmake commands I used:
cmake \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D WITH_CUDA=ON \
-D BUILD_opencv_cudacodec=OFF \
-D ENABLE_PRECOMPILED_HEADERS=OFF\
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=1 \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=ON \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_EXTRA_MODULES_PATH=/home/ubuntu/Installation/opencv_contrib-4.4.0/modules/ \
-D PYTHON_EXECUTABLE=/home/ubuntu/anaconda3/envs/tf2/bin/python \
-D BUILD_TIFF=ON ..
And system info:
Ubuntu 18.04;
CUDA 10.0.0;
I will provide more sys info if necessary. Is this related to platform? It seems that source code was from Windows platform. Help needed!

Related

Compiling MMIF with gfortran

I'm trying to compile MMIF (mesoscale meteorological interface) on a HPC. Although MMIF compiles it doesn't work (mmif: command not found). I'm concerned installing/adding more libraries will cause issues with WRF, which I have successfully compiled on the HPC
The makefile log file is /usr/bin/ld: warning: libgfortran.so.5, needed by /apps/spack/hbv2/linux-centos7-x86_64/gcc-9.2.0/netcdf-fortran-4.5.3-qlkoxdcdchzdgg6nemvt5r6uox77d6ut/lib/libnetcdff.so, may conflict with libgfortran.so.4
libgfortran.so.4 & libgfortran.so.5 are both located in /usr/lib/x86_64-linux-gnu/
The makefile is
INCL = -I$(NETCDF_DIR)/include -I$(HDF5)/include
LIBS = -L$(NETCDF_DIR)/lib -lnetcdff -lnetcdf
PROGRAM = mmif
TODAY = 2021-12-15
VERSION = 4.0
NEWTAG = 4.0 2021-12-15
OLDTAG = 3.4.2rc2 2020-12-15
MODULES = met_fields.f90 functions.f90 module_llxy.f90 wrf_netcdf.f90 \
parse_control.f90
SOURCES = aggregate.f90 avg_zface.f90 cloud_cover.f90 interpolate.f90 \
landuse.f90 mmif.f90 output_aercoare.f90 output_aermet.f90 \
output_calmet.f90 output_onsite.f90 output_scichem.f90 \
pasquill_gifford.f90 pbl_height.f90 read_mm5.f90 read_wrf.f90 \
sfc_layer.f90 timesubs.f90
OBJECTS = $(SOURCES:.f90=.o)
MODOBJS = $(MODULES:.f90=.o)
MODMODS = $(MODULES:.f90=.mod)
$(PROGRAM): $(MODOBJS) $(OBJECTS)
$(FC) $(FFLAGS) $(MODOBJS) $(OBJECTS) $(LIBS) -o $#
%.o : %.f90
$(FC) $(FFLAGS) $(INCL) -c $< -o $#
install: $(PROGRAM)
cp $(PROGRAM) /usr/local/bin
update_version:
sed -i "s|VERSION $(OLDTAG)|VERSION $(NEWTAG)|g" \
*.f90 README.txt makefile makefile.windows mmif_change_log.txt
distro:
mmif --sample > mmif.inp
unix2dos *.f90 *.sh makefile.windows old_compile.bat README*.txt mmif.inp
zip -j MMIFv$(VERSION)_$(TODAY).zip \
mmif.exe mmif mmif.inp *.f90 *.sh makefile \
makefile.windows old_compile.bat README*.txt \
MMIFv$(VERSION)_Users_Manual.pdf \
mmif_change_log.txt test_problems/*/*.inp
dos2unix *.f90
test_pkg:
zip -r MMIFv$(VERSION)_test_problems.zip \
test_problems -x \*/wrf/\* \*/mm5/\*
test_pkg_mm5+wrf:
zip -r MMIF_test_problems_mm5+wrf.zip \
test_problems/wrf \
test_problems/mm5 ```

How to fix make errors on ubuntu 16.04

Try to dockerize bitcoin-sv on ubuntu:16.04, but have an error on last step.
A piece of Dockerfile :
RUN mkdir boost \
&& cd boost \
&& wget https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.gz \
&& tar -xzvf boost_1_70_0.tar.gz \
&& cd boost_1_70_0 \
&& ./bootstrap.sh \
&& ./b2 \
&& ./b2 install \
&& cd ../../ \
&& git clone https://github.com/bitcoin-sv/bitcoin-sv \
&& cd bitcoin-sv \
&& ./autogen.sh \
&& mkdir build \
&& cd build \
&& ../configure \
&& make <------------- error on this final step
Error:
Makefile:4415: recipe for target 'rpc/libbitcoin_cli_a-client.o' failed
make[2]: *** [rpc/libbitcoin_cli_a-client.o] Error 1
make[2]: Leaving directory '/bitcoin-sv/build/src'
Makefile:8455: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/bitcoin-sv/build/src'
Makefile:660: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
Read here that there may be a lack of memory . How to fixed it?
One more error logged. There is out of memory in docker machine
../../src/validation.cpp:4046:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
cacheSize > std::max(static_cast<uint64_t>((9 * nTotalSpace) / 10),
~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nTotalSpace - MAX_BLOCK_COINSDB_USAGE * ONE_MEBIBYTE);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
g++: internal compiler error: Killed (program cc1plus)
The error g++: internal compiler error: Killed (program cc1plus) is nearly always due to too little memory - as explained more thoroughly in this StackOverflow post by Jon.
Running on ubuntu (not meaning within a virtual machine on ubuntu) your machine may be out of memory as docker has access to the whole memory of a Linux host as far as I know. If running within a virtual machine make sure it has enough memory available and in turn that it is available to docker.
For macOS or Windows, you could easily manage the resources available to docker (assuming that there are still resources left) by following Roberts answer to the (not quite correctly phrased) StackOverflow question 'How to assign more memory to docker container'.

Build fails during make of OpenCV on Raspberry Pi with "segmentation fault" caused by "cc1plus"

I'm trying to make a build of OpenCV 4.0.0 on my Raspberry Pi 3B+, and keep running into this issue:
[ 83%] Building CXX object modules/stitching/CMakeFiles/opencv_perf_stitching.dir/perf/opencl/perf_stitch.cpp.o
c++: internal compiler error: Segmentation fault (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
modules/stitching/CMakeFiles/opencv_perf_stitching.dir/build.make:62: recipe for target 'modules/stitching/CMakeFiles/opencv_perf_stitching.dir/perf/opencl/perf_stitch.cpp.o' failed
make[2]: *** [modules/stitching/CMakeFiles/opencv_perf_stitching.dir/perf/opencl/perf_stitch.cpp.o] Error 4
CMakeFiles/Makefile2:23142: recipe for target 'modules/stitching/CMakeFiles/opencv_perf_stitching.dir/all' failed
make[1]: *** [modules/stitching/CMakeFiles/opencv_perf_stitching.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
This is the make/build portion of the script I'm running:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D PYTHON_EXECUTABLE=~/.virtualenvs/py3cv4/bin/python \
-D WITH_GSTREAMER=ON \
-D WITH_FFMPEG=ON \
-D WITH_OPENMP=ON \
-D BUILD_EXAMPLES=ON ..
echo ""
echo "======================="
echo "Building OpenCV..."
make -j4
sudo make install
sudo ldconfig
I read somewhere that I should change the make -j4 command to not use all four cores, because I'm running out of memory. I tried make -j1, but still got the same error at the same spot. I'm going to try again with just plain make, but delete all the pre-built stuff that's in there and start over from scratch to see if that helps.
Turns out I needed to entirely delete the build I had created and rebuild it with a single core instead of all four, as it was using up too much memory. I deleted my /opencv/build/ directory and then did make with no -j command, and it worked fine. It took a really long time (5+ hours), but it did complete successfully. Now I just have to figure out why I can't import cv2...

Makefile:160: recipe for target 'all' failed

Guys am trying to install OpenCV 3.3.1 on Raspbian stretch Noobs on Pi model B
I am following this tutorial.
But when i type
cmake
-D CMAKE_BUILD_TYPE=RELEASE \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH= ~/Opencv_contrib-3.3.1/modules \
-D BUILD_opencv_python3=yes \
-D BUILD_EXAMPLES=ON \
-D WITH_CUDA=OFF.. `
And then i type make -j2
To get this error
[ 7%] building cxx object 3rsparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ ImfZipcompressor.cpp.o
[ 7%] linking cxx static library.. /lib/libIlmImf.a
[ 7%] built target IlmImf
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
What's the problem?
I found that the problem was in this line
/home/pi/opencv3.3.1/3rdparty/carotene/src/absdiff.cpp:42:22: fatal error: common.hpp: no such file or directory
#include "common.hpp"
I 've gone through the directory and opened absdiff.cpp to find #include "common.hpp"
But no file called common.hpp in the same directory so i copied common.hpp from
/home/pi/opencv/3rd party/carotene/src/
Which i cloned using this code
git clone https://github.com/Itseez/opencv.git opencv
I don't know why opencv-3.3.1 doesn't have it or just an issue during the download...
Or just re-download opencv-3.3.1 again

Torch OpenCV integration

I want to install opencv package in torch. I have already installed opencv and it is working fine. After using luarocks install cv for installing cv package in torch I am getting following error.
CMake Error at CMakeLists.txt:30 (FIND_PACKAGE):
Could not find a configuration file for package "OpenCV" that exactly
matches requested version "3.1".
The following configuration files were considered but not accepted:
/home/user/opencv-3.1.0/cmake/OpenCVConfig.cmake, version: unknown
/usr/local/share/OpenCV/OpenCVConfig.cmake, version: 3.3.0
-- Configuring incomplete, errors occurred!
See also "/tmp/luarocks_cv-scm-1-5467/torch-
opencv/build/CMakeFiles/CMakeOutput.log".
make: *** No targets specified and no makefile found. Stop.
Is there any way to fix this?
you may take a look at installation guide from the GitHub page
torch-opencv requires opencv-3.1.0 and is not (yet) compatible with opencv-3.3.0.
Therefore, you need to install opencv-3.1.0
git clone https://github.com/daveselinger/opencv
cd opencv
git checkout 3.1.0-with-cuda8
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local
-D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON
-D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON
-D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
make
sudo make install
luarocks install cv
if your cuda version is not 8, you should change it.

Resources