ubuntu) installed opencv with cmake but python couldn`t find cv2 module - opencv

i just want to know about this problem.
pkg config show my opencv4 version, but in python3 there`s no module named cv2.
please help me...!
cmake list:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=ON -D BUILD_DOCS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -D BUILD_PACKAGE=OFF -D BUILD_EXAMPLES=OFF -D WITH_TBB=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.7 -D WITH_CUDA=ON -D WITH_CUBLAS=ON -D WITH_CUFFT=ON -D WITH_NVCUVID=ON -D WITH_IPP=OFF -D WITH_V4L=ON -D WITH_1394=OFF -D WITH_GTK=ON -D WITH_QT=OFF -D WITH_OPENGL=ON -D WITH_EIGEN=ON -D WITH_FFMPEG=ON -D WITH_GSTREAMER=ON -D BUILD_JAVA=OFF -D BUILD_opencv_python3=ON -D BUILD_opencv_python2=OFF -D BUILD_NEW_PYTHON_SUPPORT=ON -D OPENCV_SKIP_PYTHON_LOADER=ON -D OPENCV_GENERATE_PKGCONFIG=ON -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.5.1/modules -D WITH_CUDNN=ON -D OPENCV_DNN_CUDA=ON -D CUDA_ARCH_BIN=8.6 -D CUDA_ARCH_PTX=8.6 -D OpenCL_LIBRARY=/usr/local/cuda-11.7/lib64/libOpenCL.so -D OpenCL_INCLUDE_DIR=/usr/local/cuda-11.7/include/ ..
cuda-11.7 cudnn- so.8 opencv-4.5.1

Did you check the build information before building and installing OpenCV? If not, you can still check the build information using the OpenCV function getBuildInformation(). To find your OpenCV configuration, create a C++ file, add the following code to it, and execute the file:
#include <opencv2/opencv.hpp>
int main(void)
{
std::cout << cv::getBuildInformation() << std::endl;
}
Reference: https://learnopencv.com/get-opencv-build-information-getbuildinformation/
Once you have the build information, check the Python3 options (usually found at the bottom of the output). OpenCV Python bindings have not been generated if the install path is unspecified.
That means OpenCV has to be built again with the proper Python3 addresses.
The following options need to be added to the CMake command:
-D PYTHON_EXECUTABLE=$(which python3)
-D OPENCV_PYTHON3_INSTALL_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
-D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")
-D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
Then, run a clean build, and check the configuration page for the correct Python3 options. A step-by-step guide is posted by learnopencv for installing OpenCV DNN module with GPU support on Linux.

Related

phabricator curl commandline for creating repository

Can somebody help me please to create a git Repository with curl ?
I try based on documentation:
curl https://my-url.eu/api/diffusion.repository.edit \
-d api.token=api-my-token \
-d transactions[0][type]=vcs \
-d transactions[0][value]=git \
-d transactions[1][type]=name \
-d transactions[1][value]=testing-api-repo \
-d objectIdentifier=
Return:
zsh: no matches found: transactions[0][type]=vcs
Also my second question: is there a way to create conduit-api-token via cli ?? it would be very useful for automation
I found it :
curl -k -s -X POST https://URL/api/diffusion.repository.edit \
-d api.token=api-TOKEN_HERE \
-d 'transactions[0][type]=vcs' \
-d 'transactions[0][value]=git' \
-d 'transactions[1][type]=name' \
-d 'transactions[1][value]=testing' | jq -r

how to Install OpenCv on my home directory in Ubuntu

