opencv / opencv/opencv-python

USB Webcam does not work in the newer version: 4.7.0.72

Open
#834 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

incomplete
Dominant language
Python
Stars
5.4k
Forks
1k
Avg merge
22h 17m
Merged PRs (30d)
3

Description

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:1@2.601] 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied cv2.VideoCapture(2) script with the USB webcam on OpenCV-Python 4.7.0.72, then compare it with 4.5.5.62. Investigate the MSMF grabFrame warning and determine the cause of the version-specific failure; done means USB webcam frames are read successfully on the newer release.

Written by the indexing model from the issue text.

Assessment

Tech stack
opencv, python
Domain
computer-vision
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.