63 lines
1.6 KiB
Docker
63 lines
1.6 KiB
Docker
FROM python:3.10-slim
|
|
|
|
# Install system dependencies for OpenCV and GStreamer
|
|
RUN apt-get update && apt-get install -y \
|
|
build-essential \
|
|
cmake \
|
|
git \
|
|
libgtk2.0-dev \
|
|
pkg-config \
|
|
libavcodec-dev \
|
|
libavformat-dev \
|
|
libswscale-dev \
|
|
libv4l-dev \
|
|
libxvidcore-dev \
|
|
libx264-dev \
|
|
libjpeg-dev \
|
|
libpng-dev \
|
|
libtiff-dev \
|
|
gfortran \
|
|
openexr \
|
|
libatlas-base-dev \
|
|
python3-dev \
|
|
libgstreamer1.0-dev \
|
|
libgstreamer-plugins-base1.0-dev \
|
|
gstreamer1.0-tools \
|
|
gstreamer1.0-plugins-good \
|
|
gstreamer1.0-plugins-bad \
|
|
gstreamer1.0-plugins-ugly \
|
|
gstreamer1.0-libav \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install numpy separately to avoid recompilation during opencv build
|
|
RUN pip install numpy
|
|
|
|
# Clone OpenCV and OpenCV contrib
|
|
WORKDIR /opt
|
|
RUN git clone --branch 4.8.0 https://github.com/opencv/opencv.git && \
|
|
git clone --branch 4.8.0 https://github.com/opencv/opencv_contrib.git
|
|
|
|
# Build OpenCV with GStreamer support
|
|
WORKDIR /opt/opencv/build
|
|
RUN cmake -D CMAKE_BUILD_TYPE=Release \
|
|
-D CMAKE_INSTALL_PREFIX=/usr/local \
|
|
-D OPENCV_EXTRA_MODULES_PATH=/opt/opencv_contrib/modules \
|
|
-D WITH_GSTREAMER=ON \
|
|
-D WITH_V4L=ON \
|
|
-D WITH_LIBV4L=ON \
|
|
-D BUILD_opencv_python3=ON \
|
|
-D BUILD_opencv_python2=OFF \
|
|
-D BUILD_EXAMPLES=OFF \
|
|
-D BUILD_TESTS=OFF \
|
|
-D BUILD_PERF_TESTS=OFF \
|
|
-D PYTHON_EXECUTABLE=$(which python3) \
|
|
.. && \
|
|
make -j"$(nproc)" && \
|
|
make install && \
|
|
ldconfig
|
|
|
|
RUN pip install redis
|
|
COPY reader.py /app/reader.py
|
|
|
|
CMD ["python3", "/app/reader.py"]
|