How to edit camera frames using python?

871 Views Asked by At

I need to edit frames of computer webcam during a live streaming (google.meet, Skype, FaceTime..).

I tried using OpenCV, but I don't know how to redirect the output to replace original frames of the camera or render output to the camera path.

import cv2

video = cv2.VideoCapture(0)
if not video.isOpened():
    raise Exception('Video is not opened!')

while True:
    ret, frame = video.read() # Capture frame-by-frame
    
    # here edits like blur...
    blurred_frame = cv2.blur(frame, (10, 10))
    cv2.imshow('Video', blurred_frame) # Display the resulting frame

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# release the capture
video.release()
cv2.destroyAllWindows()

Someone can help me solving this problem?

I'm running on macOS Catalina, with Python 3.7.4

1

There are 1 best solutions below

2
On

Just display the frames in a window and use open broadcaster studio (obs) app to capture that window and use obs's virtual camera in zoom