Been a while since I posted anything here, so I decided to post what I've currently been working on.
I use ImageChops to get a difference between two consecutive frames from my webcam. I would like to replace the pixel values > rgb 50, 50, 50 with 255, 0, 0.
I thought about using im.getdata() but it is too slow for "live feed".
I'm thinking the answer is in Image.point()
A more detailed discription on what I'm doing is found here.
My code so far. Its almost what I need.
from VideoCapture import Device import pygame, Image, sys, ImageChops, time from pygame.locals import * cam = Device() res = cam.getImage() res = res.size pygame.init() screen = pygame.display.set_mode(res) pygame.display.set_caption("Predator Vision: by Tech B") while 1: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() #grab two images im1 = cam.getImage() #you will need to wait a sec before taking another image #if not, the screen will remain black and buggy time.sleep(.2) im2 = cam.getImage() #im2-im1 per pixel diff = ImageChops.difference(im1,im2) #convert image to pygame type and then display shot = pygame.image.frombuffer(diff.tostring(), res, "RGB") screen.blit(shot,(0,0)) pygame.display.flip()