Skip to content

Built-in virtual camera does not work with OpenCV #3635

@upgradeQ

Description

@upgradeQ

Platform

Operating system and version: Windows 7 64 bit
OBS Studio version: 26.0.2 64 bit
Python version: Python 3.6 64 bit

Expected Behavior

Built-in virtual camera should be usable with OpenCV python package

Current Behavior

OpenCV window shows black screen if OBS Virtual Camera is selected.

Steps to Reproduce

  1. Start virtual camera
  2. Run check_cv.py

Additional information

Black screen
screenshot
However OpenCV works with obs-virtual-cam plugin, if OBS-Camera is selected.
screenshot
Code used to check it:

# check_cv.py

import numpy as np
import cv2 as cv

def check_cam_by_index(i):
    cap = cv.VideoCapture(i)
    cap.set(cv.CAP_PROP_FRAME_WIDTH, 1280)
    cap.set(cv.CAP_PROP_FRAME_HEIGHT, 720)

    if not cap.isOpened():
        print("Cannot open camera")
        exit()
    while True:
        # Capture frame-by-frame
        ret, frame = cap.read()
        # if frame is read correctly ret is True
        if not ret:
            print("Can't receive frame (stream end?). Exiting ...")
            break
        cv.imshow('frame',frame)
        if cv.waitKey(1) == ord('q'):
            break
    # When everything done, release the capture
    cap.release()
    cv.destroyAllWindows()


def check_multiple():
    for i in range(-1,10):
        try:
            print(f'checking camera #{i}')
            check_cam_by_index(i)
        except:
            continue

#check_multiple() # 2 is index of OBS Virtual Camera , 0 is index of OBS-Camera
check_cam_by_index(2) 

I've tried reinstalling OBS, virtual cam drivers, running it as admin - same result.

Also, built-in virtual webcam is accessible from imageio by index, but with high CPU usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy