當前位置: 首頁>>代碼示例>>Python>>正文


Python cv.CV_CAP_PROP_FRAME_WIDTH屬性代碼示例

本文整理匯總了Python中cv.CV_CAP_PROP_FRAME_WIDTH屬性的典型用法代碼示例。如果您正苦於以下問題:Python cv.CV_CAP_PROP_FRAME_WIDTH屬性的具體用法?Python cv.CV_CAP_PROP_FRAME_WIDTH怎麽用?Python cv.CV_CAP_PROP_FRAME_WIDTH使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在cv的用法示例。


在下文中一共展示了cv.CV_CAP_PROP_FRAME_WIDTH屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: init_camera

# 需要導入模塊: import cv [as 別名]
# 或者: from cv import CV_CAP_PROP_FRAME_WIDTH [as 別名]
def init_camera(self):
        # create the device
        self._device = hg.cvCreateCameraCapture(self._index)

        # Set preferred resolution
        cv.SetCaptureProperty(self._device, cv.CV_CAP_PROP_FRAME_WIDTH,
                              self.resolution[0])
        cv.SetCaptureProperty(self._device, cv.CV_CAP_PROP_FRAME_HEIGHT,
                              self.resolution[1])

        # and get frame to check if it's ok
        frame = hg.cvQueryFrame(self._device)
        # Just set the resolution to the frame we just got, but don't use
        # self.resolution for that as that would cause an infinite recursion
        # with self.init_camera (but slowly as we'd have to always get a
        # frame).
        self._resolution = (int(frame.width), int(frame.height))

        #get fps
        self.fps = cv.GetCaptureProperty(self._device, cv.CV_CAP_PROP_FPS)
        if self.fps <= 0:
            self.fps = 1 / 30.

        if not self.stopped:
            self.start() 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:27,代碼來源:camera_opencv.py

示例2: __init__

# 需要導入模塊: import cv [as 別名]
# 或者: from cv import CV_CAP_PROP_FRAME_WIDTH [as 別名]
def __init__(self):
        cv.NamedWindow( color_tracker_window, 1 )
        self.capture = cv.CaptureFromCAM(0)
        width = 640
        height = 480
        cv.SetCaptureProperty(self.capture,cv.CV_CAP_PROP_FRAME_WIDTH,width)
        cv.SetCaptureProperty(self.capture,cv.CV_CAP_PROP_FRAME_HEIGHT,height)
        #self.capture = cv.CaptureFromFile('crash-480.mp4') 
開發者ID:alduxvm,項目名稱:rpi-opencv,代碼行數:10,代碼來源:color-1.py

示例3: FPV_init

# 需要導入模塊: import cv [as 別名]
# 或者: from cv import CV_CAP_PROP_FRAME_WIDTH [as 別名]
def FPV_init():
    global capture
    global latest_frame
    #cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_WIDTH, 640)
    #cv.SetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_HEIGHT, 480) 
開發者ID:cmusatyalab,項目名稱:elijah-provisioning,代碼行數:7,代碼來源:FPV_client.py

示例4: download_and_process_video

# 需要導入模塊: import cv [as 別名]
# 或者: from cv import CV_CAP_PROP_FRAME_WIDTH [as 別名]
def download_and_process_video(save_path, row):
    video_id = row['VideoID']
    video_path = row['video_path']
    full_path = os.path.join(save_path, video_path)
    if os.path.exists( full_path ):
        return

    start = row['Start']
    end = row['End']

    print video_id

    if os.path.exists('tmp.mp4'):
        os.system('rm tmp.mp4')

    try: # 다운로드 포기
        youtube = YouTube("https://www.youtube.com/watch?v="+video_id)
    except:
        print "다운로드 포기"
        return

    youtube.set_filename('tmp')

    try: # 360p로 받아보고 안되면 예외처리
        video = youtube.get('mp4', '360p')
    except:
        ipdb.set_trace()
    video.download('.')

    cap = cv2.VideoCapture( 'tmp.mp4' )
    fps = cap.get(cv.CV_CAP_PROP_FPS)
    fourcc = int(cap.get(cv.CV_FOURCC(*'XVID')))
    w = int(cap.get(cv.CV_CAP_PROP_FRAME_WIDTH))
    h = int(cap.get(cv.CV_CAP_PROP_FRAME_HEIGHT))

    out = cv2.VideoWriter( full_path, fourcc, fps, (w,h))

    start_frame = int(fps * start)
    end_frame = int(fps * end)

    frame_count = 0
    while frame_count < end_frame:
        ret, frame = cap.read()
        frame_count += 1

        if frame_count >= start_frame:
            out.write(frame)

    cap.release()
    out.release() 
開發者ID:jazzsaxmafia,項目名稱:video_to_sequence,代碼行數:52,代碼來源:download_videos.py


注:本文中的cv.CV_CAP_PROP_FRAME_WIDTH屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。