def process(self): """Process frames in queue/memory.""" # Start benchmark self.bench.start("Processing", len(self.files)) # Temporary Data Var data = [] # Initialize Compare Object if METHOD == algorithm.BACKGROUND_SUBTRACTION: # Load Current Frame and Background compare = CompareImages(self.queue[0], background) elif METHOD == algorithm.FRAME_DIFFERENCING: # Load Current Frame and Next Frame compare = CompareImages(self.queue[0], self.queue[1]) # Process Image Queue for frame in self.queue: if METHOD == algorithm.BACKGROUND_SUBTRACTION: # Load Current Frame compare.setLeft(frame) elif METHOD == algorithm.FRAME_DIFFERENCING: # Load Next Frame compare.setRight(frame) data.append(compare.process(TOLERANCE)) # End benchmark self.bench.end() # Write data to file listToFile(data, 'data.txt')
def process(self): """Process frames in queue/memory.""" # Start benchmark self.bench.start("Processing", len(self.files)) # Temporary Data Var data = [] # Initialize Compare Object if METHOD == algorithm.BACKGROUND_SUBTRACTION: # Load Current Frame and Background compare = CompareImages( self.queue[0], background ) elif METHOD == algorithm.FRAME_DIFFERENCING: # Load Current Frame and Next Frame compare = CompareImages( self.queue[0], self.queue[1] ) # Process Image Queue for frame in self.queue: if METHOD == algorithm.BACKGROUND_SUBTRACTION: # Load Current Frame compare.setLeft( frame ) elif METHOD == algorithm.FRAME_DIFFERENCING: # Load Next Frame compare.setRight( frame ) data.append( compare.process( TOLERANCE ) ) # End benchmark self.bench.end() # Write data to file listToFile(data, 'data.txt')
else: tmpImage = ImageFile(files[currentFile]).imgFile # If Current File is not the Processed File or a if currentFile != processedFile: # Get the Images Needed Based on the Algorithm try: if METHOD == algorithm.BACKGROUND_SUBTRACTION: # Load Current Frame compare.setLeft( ImageFile(files[currentFile], currentFile) ) elif METHOD == algorithm.FRAME_DIFFERENCING: # Load Next Frame compare.setRight( ImageFile(files[currentFile+1], currentFile+1) ) except IOError as e: # Display Screen Error if Images are Missing font = pygame.font.SysFont("Consolas", 18) tmpImage = font.render("Could not load one or more images.", 1, RED) except ValueError as e: # Display Screen Error if Images are not Equal Dimensions font = pygame.font.SysFont("Consolas", 18) tmpImage = font.render("Images are not the same dimensions.", 1, RED) else: # Do Compare Operation compare.process(TOLERANCE) # If showSource is enabled then process the frames, and get the diffed result for display
# Else then process the frames, but get the first frame for display else: tmpImage = ImageFile(files[currentFile]).imgFile # If Current File is not the Processed File or a if currentFile != processedFile: # Get the Images Needed Based on the Algorithm try: if METHOD == algorithm.BACKGROUND_SUBTRACTION: # Load Current Frame compare.setLeft(ImageFile(files[currentFile], currentFile)) elif METHOD == algorithm.FRAME_DIFFERENCING: # Load Next Frame compare.setRight( ImageFile(files[currentFile + 1], currentFile + 1)) except IOError as e: # Display Screen Error if Images are Missing font = pygame.font.SysFont("Consolas", 18) tmpImage = font.render("Could not load one or more images.", 1, RED) except ValueError as e: # Display Screen Error if Images are not Equal Dimensions font = pygame.font.SysFont("Consolas", 18) tmpImage = font.render("Images are not the same dimensions.", 1, RED) else: # Do Compare Operation compare.process(TOLERANCE)