From 215a059a325463e68e957fde6d55c04301c99a59 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Wed, 6 Feb 2019 09:22:36 +0100 Subject: [PATCH] Some changes --- head_pose.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/head_pose.py b/head_pose.py index a5f827d..743cbd5 100644 --- a/head_pose.py +++ b/head_pose.py @@ -237,7 +237,7 @@ if os.path.exists("coordinates.p"): logger.info("Loaded coordinates: %s", coordinatesToSrc(coordinates)) logger.debug("Corners: %s", screenDrawCorners) logger.debug("Test point %s", a) - logger.debug("Transformed point %s", transform(a[0:2])) + logger.info("Transformed point %s", transform(a[0:2])) # exit() else: coordinates = {'tl': None, 'tr': None, 'bl': None, 'br': None} @@ -475,6 +475,7 @@ processes.append(p) while True: te1 = time.time() result = pointsQueue.get() + te1b = time.time() im = result['im'] currentPoint = result['currentPoint'] currentPoints = result['currentPoints'] @@ -530,7 +531,7 @@ while True: if mx >= 0 and my >= 0 and mx < metricsSize[0] and my < metricsSize[1]: newMetrics[my,mx] += spot[sx,sy] #/ 20 - print("MAX",np.max(newMetrics)) + # print("MAX",np.max(newMetrics)) # TODO: put in an image of a blurred spot & remove blur action @@ -549,6 +550,7 @@ while True: te3 = time.time() logger.debug("showed webcam image in %fs", te3-te2) logger.debug("Rendering took %fs", te3-te1) + logger.debug("Waited took %fs", te1b-te1) # blur smooth the heatmap # logger.debug("Max blurred metrics: %f", np.max(metrics)) @@ -556,7 +558,7 @@ while True: # update the heatmap output tm21 = time.time() # smooth impact of first hits by having at least 0.05 - normalisedMetrics = metrics / (max(255*4 ,np.max(metrics))) + normalisedMetrics = metrics / (max(255*7 ,np.max(metrics))) # convert to colormap, thanks to: https://stackoverflow.com/a/10967471 normalisedMetricsColored = np.uint8(cm.nipy_spectral(normalisedMetrics)*255) normalisedMetricsColoredBGR = cv2.cvtColor(normalisedMetricsColored, cv2.COLOR_RGB2BGR) @@ -630,22 +632,25 @@ while True: if keyPress == ord('1'): coordinates['tl'] = currentPoint recalculate = True + logger.warn('Calibrate 1') elif keyPress == ord('2'): coordinates['tr'] = currentPoint recalculate = True + logger.warn('Calibrate 2') elif keyPress == ord('3'): coordinates['bl'] = currentPoint recalculate = True + logger.warn('Calibrate 3') elif keyPress == ord('4'): coordinates['br'] = currentPoint recalculate = True + logger.warn('Calibrate 4') elif keyPress == ord('t') and transform is not None: logger.info("Coordinates {}".format(coordinates) ) logger.info("Drawing area {}".format(screenDrawCorners)) logger.info("Test point {}".format(currentPoint )) logger.info("Transformed point {}".format(transform(currentPoint))) - if recalculate is True and not any (x is None for x in coordinates.values()): logger.debug(coordinates.values()) pickle.dump( coordinates, open( "coordinates.p", "wb" ) )