diff --git a/head_pose.py b/head_pose.py index a7eeff6..3d687cb 100644 --- a/head_pose.py +++ b/head_pose.py @@ -59,6 +59,12 @@ argParser.add_argument( default=15, help="Interval at which to save heatmap frames (in seconds)" ) +argParser.add_argument( + '--queue-length', + type=int, + default=0, + help="Nr of frames to keep in queue (adds a delay)" +) args = argParser.parse_args() @@ -231,6 +237,8 @@ if args.output_dir: startTime = time.time() lastSaveTime = startTime +if args.queue_length: + imageQueue = [] while True: t1 = time.time() @@ -451,6 +459,13 @@ while True: wpercent = (imageWindowSize[0] / float(image.size[0])) hsize = int((float(image.size[1]) * float(wpercent))) image = image.resize((imageWindowSize[0], hsize)) + + if args.queue_length: + imageQueue.append(image) + if len(imageQueue) > args.queue_length: + logger.warn("Use image from queue :-)") + image = imageQueue.pop(0) + tkpi = ImageTk.PhotoImage(image) imageCanvas.delete("IMG") imagesprite = imageCanvas.create_image(500,500,image=tkpi, tags="IMG") @@ -485,7 +500,7 @@ while True: pass # (optionally) very slowly fade out previous metrics: - # metrics = metrics * .999 + metrics = metrics * .9997 keyPress = cv2.waitKey(5)