#!/usr/bin/env python # -*- coding: utf-8 -*- import cv2 import numpy as np eta=1.0 cv2.namedWindow("preview") vc = cv2.VideoCapture(0) vc.set(3,1024) vc.set(4, 768) vc.set(cv2.cv.CV_CAP_PROP_FPS, 1) print vc.get(cv2.cv.CV_CAP_PROP_FPS),'fps' if vc.isOpened(): # try to get the first frame rval, frame = vc.read() else: rval = False quit() wframe=frame while rval: wframe=wframe*(1.-eta)+frame*eta iframe=np.uint8(wframe) cv2.imshow("preview", iframe) rval, frame = vc.read() key = cv2.waitKey(20) if key%256 == 27: # exit on "ESC" break cv2.destroyWindow("preview")