1

I want to set up a virtual webcam on windows. Final aim being directing the output of OpenCV to meet (Say GMeet) frame by frame

Steps Done

A normal pip install showed the package not found. I installed using the wheel distribution for python version 3.8.7 from pypi. I also installed OBS Studio, and OBS-VirtualCam 2.0.4. As mentioned in the installation guide here. I extracted the zip from the OBS-VritualCam release and could successfully start the virtualcam from the .dll file in the /bin/32bit directory by

regsvr32 /n /i:1 "obs-virtualsource.dll"

I could import pyvirtualcam!

But on running the code given with the package.

import pyvirtualcam
import numpy as np

with pyvirtualcam.Camera(width=1280, height=720, fps=30) as cam:
    while True:
        frame = np.zeros((cam.height, cam.width, 4), np.uint8) # RGBA
        frame[:,:,:3] = cam.frames_sent % 255 # grayscale animation
        frame[:,:,3] = 255
        cam.send(frame)
        cam.sleep_until_next_frame()

I get the error

Traceback (most recent call last):
File "pyvirtualcam.py", line 1, in
import pyvirtualcam
File "D:\sem7\DSL\Project\try\pyvirtualcam.py", line 4, in
with pyvirtualcam.Camera(width=1280, height=720, fps=30) as cam:
AttributeError: partially initialized module 'pyvirtualcam' has no attribute 'Camera' (most likely due to a circular import)

Sources: Capturing and manipulating a webcam feed and exposing it as a "virtual webcam" - in Python, on Windows

Kaivalya Swami
  • 91
  • 1
  • 12

1 Answers1

0

Rename your file to something else than pyvirtualcam.py otherwise Python tries to import that one when you do import pyvirtualcam.

letmaik
  • 3,348
  • 1
  • 36
  • 43