opencv-python icon indicating copy to clipboard operation
opencv-python copied to clipboard

USB Webcam does not work in the newer version: 4.7.0.72

Open gunarakulangunaretnam opened this issue 1 year ago • 6 comments

USB Webcam does not work in the newer version: 4.7.0.72

I wrote a simple script to read frames from a webcam, it works fine with laptop-attached webcams. When I try to use with the USB-based webcam (not-branded webcam), it returns the following error.

[ WARN:[email protected]] global cap_msmf.cpp:1759 CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -2147024809

My Code:

import cv2


cap = cv2.VideoCapture(2)

while True:

    
    ret, frame = cap.read()
    

    if ret:

        cv2.imshow('Input', frame)
    else:
        print("dsd")

    c = cv2.waitKey(1)
    if c == 27:
        break

When I install the older version of OpenCV-python: 4.5.5.62, it works fine, I think the issue is with the newer release.

Please take a consideration on it.

gunarakulangunaretnam avatar Apr 17 '23 15:04 gunarakulangunaretnam

could you run the same code with old and new OpenCV versions with debug options and collect logs. To enable debug logging you need to set the following environment variables OPENCV_LOG_LEVEL=DEBUG, OPENCV_VIDEOIO_DEBUG=1

asmorkalov avatar Apr 21 '23 13:04 asmorkalov

I'm also getting this error with the USB webcam. Does anyone have a solution regarding this?

harshkasat avatar Jun 27 '23 19:06 harshkasat

Please try the previous recommendation to give us information for debugging.

asmorkalov avatar Jun 29 '23 09:06 asmorkalov

Please try the previous recommendation to give us information for debugging.

asmorkalov avatar Sep 12 '23 07:09 asmorkalov

Hi! I can confirm the same problem with 4.8.x version using usb cam. Had to downgrade to 4.5 to get it working, as mentioned by the author.

Maculapse avatar Dec 21 '23 21:12 Maculapse

@Maculapse could you run the same code with old and new OpenCV versions with debug options and collect logs. To enable debug logging you need to set the following environment variables OPENCV_LOG_LEVEL=DEBUG, OPENCV_VIDEOIO_DEBUG=1

asmorkalov avatar Dec 22 '23 11:12 asmorkalov

我也是4.8版本也遇到这个问题,自己的电脑上没问题,在客户的电脑上死活不行

ArptPlank avatar Jul 05 '24 07:07 ArptPlank