I am trying to compile and install OpenCV on my home directory (so I can have several versions installed)
I have this option when I am calling cmak:
-D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/mans/local/opencv -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_INF_ENGINE=ON -D ENABLE_CXX11=ON
but when I build the code and try to install it, I am getting this error:
-- Install configuration: "Release"
CMake Error at cmake_install.cmake:41 (file):
file cannot create directory: /usr/local/share/licenses/opencv4. Maybe
need administrative privileges.
Makefile:61: recipe for target 'install' failed
make: *** [install] Error 1
As I want to install on my home directory, I can not use
sudo make install
as it will install openCV on root and I don't want to do this.
Edit
I am using this bash script to build and install OpenCV from git repository.
WITH_INF_ENGINE=true # should be buildwith Intel Inference Engineen
workingDir="$HOME/local"
downloadDir="$workingDir/downloadedFiles"
if [ ! -d "$workingDir" ]; then
mkdir "$workingDir"
fi
cd $workingDir
git clone https://github.com/opencv/opencv $downloadDir/opencv
cd $downloadDir/opencv
mkdir build
cd build
cmakeParameters="-D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=$workingDir/opencv -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON "
if $WITH_INF_ENGINE; then
source /opt/intel/computer_vision_sdk/bin/setupvars.sh
cmakeParameters="$cmakeParameters -D WITH_INF_ENGINE=ON -D ENABLE_CXX11=ON"
fi
echo "$cmakeParameters"
cmake "$cmakeParameters" ..
make -j $(nproc)
make install

Getting CMake Error with Protobuf Library in the configuration of OpenCV in Raspberry Pi

I followed this tutorial to install OpenCV and all the steps worked until I reached the Install part. I did the following:
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.3.0/modules \
-D BUILD_EXAMPLES=ON ..
The command performed several tests and showed the General configuration for OpenCV 3.3.0 but at the end I got the following error:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
Protobuf_LIBRARY
linked by target "opencv_dnn_modern" in directory /home/pi/opencv_contrib-3.3.0/modules/dnn_modern
-- Configuring incomplete, errors occurred!
See also "/home/pi/opencv-3.3.0/build/CMakeFiles/CMakeOutput.log".
See also "/home/pi/opencv-3.3.0/build/CMakeFiles/CMakeError.log".
I have a opencv_contrib-3.3.0 directory though instead of opencv_contrib that's why I included the -3.3.0 in the make.
I solved the issue through the following steps:
Deleting the build folder in the opencv directory
Recreating the build folder: mkdir build
Moving to that build directory: cd build
Adding the following line in the make: -D BUILD_opencv_dnn_modern=OFF
and running it as follows:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_opencv_dnn_modern=OFF \
-D ENABLE_NEON=ON \
-D ENABLE_VFPV3=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.3.0/modules \
-D BUILD_EXAMPLES=ON ..

Can't install cmake on Ubuntu(build error)

I tried to install opencv(3.1.0) on Ubuntu 12.06. What does this error mean? Is observed for OpenCV modules second time? How can I fix it?
Env Var setup
cmake
-D CMAKE_BUILD_TYPE=RELEASE
-D ENABLE_PRECOMPILED_HEADERS=OFF
-D CMAKE_INSTALL_PREFIX=/usr/local
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules
-D BUILD_NEW_PYTHON_SUPPORT=ON
-D WITH_TBB=ON
-D WITH_QT=ON
-D WITH_OPENGL=ON
-D BUILD_TIFF=ON
-D BUILD_SHARED_LIBS=ON
-D BUILD_EXAMPLES=ON
-D BUILD_opencv_ts=ON
CMake Error at cmake/OpenCVModule.cmake:268 (message):
The directory /home/user/bin/opencv/modules is observed for OpenCV
modules second time.
Call Stack (most recent call first):
modules/CMakeLists.txt:7 (ocv_glob_modules)
This issue is already raised on OpenCV GitHub Page :
ts module not installed
Hope that helps.

building opencv from trunk makes cv2.so, how to get cv.so?

Simplecv depends on cv.so, but when I build open opencv from trunk I only get cv2.so
I've not heard back from either opencv or Simplecv. Any here have an idea?
Ubuntu 12.10 64bit desktop, build args:
-D CMAKE_BUILD_TYPE=DEBUG \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D BUILD_PYTHON_SUPPORT=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_DOCS=ON
Thanks,
Kent

Resources