Hi,
Can anyone help me with streaming video from OpenCV (using Python, or C if necessary) into OBS?
I've had a look at the API docs but they're rather bewildering to a new OBS user, and I can't find any similar examples. I think I need to use obs_source_draw() using the frame data I have but I'm not sure how.
Here's some example Python code that captures the camera in OpenCV, displays it and writes the video out to a file. Frame data is in the "frame" variable, I'd like to have this as a custom source:
Above code is just a simple example. My code is actually more complex than this; I'm doing object recognition and tracking, etc.
Any help would be greatly appreciated!
Many thanks,
Zappso
Can anyone help me with streaming video from OpenCV (using Python, or C if necessary) into OBS?
I've had a look at the API docs but they're rather bewildering to a new OBS user, and I can't find any similar examples. I think I need to use obs_source_draw() using the frame data I have but I'm not sure how.
Here's some example Python code that captures the camera in OpenCV, displays it and writes the video out to a file. Frame data is in the "frame" variable, I'd like to have this as a custom source:
Python:
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
ret, frame = cap.read()
h, w, c = frame.shape
print(h, w, c)
fourcc = cv2.VideoWriter_fourcc('m','p','4','v')
out = cv2.VideoWriter('output.mp4', fourcc, 15.0, (w, h))
while(True):
ret, frame = cap.read()
out.write(frame)
frame = cv2.resize(frame, (0,0), fx=0.5, fy=0.5)
cv2.imshow("Frame", frame)
ch = cv2.waitKey(1)
if ch & 0xFF == ord('q'):
break
cap.release()
out.release()
cv2.destroyAllWindows()
Above code is just a simple example. My code is actually more complex than this; I'm doing object recognition and tracking, etc.
Any help would be greatly appreciated!
Many thanks,
Zappso