from VideoCapture import Device import ImageDraw import Image import sys import pygame # init pygame pygame.init() # get cam device cam = Device() # setup screen size size = width, height = 320,240 screen = pygame.display.set_mode(size) while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() shot = cam.getImage() #split the image into individual bands source = shot.split() R, G, B = 0, 1, 2 reddata = source[R].getdata() greendata = source[G].getdata() bluedata = source[B].getdata() pixel_count = len(reddata) redcount = 0 for i in range(pixel_count): red = reddata[i] green = greendata[i] blue = bluedata[i] # process bands factor = 1.5 if (green*factor) <= red >= (blue*factor): redcount = redcount + 1 print redcount shot = pygame.image.fromstring(shot.tostring(), (320,240), "RGB") screen.blit(shot, (0,0)) pygame.display.flip()