I'm creating a proof of concept, I have a CCTV Setup & the only output i have access to is a HDMI port, can I use say a capture card or OBS, as an input for openCV all the code i've looked at uses a raspberry pi with a PiCam an. so im just a little lost on limitations of functionality
Asked
Active
Viewed 2,195 times
1 Answers
0
This works for me using USB HDMI capture card:
#!/usr/bin/env python
import numpy as np
import cv2
import datetime, time
import os, sys
cap = cv2.VideoCapture(0)
cv2_version_major = int(cv2.__version__.split('.')[0])
if cv2_version_major > 3 :
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1280)
else : # before 3.0
cap.set( cv2.cv.CV_CAP_PROP_FRAME_WIDTH, 1920)
cap.set( cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, 1280)
start_time = time.time()
total_frames = 0
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Display the resulting frame
cv2.imshow('frame', cv2.pyrDown(frame))
# add some processing here if you like
total_frames += 1
fps = total_frames / (time.time() - start_time)
print 'FPS %.02f \r' % fps,
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

lenik
- 23,228
- 4
- 34
- 43