Enable fade & rudimentary delay in image display

This commit is contained in:
Ruben van de Ven 2019-02-05 09:58:43 +01:00
parent a1d23a3532
commit d5823a0a8d

View file

@ -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)