How to build a Python wheel for Opencv

Viewed 2217

I am a beginner in Python and I am looking for your help. So, I have built Opencv 4.4.0 from source with support for a few things (s.a. CUDA). I downloaded the package from here:

wget -O opencv.zip https://github.com/opencv/opencv/archive/4.4.0.zip

Here is the command I used:

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 WITH_CUDA=ON \
    -D WITH_CUDNN=ON \
    -D OPENCV_DNN_CUDA=ON \
    -D ENABLE_FAST_MATH=1 \
    -D CUDA_FAST_MATH=1 \
    -D CUDA_ARCH_BIN="5.3" \
    -D CUDNN_VERSION='8.0' \
    -D WITH_CUBLAS=1 \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
    -D HAVE_opencv_python3=ON \
    -D WITH_GSTREAMER=ON \
    -D BUILD_opencv_python2=OFF \
    -D BUILD_opencv_python3=ON \
    -D PYTHON_EXECUTABLE=/usr/bin/python3.7 \
    -D ENABLE_NEON=ON \
    -D WITH_OPENGL=ON \
    -D OPENCV_GENERATE_PKGCONFIG=YES \
    -D EIGEN_INCLUDE_PATH=/usr/include/eigen3 \
    -D BUILD_EXAMPLES=ON ..

This is done on aarch64. After "make" and "make install" I got a file called "cv2.cpython-37m-aarch64-linux-gnu.so".

Q1: Let us assume I format the SD card, can I simply use that file alone and get all the functionality I need?

Q2 I read about creating ready packages via Python wheels. I want to create a wheel for my above built code. How can I do that? I searched a lot online but could not find a tutorial for that.

Thanks all!

0 Answers
Related