# -*- coding: utf-8 -*-
"""
Created on Fri Jan 3 21:06:22 2014@author: duan
"""import numpy as np
import cv2cap = cv2.VideoCapture(0)
width=cap.get(3)
height=cap.get(4)
print width
print heightret=cap.set(3,320)
ret=cap.set(4,240)
width=cap.get(3)
height=cap.get(4)
print width
print heightif cap.isOpened():
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
if ret==True:
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # Display the resulting frame
cv2.imshow('frame',gray)
key=cv2.waitKey(1)
if key & 0xFF == ord('q'):
break
elif key & 0xFF == ord('a'):
ret=cap.set(3,640)
ret=cap.set(4,480)
elif key & 0xFF == ord('s'):
ret=cap.set(3,320)
ret=cap.set(4,240)
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
else:
print 'cap is not Opened!'
你可以使用函数cap.get(propId) 来获得视频的一些参数信息。这里
propId 可以是0 到18 之间的任何整数。每一个数代表视频的一个属性,见
下表
其中的一些值可以使用cap.set(propId,value) 来修改,value 就是
你想要设置成的新值。
例如,我可以使用cap.get(3) 和cap.get(4) 来查看每一帧的宽和高。
默认情况下得到的值是640X480。但是我可以使用ret=cap.set(3,320)
和ret=cap.set(4,240) 来把宽和高改成320X240。
VideoCapture_read.py 使用ret=cap.set(3,320)和ret=cap.set(4,240) 来把宽和高改成320X240
转载
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
uCOS-II+uCGUI390在FL2440上的移植(320*240)
在二姨家某位大侠那下载的KEIL2440+uCOSII+uCGUI,但是不支持FL2440,阿
uCOS-II uCGUI 2440 下载地址 javascript -
spring boot批量调度卡住
业务需求是将一张2000多万的数据表进行分表插入。引入依赖<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <
spring boot批量调度卡住 spring boot 后端 java spring -
springmvc请求超时时间设置
一、概述 SpringMVC是一个基于Java的实现了MVC设计模式的请求驱动类型的轻量级Web框架,通过一套注解,我们可以快速的搭建一个Web应用。本文将讲解SpringMVC处理请求的过程。二、基本概念1. MVC模式
springmvc请求超时时间设置 spring java 后端 MVC