rt-utils
rt-utils copied to clipboard
Remove unnecessary system dependency
Resolves #135
Summary
As explained in the issue, rt-utils appears to run headlessly, in which case libGL is not necessary if the opencv-python-headless package is used instead of opencv-python.
This PR
- Changes
opencv-python->opencv-python-headless - Removes libGL from the README
- Adds some sanity checks for
find_mask_contours()anddraw_line_upwards_from_point()- 2/3 functions usingcv2methods - from theimage_helpermodule
Testing
I compared pytest output between the main branch and my own when run in a Docker container defined by the following Dockerfile:
FROM ubuntu
WORKDIR /app
# Explicitly *not* installing LibGL (libgl1 && libglib2.0-0)
RUN apt-get update && \
apt-get install -y python3 python3-pip python3-venv && \
rm -rf /var/lib/apt/lists/*
COPY . .
ENV PATH="/opt/venv/bin:$PATH"
RUN python3 -m venv /opt/venv && \
pip3 install pytest && \
pip3 install --no-cache-dir -r requirements.txt
CMD ["pytest"]
In main, the following error will occur:
rt_utils/__init__.py:1: in <module>
from .rtstruct import RTStruct
rt_utils/rtstruct.py:5: in <module>
from . import ds_helper, image_helper
rt_utils/ds_helper.py:2: in <module>
from rt_utils.image_helper import get_contours_coords
rt_utils/image_helper.py:5: in <module>
import cv2 as cv
/opt/venv/lib/python3.12/site-packages/cv2/__init__.py:181: in <module>
bootstrap()
/opt/venv/lib/python3.12/site-packages/cv2/__init__.py:153: in bootstrap
native_module = importlib.import_module("cv2")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E ImportError: libGL.so.1: cannot open shared object file: No such file or directory