Enable fade & rudimentary delay in image display
This commit is contained in:
parent
a1d23a3532
commit
d5823a0a8d
1 changed files with 16 additions and 1 deletions
17
head_pose.py
17
head_pose.py
|
@ -59,6 +59,12 @@ argParser.add_argument(
|
||||||
default=15,
|
default=15,
|
||||||
help="Interval at which to save heatmap frames (in seconds)"
|
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()
|
args = argParser.parse_args()
|
||||||
|
|
||||||
|
@ -231,6 +237,8 @@ if args.output_dir:
|
||||||
startTime = time.time()
|
startTime = time.time()
|
||||||
lastSaveTime = startTime
|
lastSaveTime = startTime
|
||||||
|
|
||||||
|
if args.queue_length:
|
||||||
|
imageQueue = []
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
t1 = time.time()
|
t1 = time.time()
|
||||||
|
@ -451,6 +459,13 @@ while True:
|
||||||
wpercent = (imageWindowSize[0] / float(image.size[0]))
|
wpercent = (imageWindowSize[0] / float(image.size[0]))
|
||||||
hsize = int((float(image.size[1]) * float(wpercent)))
|
hsize = int((float(image.size[1]) * float(wpercent)))
|
||||||
image = image.resize((imageWindowSize[0], hsize))
|
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)
|
tkpi = ImageTk.PhotoImage(image)
|
||||||
imageCanvas.delete("IMG")
|
imageCanvas.delete("IMG")
|
||||||
imagesprite = imageCanvas.create_image(500,500,image=tkpi, tags="IMG")
|
imagesprite = imageCanvas.create_image(500,500,image=tkpi, tags="IMG")
|
||||||
|
@ -485,7 +500,7 @@ while True:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# (optionally) very slowly fade out previous metrics:
|
# (optionally) very slowly fade out previous metrics:
|
||||||
# metrics = metrics * .999
|
metrics = metrics * .9997
|
||||||
|
|
||||||
keyPress = cv2.waitKey(5)
|
keyPress = cv2.waitKey(5)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue