本文整理汇总了Python中cv.CV_CAP_PROP_FRAME_HEIGHT属性的典型用法代码示例。如果您正苦于以下问题:Python cv.CV_CAP_PROP_FRAME_HEIGHT属性的具体用法?Python cv.CV_CAP_PROP_FRAME_HEIGHT怎么用?Python cv.CV_CAP_PROP_FRAME_HEIGHT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类cv
的用法示例。
在下文中一共展示了cv.CV_CAP_PROP_FRAME_HEIGHT属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_camera
# 需要导入模块: import cv [as 别名]
# 或者: from cv import CV_CAP_PROP_FRAME_HEIGHT [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()
示例2: __init__
# 需要导入模块: import cv [as 别名]
# 或者: from cv import CV_CAP_PROP_FRAME_HEIGHT [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')
示例3: FPV_init
# 需要导入模块: import cv [as 别名]
# 或者: from cv import CV_CAP_PROP_FRAME_HEIGHT [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)
示例4: download_and_process_video
# 需要导入模块: import cv [as 别名]
# 或者: from cv import CV_CAP_PROP_FRAME_HEIGHT [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()