Ejemplo n.º 1
0
    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')
Ejemplo n.º 2
0
	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')
Ejemplo n.º 3
0
			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
			if showSource:
				tmpImage = compare.surfDiff
			# Else then process the frames, but get the first frame for display
			else:
				tmpImage = ImageFile(files[currentFile]).imgFile

			# Fit Window Size to Image
			x, y = screen.get_size()
			if x != tmpImage.get_width() or y != tmpImage.get_height():
				screen = pygame.display.set_mode((tmpImage.get_width(),tmpImage.get_height()))

			# Display Title
			pygame.display.set_caption("PyTrack Viewer. Frame: " + str(currentFile) + "-" + str(currentFile+1))
Ejemplo n.º 4
0
                    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
            if showSource:
                tmpImage = compare.surfDiff
            # Else then process the frames, but get the first frame for display
            else:
                tmpImage = ImageFile(files[currentFile]).imgFile

            # Fit Window Size to Image
            x, y = screen.get_size()
            if x != tmpImage.get_width() or y != tmpImage.get_height():
                screen = pygame.display.set_mode(
                    (tmpImage.get_width(), tmpImage.get_height()))

            # Display Title