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

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

Related

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

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.

Bulid opencv4 on Jetson Xavier nx but failed

I'm trying to implentment openpilot on Jetson Xavier nx. So I'm following https://github.com/eFiniLan/xnxpilot instruction to install dependence.
But when I'm installing opencv4, I get the following errors in ".../opencv/build/CMakeFiles/CMakeError.log"
CMakeFiles/cmTC_ee78d.dir/CheckIncludeFile.c.o -c /home/tshu/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/home/tshu/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:10: fatal error: sys/videoio.h: No such file or directory
#include <sys/videoio.h>
^~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/cmTC_ee78d.dir/build.make:65: recipe for target ‘CMakeFiles/cmTC_ee78d.dir/CheckIncludeFile.c.o’ failed
make[1]: * [CMakeFiles/cmTC_ee78d.dir/CheckIncludeFile.c.o] Error 1
make[1]: Leaving directory ‘/home/tshu/opencv/build/CMakeFiles/CMakeTmp’
Makefile:126: recipe for target ‘cmTC_ee78d/fast’ failed
make: * [cmTC_ee78d/fast] Error 2
The build command I used is
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D WITH_CUDA=ON \
-D CUDA_ARCH_PTX="" \
-D CUDA_ARCH_BIN="7.2" \
-D WITH_CUDNN=ON \
-D CUDNN_VERSION="8.0" \
-D BUILD_opencv_python3=ON \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_java=OFF \
-D WITH_GSTREAMER=ON \
-D WITH_GTK=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_EXAMPLES=OFF \
-D BUILD_FFMPEG=ON \
-D OPENCV_DNN_CUDA=ON \
-D ENABLE_FAST_MATH=ON \
-D CUDA_FAST_MATH=ON \
-D WITH_QT=ON \
-D ENABLE_NEON=ON \
-D ENABLE_VFPV3=ON \
-D BUILD_TESTS=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D PYTHON_EXECUTABLE=/home/`whoami`/.pyenv/versions/3.8.5/bin/python \
-D PYTHON_DEFAULT_EXECUTABLE=/home/`whoami`/.pyenv/versions/3.8.5/bin/python \
-D PYTHON_PACKAGES_PATH=/home/`whoami`/.pyenv/versions/3.8.5/lib/python3.8/site-packages/ \
-D OPENCV_EXTRA_MODULES_PATH=/home/`whoami`/opencv_contrib/modules ..
The version of opencv I tried to install is opencv-4.5.2
Can someone give me some advices? Thank you.
Jetpack comes with opencv preinstalled. JetPack 4.4 includes OpenCV 4.1.1. JetPack 4.6 includes OpenCV 4.1.1.
Let me look at the link you sent and I get back to you. You may need to install and compile OpenCV 4.5.2 from source. I wrote some instructions a while a go.
What Jetpack version are you using? OPENCV 4.4, is CUDA GPU accelerated. Using version 4.4 or higher to fully use the Super Resolution function provided by OpenCV. If you are using Jetpack 4.4, you will need to delete the OpenCV 4.1.1 version of JetPack 4.4 and install 4.4 newly.
Try this script file:
#!/bin/bash
#
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA Corporation and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA Corporation is strictly prohibited.
#
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <Install Folder>"
exit
fi
folder="$1"
user="nvidia"
passwd="nvidia"
echo "** Remove OpenCV4.1 first"
sudo apt-get purge *libopencv*
echo "** Install requirement"
sudo apt-get update
sudo apt-get install -y build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt-get install -y python2.7-dev python3.6-dev python-dev python-numpy python3-numpy
sudo apt-get install -y libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
sudo apt-get install -y libv4l-dev v4l-utils qv4l2 v4l2ucp
sudo apt-get install -y curl
sudo apt-get update
echo "** Download opencv-4.5.1"
cd $folder
curl -L https://github.com/opencv/opencv/archive/4.5.1.zip -o opencv-4.5.1.zip
curl -L https://github.com/opencv/opencv_contrib/archive/4.5.1.zip -o opencv_contrib-4.5.1.zip
unzip opencv-4.5.1.zip
unzip opencv_contrib-4.5.1.zip
cd opencv-4.5.1/
echo "** Building..."
mkdir release
cd release/
cmake -D WITH_CUDA=ON -D ENABLE_PRECOMPILED_HEADERS=OFF -D CUDA_ARCH_BIN="7.2" -D CUDA_ARCH_PTX="" -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.4.0/modules -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D BUILD_opencv_python2=ON -D BUILD_opencv_python3=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j6
sudo make install
echo "** Install opencv-4.5.1 successfully"
echo "** Bye :)"
If you are using NX -D CUDA_ARCH_BIN="7.2"
Run following script with on path:
$./opencv4.5_xavier_nx.sh /home/TH-Dev/src/

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.

Resources