Skip to content

OpenCV for Python 3.10.11

OpenCV docker images

HEY! 👋

I've made a docker container with opencv 4.8.0 ready to use! Check it out.
If you don't want to use docker, keep reading.

OpenCV 4.8.0 installation

Required time: 25 min

Pre-requisites

INFO

I'm going start from a new fresh Jetpack.

Python 3.10.11

To install python 3.10.11 for l4t32.7.1 follow these steps, once done, come back here.

Install OpenCV from package

  1. Download the pre-built .sh installer from here: OpenCV-4.8.0-aarch64.sh, or download it using wget:

    bash
    wget https://github.com/lanzani/jetson-libraries/raw/main/libraries/opencv/l4t32.7.1/py3.10.11/ocv4.8.0/OpenCV-4.8.0-aarch64.sh
  2. Give execution privileges:

    bash
     chmod +x OpenCV-4.8.0-aarch64.sh
  3. To install OpenCV run:

    bash
    sudo ./OpenCV-4.8.0-aarch64.sh --prefix=/usr/local --skip-license --exclude-subdir

    This will install opencv in your system.

  4. Now you need to install runtime dependencies:

    bash
    sudo apt-get update && sudo apt-get upgrade -y --autoremove
    bash
    sudo apt-get -y install \
        libtesseract4 \
        libatlas3-base
    bash
     sudo apt-get clean
  5. Install numpy with pip:

    bash
      pip3 install numpy
  6. To check if the installation went good you can type:

    bash
    opencv_version

    The output should be the opencv version you desired.

    WARNING

    If you got some error, you may miss some runtime dependencies, to solve that, go to the section below.

  7. To check if python has the right opencv version in the scope and to see the build details you can run:

    bash
    python3 -c "import cv2; print('OpenCV version:', str(cv2.__version__)); print(cv2.getBuildInformation())"
  8. To be sure that opencv is properly using cuda (and the gpu) try to run one of these python scripts.

Congratulations! You now have OpenCV 4.8.0 🎉

If you are encountering some problems feel free to open an issue.

Check for missing runtime dependencies

If you got some error when importing cv2 in python or executing opencv_version, you may miss some dependencies. To find those follow the steps:

Go to the opencv installation folder:

bash
cd /usr/local/lib/python3.6/site-packages/cv2/python3.6

Find missing dynamic dependencies:

bash
ldd cv2.cpython-36m-aarch64-linux-gnu.so | grep found

Proceed to install the missing dependencies with sudo apt-get install ...

Build from source

Great video by JetsonHacks.