Sign inSign up

m1l0/opencv

By m1l0

Updated over 2 years ago

OpenCV build from source

Image
Machine learning & AI
Data science
1

4.0K

m1l0/opencv repository overview

M1L0 OpenCV Docker image

Image of OpenCV built from source

There are 2 kinds of images: plain CPU images and GPU images

The GPU Images are built using nvidia CUDA images as source in a multistage build process.

Supported builds

OpenCV versions:

  • 4.5.5
  • 4.6.0
  • 4.7.0
  • 4.8.0
  • 4.9.0

All images are built using python 3.10.13, 3.11.6, 3.12.2 and Ubuntu 22.04

The GPU images are built to support the CUDA arch of 6.1, 7.0, 7.5, 8.0, 8.6

Tagging and labels

CPU images are tagged in the following format:

<OPENCV VERSION>-<PYTHON VERSION>-<UBUNTU_VERSION>

e.g. 4.5.5-python3.10.9-ubuntu22.04 indicates that the image was compiled with 4.5.5 version of OpenCV with python version of 3.10.9 and Ubuntu version of 22.04

Likewise for GPU images, they are tagged in the following format:

<OPENCV VERSION>-<CUDA VERSION>-<CUDNN VERSION>-<PYTHON VERSION>-<UBUNTU VERSION>

e.g. 4.5.5-cuda11.8.0-cudnn8-python3.10.9-ubuntu22.04 indicates that the image was compiled with OpenCV 4.5.5, with CUDA version 11.8.0, CUDNN 8.0, python 3.10.9 and Ubuntu version 22.04

Multi-stage builds

The OpenCV built artufacts are installed into /installed.

It can be used in multi-stage builds. For example to use the python bindings

FROM m1l0/opencv:4.5.5-python3.10.9-ubuntu22.04 as base

...

FROM ubuntu:latest
...

# copies the opencv libs from base image
COPY --from=base /installed /usr/local

# symlinks the shared lib into python site-packages
RUN ln -s /usr/local/lib/python3.6/site-packages/cv2/python-3.6/cv2.cpython-36m-x86_64-linux-gnu.so /usr/local/lib/python3.6/site-packages/cv2.so && \
    cd /usr/share/pkgconfig && \
    ln -s /usr/local/lib/pkgconfig/opencv4.pc opencv4.pc && \
    ldconfig

To use it with C++ bindings:

FROM m1l0/opencv:4.5.5-python3.10.9-ubuntu22.04 as base

...

FROM ubuntu:latest
...

# copies the opencv libs from base image
COPY --from=base /installed /usr/local

RUN cd /usr/share/pkgconfig && \
    ln -s /installed/lib/pkgconfig/opencv4.pc opencv4.pc && \
    echo "/installed/lib" >> /etc/ld.so.conf.d/opencv4.conf && \
    ldconfig

Built by Chee Yeo https://cheeyeo.dev

LICENSE

MIT License

Copyright (c) [2023] [Chee Yeo]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Tag summary

Content type

Image

Digest

sha256:d672ba00a

Size

718.4 MB

Last updated

over 2 years ago

docker pull m1l0/opencv:4.9.0-python3.10.13-ubuntu22.04