from SimpleCV import Camera cam = Camera() while True: img = cam.getImage() img.show() print cam.getAllProperties()
from SimpleCV import Camera from numpy import fft import numpy import helpers import matplotlib.pyplot as plt import time import collections # RGB cam = Camera() SAMPLE_WIDTH = 100 SAMPLE_HEIGHT = SAMPLE_WIDTH PIXEL_COUNT = SAMPLE_HEIGHT * SAMPLE_WIDTH CAM_WIDTH = int(cam.getAllProperties().get('width')) CAM_HEIGHT= int(cam.getAllProperties().get('height')) cam_center_point = (CAM_HEIGHT / 2, CAM_HEIGHT / 2) sample_x0 = cam_center_point[0] - (SAMPLE_WIDTH / 2) sample_y0 = cam_center_point[1] - (SAMPLE_HEIGHT / 2) green_values = [] SAMPLE_RATE = 30 # same as the camera FPS plt.ion() # enable interactive graphing plt.show() bpm = None avg_bpm = None bpm_history = collections.deque(maxlen=5) while True: img = cam.getImage() sampled_img = img[sample_x0:sample_x0 + SAMPLE_WIDTH, sample_y0: sample_y0 + SAMPLE_HEIGHT] avg_green = helpers.sample_avg_green(sampled_img)