Skip to content

Conversation

@cbarkr
Copy link

@cbarkr cbarkr commented Dec 18, 2025

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() and draw_line_upwards_from_point() - 2/3 functions using cv2 methods - from the image_helper module

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unnecessary system dependency

1 participant