cv2.error: OpenCV(4.8.0) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:971:

Record 2

During the process of capturing the camera, the following error message appears

Solution 1 : Check whether to use the built-in camera or an external camera, and modify the number. If there is only one camera, the number is 0, run, and the camera is retrieved successfully. Correspondingly, change the number to 0, 1... or other

cap=cv2.VideoCapture(0)

Solution 2 :

In case of error

Place the required video or picture path in the path folder where the code is located, and the path name cannot contain Chinese characters.

If the operation ends midway and an error is reported, it may be because the video has finished playing.

Solution 3 : Refer to the original article of CSDN blogger "hongye0v0", original link: https://blog.csdn.net/hongye0v0/article/details/132876083

Uninstall opencv-python and opencv-contrib-python and reinstall opencv-python.

Personal test is effective.

pip uninstall opencv-python
pip uninstall opencv-contrib-python
pip install opencv-python  -i https://pypi.tuna.tsinghua.edu.cn/simple

おすすめ

転載: blog.csdn.net/gzy13477/article/details/133070619
おすすめ