MacOS下OpenCV + Python+PyQt5 多进程Bug
环境
- macOS Catalina 10.15.7
 - pyqt5
 - opencv
 
问题
- 多进程情况下
cv2.resize或者cv2.cvtColor引发程序崩溃 - 使用PyQt5与opencv的冲突
 
可能的解决方案
- 安装
opencv-python-headless替换opencv-python - 设置 
cv2.setNumThreads(0) 
OpenCV will try to set the number of threads for the next parallel region. If
threads == 0, OpenCV will disable threading optimizations and run all its functions sequentially. Passingthreads < 0will reset threads number to system default. This function must be called outside of parallel region.
1
2import multiprocessing as mp
mp.set_start_method('spawn')
参考
OpenCV + Python multiprocessing breaks on OSX
pytorch dataloader stucked if using opencv resize method
OpenCV 4.4.0.44 macOS Catalina - Hang/Frozen