GithubHelp home page GithubHelp logo

borda / docker_python-opencv-ffmpeg Goto Github PK

View Code? Open in Web Editor NEW

This project forked from valian/docker-python-opencv-ffmpeg

73.0 73.0 30.0 85 KB

Dockerfile containing FFmpeg, OpenCV4 and Python2/3, based on Ubuntu LTS

Home Page: https://hub.docker.com/r/borda/docker_python-opencv-ffmpeg/

Dockerfile 100.00%
cuda docker-image ffmpeg opencv4 python python2 python3 ubuntu

docker_python-opencv-ffmpeg's Introduction

Hi there ๐Ÿ‘‹ Visit counter

I have been working in Machine learning and Data science for several years. I have done my Ph.D. in Medical Imaging. I have gained practical experience working for a few IT companies as a consultant, data scientist, or research engineer. I focus on exploring interesting world problems and solving them with state-of-the-art techniques.

Academic track: I have published several journal articles and papers on international conferences such as ISBI, ICIP, ACCV, and MICCAI workshops. I am also a reviewer for these conferences and other IEEE journals. I was the main organizer of the ANHIR challenge.

ORCID ResearchGate

Developer track: I have created several open-source Python packages, and I am a leading contributor to PyTorch-Lightning and other Lightning projects. I also actively participate in other well-known projects like auto-sklearn, yolov5, dipy, etc., with writing code, reporting issues, building CI/CD, and reviewing PRs.

Manager track: I led a small team while developing a video analysis tool. I have been leading & managing the Lightning team responsible for our open-source projects.

simple GH stats

๐ŸŒ Get in Touch:

JirkaBorovec in/jirka-borovec jirkaborovec @jborovec jirka

docker_python-opencv-ffmpeg's People

Contributors

borda avatar dependabot[bot] avatar valian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker_python-opencv-ffmpeg's Issues

cv2 import error

  • Docker image: borda/docker_python-opencv-ffmpeg:gpu-py3.7-cv4.4.0
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/dist-packages/cv2/__init__.py", line 96, in <module>
    bootstrap()
  File "/usr/local/lib/python3.7/dist-packages/cv2/__init__.py", line 86, in bootstrap
    import cv2
ImportError: libQt5Core.so.5: cannot open shared object file: No such file or directory

Docker build on arm64 fails

Small error when building on arm64:

 ---> 9f0e2cb95ad0
Step 5/5 : RUN update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 &&     update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1 &&     python --version &&     python -c "import cv2 ; print(cv2.__version__)"
 ---> Running in 75831159731a
update-alternatives: using /usr/bin/python3.8 to provide /usr/bin/python3 (python3) in auto mode
update-alternatives: using /usr/bin/python3.8 to provide /usr/bin/python (python) in auto mode
Python 3.8.0
OpenCV bindings requires "numpy" package.
Install it via command:
    pip install numpy
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/numpy/core/__init__.py", line 24, in <module>
    from . import multiarray
  File "/usr/local/lib/python3.8/dist-packages/numpy/core/multiarray.py", line 14, in <module>
    from . import overrides
  File "/usr/local/lib/python3.8/dist-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: libcblas.so.3: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

without opencv

I only need python and ffmpeg.

may I know if possible to provide an option without opencv

Failed to build Opencv with CUDA_ARCH_BIN=8.9, such as RTX 4090

๐Ÿ› Bug

#0 853.9 [ 13%] Built target libprotobuf
#0 853.9 make: *** [Makefile:163: all] Error 2

To Reproduce

Steps to reproduce the behavior:

  1. Go to /gpu/dockerfile
  2. set -D CUDA_ARCH_BIN="6.1 7.5 8.9" \
  3. failed to build at opencv

my dockerfile

FROM nvidia/cuda:11.7.1-cudnn8-devel-ubuntu20.04
ARG PYTHON_VERSION=3.9
ARG OPENCV_VERSION=4.7.0
ARG HOST_XDG_RUNTIME_DIR=/run/user/1000

# Set SHELL to bash
SHELL ["/bin/bash", "-c"]

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
    &&  DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata

RUN TZ=Asia/Taipei \
    && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
    && echo $TZ > /etc/timezone \
    && dpkg-reconfigure -f noninteractive tzdata

RUN mkdir -p $HOST_XDG_RUNTIME_DIR && chmod 700 $HOST_XDG_RUNTIME_DIR

