I'm sorry for asking such an odd question. I thought I had it more or less worked out utilizing pygame, but I've run into some errors.
I want to go through an image and discern whether each pixel matches a pre-defined color. Once the color is found, the loop will break and return the coordinates.
This is what I have currently.
Code: Select all
import renpygame as pygame
from renpygame.locals import *
class MotionTracker():
def __init__(self,im, faceInit, frame_width, frame_height, frames,pixColor = None):
self.image = pygame.image.load(im).convert()
self.frame_width = frame_width
self.frame_height = frame_height
self.frames = frames
self.pixColor = pixColor
if pixColor is None:
self.pixColor = (0,255,0,255) #set default tracker color to lime green
self.posArray = [faceInit]
def getBeacon(self,x,y): #allow user to customize color being tracked, in case of need, but assumes lime green.
x = x
y = y
while y < self.frame_height:
while x < self.frame_width:
dsf = self.image.get_at((x,y))
if dsf == self.pixColor:
break
else:
x+=1
if dsf == self.pixColor:
break
else:
y+=1
return (x,y)
If anyone has any idea how to correct this, or suggestions for other methods (PIL would be the most obvious, but it doesn't look like Ren'py supports it, unless I missed something), that would be great! I know what I want to do otherwise, it's just getting the image to read is a huge hurldle.