Fatal error building opencv from tarball
fatal error: opencv2/alphamat.hpp: No such file or directory
However, I confirmed that alphamat.hpp exists and it is located at opencv_contrib
pi@SMSNG003:~/Applications/opencv/opencv/build ls -la ../../opencv_contrib/modules/alphamat/include/opencv2/
total 12
drwxr-xr-x 2 pi pi 4096 May 3 17:51 .
drwxr-xr-x 3 pi pi 4096 May 3 17:51 ..
-rw-r--r-- 1 pi pi 1769 May 3 17:51 alphamat.hpp
pi@SMSNG003:~/Applications/opencv/opencv/build
As well as other dependencies, which I noticed the show as unavalable at “cmake” building stage
– OpenCV modules:
– To be built: aruco barcode bgsegm bioinspired calib3d ccalib core cvv datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python2 python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
– Disabled: world
– Disabled by dependency: -
– Unavailable: alphamat cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java julia matlab ovis sfm viz
– Applications: perf_tests examples apps
installation source has been built with the following command line
Sure?
>>> help(cv.alphamat.infoFlow)
Help on built-in function infoFlow:
infoFlow(...)
infoFlow(image, tmap[, result]) -> result
. * @brief Compute alpha matte of an object in an image
. * @param image Input RGB image
. * @param tmap Input greyscale trimap image
. * @param result Output alpha matte image
. *
. * The function infoFlow performs alpha matting on a RGB image using a greyscale trimap image, and outputs a greyscale alpha matte image. The output alpha matte can be used to softly extract the foreground object from a background image. Examples can be found in the samples directory.
. *
It turned out to be an issue related with permission. Because the installation directory was /usr/local/, installation source files were not properly created. One of them was alphamat.hpp.
… -D CMAKE_INSTALL_PREFIX=/usr/local -D …
by the way, I also tried to run “cmake” as sudo, however files were not created properly. That was weird too.
So I’ve changed the directory, then cmake ran just fine and files were properly created.
I understand and agree. However, that was not what I had witnessed.
“make install”, which I ran right after “cmake …” , as per installation manual, also returns errors related to alphamat, as expected Of course.
Thus, the error originally begins in the “cmake” procedure. So, it must be fixed there, instead of amending “make install” procedure.
Anyway, the fact is that after I changed the installation directory, the installation process finished successfully.
In fact that was even better , because it made me aware that having openCV 4.5 release located within user’s home directory and libraries installed within virtualenv, gives more flexibility.
So, if, in the future, we decide to run 2 releases of opencv in the same machine, we will have that flexibility.
Now, I’m going deeper in the installation parameters and how I could optimize scanning and image processing. What arguments must I add in the “cmake” procedure in order to achieve better and more optimized results, saving hardware resources. btw, it’s a Rasp Pi device.