【问题标题】:OpenCV Load Video from a capture card or OBS Studio FaceRecogitionOpenCV 从采集卡或 OBS Studio FaceRecogition 加载视频
【发布时间】:2020-05-21 12:23:50
【问题描述】:

我正在创建概念验证,我有一个闭路电视设置,我可以访问的唯一输出是 HDMI 端口,我可以使用采集卡或 OBS 作为 openCV 所有代码的输入吗?我看过使用带有 PiCam 的树莓派。所以我只是对功能的限制有点迷失

【问题讨论】:

    标签: python video-capture obs


    【解决方案1】:

    这适用于我使用 USB HDMI 采集卡:

    #!/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()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-15
      • 2017-08-25
      • 2015-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-06
      • 1970-01-01
      相关资源
      最近更新 更多