示例#1
0
def run(algorithm, videofile):
    from fingertracker import FingerTracker
    from gesture import gesture
    from tracking import util

    FClass = FingerTracker.get_tracker(algorithm)
    f = FClass(videofile)
    def producer(ti):
        f.run(ti)
    util.run_async_consumer(producer, gesture.gesture_consumer)
        for x, y in positions:
            di.dl().circle((int(x), int(y)), 15, color=Color.RED, width=3)
        self.add_positions(ti, positions)

        fps = 1.0 / (time.time() - self.last_time)
        di.dl().ezViewText("{0:.3f} fps".format(fps), (0, 0))
        di.save(self.display)

        self.last_time = time.time()
        self.last_img = True

        if self.display.mouseLeft or self.display.mouseRight:
            self.display.done = True
            return False
        else:
            return True

    def finish(self):
        if self.display is not None:
            self.display.done = True
            self.display.quit()


if __name__ == "__main__":
    color_tracker = FingerTrackerPeaks()

    def run(ti):
        color_tracker.run(ti)

    util.run_async_consumer(run, util.print_consumer)
示例#3
0
def run():
    f = FingerTracker()
    def producer(ti):
        f.run(ti)
    util.run_async_consumer(producer, gesture.gesture_consumer)