Skip to content

Borda/docker_python-opencv-ffmpeg

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker: Python-OpenCV-FFmpeg(-CUDA)

Repository for clean Dockerfile containing FFmpeg, OpenCV4 and Python2/3, based on Ubuntu 22.04 LTS.

Tags

  • :cpu-pyX.y-cvX.y.z for Python 2.x/3.x, OpenCV 4.10.x, FFmpeg
  • :gpu-pyX.y-cvX.y.z for Python 2.x/3.x, OpenCV 4.10.x, FFmpeg with CUDA 11.4 support

Build

Publish Docker Image Docker Build Status DockerHub Pulls Docker

First you need to install docker on your local computer, see following tutorial. Note, for running the docker properly you have be logged as superuser otherwise you will face many partial issues which sometimes does not make much sense.

You can build it on your own, note it takes lots of time, be prepared.

git clone <git-repository>
cd docker_python-opencv-ffmpeg
docker image build -t python-opencv-ffmpeg:py3.9 -f cpu/Dockerfile --build-arg PYTHON_VERSION=3.9 .

To build other versions, select different Dockerfile.

docker image list
docker run --rm -it python-opencv-ffmpeg:py3.8 bash
docker image rm python-opencv-ffmpeg:py3.8

Other option is using already build image from DockerHub which is significantly faster. it basically download the already build image.

docker pull borda/docker_python-opencv-ffmpeg

Cleaning In case you fail with some builds, you may need to clean your local storage.

docker image prune

or Docker - How to cleanup (unused) resources

docker images | grep "none"
docker rmi $(docker images | grep "none" | awk '/ / { print $3 }')

or remove all - Some way to clean up

docker rm -vf $(docker ps -aq)
docker rmi -f $(docker images -aq)
docker volume prune -f

Usage

Image has OpenCV4, Python2.7/3.9 and FFmpeg ready to use. Example:

docker run --rm -it -v $PWD:/srv borda/docker_python-opencv-ffmpeg python
>>> import cv2; cv2.VideoCapture(0).read()
# truncated for transparency
(True, array([[[ 0, 43, 37], ...]], dtype=uint8))

Note, server usually doe not have webcam :)

Languages

  • Dockerfile 100.0%