opencv / opencv-python

Automated CI toolchain to produce precompiled opencv-python, opencv-python-headless, opencv-contrib-python and opencv-contrib-python-headless packages.
https://pypi.org/project/opencv-python/
MIT License
4.44k stars 835 forks source link

opencv-python-headless depends on windows media feature pack after 4.7 update #771

Open matteoaletti opened 1 year ago

matteoaletti commented 1 year ago

Expected behaviour

On previous version (4.6.0.66) of opencv-python-headless, the package did not depend on windows media feature pack.

>> pyi-bindepend.exe "C:\Users\user\anaconda3\envs\cv246\Lib\site-packages\cv2\cv2.pyd"
C:\Users\user\anaconda3\envs\cv246\Lib\site-packages\cv2\cv2.pyd {'WSOCK32.dll', 'ole32.dll', 'KERNEL32.dll', 'OLEAUT32.dll', 'python3.dll'}

Actual behaviour

More recently (4.7.0.68) of opencv-python-headless, the package depends on windows media feature pack that is not available in windows docker image (windows/servercore:ltsc2019) .

>> pyi-bindepend.exe "C:\Users\user\anaconda3\envs\cv247\Lib\site-packages\cv2\cv2.pyd"
C:\Users\user\anaconda3\envs\cv247\Lib\site-packages\cv2\cv2.pyd {'MFReadWrite.dll', 'MF.dll', 'MFPlat.DLL', 'OLEAUT32.dll', 'KERNEL32.dll', 'SHLWAPI.dll', 'ole32.dll', 'WSOCK32.dll', 'python3.dll'}

Steps to reproduce

I have installed opencv-python-headless in a conda python 3.9 environment with

pip install opencv-python-headless

asmorkalov commented 1 year ago

@matteoaletti Thanks for the issue report. I have not found explicit changes in setup.py or build scripts that manage Media Foundation dependency. Looks like it's some side effect of Python 3.6 -> 3.7 or Github actions environment update. Could you list other container specific issues here. I want to discuss the next steps with colleagues.

matteoaletti commented 1 year ago

Thank you for your answer.

I am not sure that there are any other container specific issues. We are using a conda environment with python 3.9 inside a windows docker container (windows/servercore:ltsc2019) and when we use the opencv-python-headless 4.6.0.66 we can import cv2. Same environment with version 4.7.0.68 and our tests produces an error during the import of cv2:

ImportError: DLL load failed while importing cv2: The specified module could not be found

We tried to debug it ourselves and found out the new DLL dependencies mentioned above. Everything works fine outside the container in a normal windows OS where those libraries are available.

For now, we simply pinned the version to the latest 4.6.

alalek commented 1 year ago

@asmorkalov Need to check G-API module and/or obsensor feature.

yoonjs2 commented 10 months ago

Any news to resolve this issue after 4.8 version? I encountered this issue when import cv2 in aws codebuild docker container image (windows server 2019) . I tried 4.6 4.7 4.8 but only 4.6 works.

asmorkalov commented 10 months ago

Decided to switch to plugins for videoio in headless package on Windows. In case of good luck, it'll be part of 4.9.0.x.

matteoaletti commented 8 months ago

@asmorkalov I see that a new release of opencv is out, was this switch included in 4.9.0.80 ?

I still see the same dependencies (and errors) as for versions 4.7 and 4.8

Avasam commented 1 month ago

Likely duplicated by https://github.com/opencv/opencv-python/issues/856 (although that issue is more popular)