RUN \
    # add sources for older pythons
    apt-get update -qq --fix-missing && \
    apt-get install -y --no-install-recommends software-properties-common && \
    add-apt-repository ppa:deadsnakes/ppa && \
    apt-add-repository universe && \
    apt-get -y update -qq --fix-missing && \
    apt-get -y install --no-install-recommends \
        python${PYTHON_VERSION} \
        python${PYTHON_VERSION}-dev \
        $( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "python${PYTHON_VERSION}-distutils" ) \
        wget \
    && \
    # Set the default python and install PIP packages
    update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \
    update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1 && \
    # install python dependencies
    # sysctl -w net.ipv4.ip_forward=1 ; \
    if [[ "$PYTHON_VERSION" == "2.7" || "$PYTHON_VERSION" == "3.6" ]]; then \
        wget https://bootstrap.pypa.io/pip/$PYTHON_VERSION/get-pip.py --progress=bar:force:noscroll --no-check-certificate ; \
    else \
        apt-get -y install --no-install-recommends python${PYTHON_VERSION}-distutils ; \
        wget https://bootstrap.pypa.io/get-pip.py --progress=bar:force:noscroll --no-check-certificate ; \
    fi && \
    python${PYTHON_VERSION} get-pip.py && \
    rm get-pip.py && \
    rm -rf /var/lib/apt/lists/*

ENV PYTHONPATH="/usr/lib/python${PYTHON_VERSION}/site-packages:/usr/local/lib/python${PYTHON_VERSION}/site-packages"

# install some tools
RUN apt-get update && apt-get install -y \
    git \
    iputils-ping \
    curl \
    wget

# install gstreamer
RUN apt-get update && apt-get install -y \
  libgstreamer1.0-dev \
  libgstreamer-plugins-base1.0-dev \
  libgstreamer-plugins-bad1.0-dev \
  gstreamer1.0-plugins-base \
  gstreamer1.0-plugins-good \
  gstreamer1.0-plugins-bad \
  gstreamer1.0-plugins-ugly \
  gstreamer1.0-libav \
  gstreamer1.0-tools \
  gstreamer1.0-x \
  gstreamer1.0-alsa \
  gstreamer1.0-gl \
  gstreamer1.0-gtk3 \
  gstreamer1.0-qt5 \
  gstreamer1.0-pulseaudio


RUN \
    # Add CUDA libs paths
    CUDA_PATH=(/usr/local/cuda-*) && \
    CUDA=`basename $CUDA_PATH` && \
    echo "$CUDA_PATH/compat" >> /etc/ld.so.conf.d/${CUDA/./-}.conf && \
    ldconfig && \
# Install all dependencies for OpenCV
    apt-get -y update -qq --fix-missing && \
    apt-get -y install --no-install-recommends \
        unzip \
        cmake \
        ffmpeg \
        libtbb2 \
        gfortran \
        apt-utils \
        pkg-config \
        checkinstall \
        qt5-default \
        build-essential \
        libopenblas-base \
        libopenblas-dev \
        liblapack-dev \
        libatlas-base-dev \
        #libgtk-3-dev \
        #libavcodec58 \
        libavcodec-dev \
        #libavformat58 \
        libavformat-dev \
        libavutil-dev \
        #libswscale5 \
        libswscale-dev \
        libjpeg8-dev \
        libpng-dev \
        libtiff5-dev \
        #libdc1394-22 \
        libdc1394-22-dev \
        libxine2-dev \
        libv4l-dev \
        libprotobuf-dev protobuf-compiler \
        libglew-dev \
        libpostproc-dev \
        libeigen3-dev \
        libtbb-dev \
        zlib1g-dev \
        libsm6 \
        libxext6 \
        libxrender1 \
    && \
    pip${PYTHON_VERSION} install numpy && \
# Install OpenCV
    wget https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip -O opencv.zip --progress=bar:force:noscroll && \
    unzip -q opencv.zip && \
    mv /opencv-$OPENCV_VERSION /opencv && \
    rm opencv.zip && \
    wget https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.zip -O opencv_contrib.zip --progress=bar:force:noscroll && \
    unzip -q opencv_contrib.zip && \
    mv /opencv_contrib-$OPENCV_VERSION /opencv_contrib && \
    rm opencv_contrib.zip && \
# Prepare build
    mkdir /opencv/build && \
    cd /opencv/build && \
    cmake \
      -D CMAKE_BUILD_TYPE=RELEASE \
      -D BUILD_PYTHON_SUPPORT=ON \
      -D BUILD_DOCS=ON \
      -D BUILD_PERF_TESTS=OFF \
      -D BUILD_TESTS=OFF \
      -D CMAKE_INSTALL_PREFIX=/usr/local \
      -D OPENCV_EXTRA_MODULES_PATH=/opencv_contrib/modules \
      -D BUILD_opencv_python3=$( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "ON" || echo "OFF" ) \
      -D BUILD_opencv_python2=$( [ ${PYTHON_VERSION%%.*} -lt 3 ] && echo "ON" || echo "OFF" ) \
      -D PYTHON${PYTHON_VERSION%%.*}_EXECUTABLE=$(which python${PYTHON_VERSION}) \
      -D PYTHON_DEFAULT_EXECUTABLE=$(which python${PYTHON_VERSION}) \
      -D BUILD_EXAMPLES=OFF \
      -D WITH_IPP=OFF \
      -D WITH_FFMPEG=ON \
      -D WITH_GSTREAMER=ON \
      -D WITH_V4L=ON \
      -D WITH_LIBV4L=ON \
      -D WITH_TBB=ON \
      -D WITH_QT=ON \
      -D WITH_OPENGL=ON \
      -D WITH_CUDA=ON \
      -D WITH_CUDNN=ON \
      -D WITH_LAPACK=ON \
      #-D WITH_HPX=ON \
      -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \
      -D CMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs \
      # https://kezunlin.me/post/6580691f
      # https://stackoverflow.com/questions/28010399/build-opencv-with-cuda-support
      -D CUDA_ARCH_BIN="6.1 7.5 8.9" \
      -D CUDA_ARCH_PTX="" \
      -D WITH_CUBLAS=ON \
      -D WITH_NVCUVID=ON \
      -D ENABLE_FAST_MATH=1 \
      -D CUDA_FAST_MATH=1 \
      -D BUILD_opencv_cudaoptflow=ON \
      -D BUILD_opencv_cudacodec=ON \
      -D BUILD_opencv_cudev=ON \
      -D BUILD_opencv_cudaarithm=ON \
      -D BUILD_opencv_cudafeatures2d=ON \
      -D BUILD_opencv_cudafilters=ON \
      -D BUILD_opencv_cudaimgproc=ON \
      -D BUILD_opencv_cudaobjdetect=ON \
      -D BUILD_opencv_cudastereo=ON \
      -D BUILD_opencv_cudawarping=ON \
      -D BUILD_opencv_cudacnn=ON \
      -D BUILD_opencv_cudabgsegm=ON \
      -D BUILD_opencv_cudastitching=ON \
#      -D BUILD_opencv_world=OFF \
      -D ENABLE_PRECOMPILED_HEADERS=OFF \
      .. \
    && \
# Build, Test and Install
    cd /opencv/build && \
    make -j$(nproc) && \
    make install && \
    ldconfig && \
    rm -rf /opencv /opencv_contrib /var/lib/apt/lists/* && \
# Call default command.
    ffmpeg -version && \
    #ldd `which ffmpeg` && \
    python --version && \
    python -c "import cv2 ; print(cv2.__version__)"

RUN date

import cv2 got error

uname -a

Linux localhost.localdomain 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

docker -v

Docker version 24.0.6, build ed223bc

run with

docker run --rm -it  borda/docker_python-opencv-ffmpeg:cpu-py3.8-cv4.8.1 python -c "import cv2"

got

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/usr/local/lib/python3.8/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: libQt5Core.so.5: cannot open shared object file: No such file or directory

I found the so file under /lib/x86_64-linux-gnu/

but it works on windows wsl with ubuntu.

any suggestions?

Compiling of opencv

Hi
Am new to the compiling of the opencv . Currently I had compiled the container with the docker file. However when I also install other stuff , the opencv nvdec stop working. I suspect that my subsequent stuff overwrite the new opencv.

Can I check after compiling opencv , I should be not using pip install opencv-python . Is this correct? Thanks

FFMPEG 4.3

Some new features was implemented in ffmpeg version 4.3.

Any Chance of getting an update using 4.3?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.