Skip to content

Why can opencv-python-headless run cv2.imshow() on Mac M1? #766

@Chris-fullerton

Description

@Chris-fullerton

Expected behaviour

opencv-python-headless runs cv2.imshow() correctly on Mac M1, but it shouldn't.

According to opencv-python-headless - PyPI, headless version is suitable for servers and does not provide ui-related functions like cv2.imshow():

b. Packages for server (headless) environments (such as Docker, cloud environments etc.), no GUI library dependencies

These packages are smaller than the two other packages above because they do not contain any GUI functionality (not compiled with Qt / other GUI components). This means that the packages avoid a heavy dependency chain to X11 libraries and you will have for example smaller Docker images as a result. You should always use these packages if you do not use cv2.imshow et al. or you are using some other package (such as PyQt) than OpenCV to create your GUI.

Actual behaviour

When I tried to install insightface(https://github.com/deepinsight/insightface) package, it would automatically install opencv-python-headless(seems like the installation was fallowing the requirements of setup.py from insightface, but I'm not sure about it), and I can run cv2.imshow() correctly(use webcam with cv2.VideoCapture(0) and show by frames with cv2.imshow()).

Steps to reproduce

example code

How I build my conda env(insightface==0.7.2):

conda create -n test python=3.8
conda activate test
pip install insightface
import cv2

if __name__ == '__main__':

  # 開啟 RTSP 串流
  vidCap = cv2.VideoCapture(0)

  while True:
      ret, image = vidCap.read()

      cv2.namedWindow('image_display', cv2.WINDOW_AUTOSIZE)
      cv2.imshow('image_display', image)
      cv2.waitKey(1)

      if cv2.waitKey(1) & 0xff == ord('q'):
          break

  vidCap.release()
  cv2.destroyAllWindows()
operating system macOS Ventura 13.0
architecture (e.g. x86) Apple M1, 2020
opencv-python version

conda list | grep opencv:

opencv-python-headless    4.7.0.68                 pypi_0    pypi
Issue submission checklist
  • This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
  • I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
  • The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
  • I'm using the latest version of opencv-python (the problem is about opencv-python-headless)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions