Some changes

This commit is contained in:
Ruben van de Ven 2019-02-06 09:22:36 +01:00
parent 6007282ab3
commit 215a059a32

View file

@ -237,7 +237,7 @@ if os.path.exists("coordinates.p"):
logger.info("Loaded coordinates: %s", coordinatesToSrc(coordinates)) logger.info("Loaded coordinates: %s", coordinatesToSrc(coordinates))
logger.debug("Corners: %s", screenDrawCorners) logger.debug("Corners: %s", screenDrawCorners)
logger.debug("Test point %s", a) 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() # exit()
else: else:
coordinates = {'tl': None, 'tr': None, 'bl': None, 'br': None} coordinates = {'tl': None, 'tr': None, 'bl': None, 'br': None}
@ -475,6 +475,7 @@ processes.append(p)
while True: while True:
te1 = time.time() te1 = time.time()
result = pointsQueue.get() result = pointsQueue.get()
te1b = time.time()
im = result['im'] im = result['im']
currentPoint = result['currentPoint'] currentPoint = result['currentPoint']
currentPoints = result['currentPoints'] currentPoints = result['currentPoints']
@ -530,7 +531,7 @@ while True:
if mx >= 0 and my >= 0 and mx < metricsSize[0] and my < metricsSize[1]: if mx >= 0 and my >= 0 and mx < metricsSize[0] and my < metricsSize[1]:
newMetrics[my,mx] += spot[sx,sy] #/ 20 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 # TODO: put in an image of a blurred spot & remove blur action
@ -549,6 +550,7 @@ while True:
te3 = time.time() te3 = time.time()
logger.debug("showed webcam image in %fs", te3-te2) logger.debug("showed webcam image in %fs", te3-te2)
logger.debug("Rendering took %fs", te3-te1) logger.debug("Rendering took %fs", te3-te1)
logger.debug("Waited took %fs", te1b-te1)
# blur smooth the heatmap # blur smooth the heatmap
# logger.debug("Max blurred metrics: %f", np.max(metrics)) # logger.debug("Max blurred metrics: %f", np.max(metrics))
@ -556,7 +558,7 @@ while True:
# update the heatmap output # update the heatmap output
tm21 = time.time() tm21 = time.time()
# smooth impact of first hits by having at least 0.05 # 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 # convert to colormap, thanks to: https://stackoverflow.com/a/10967471
normalisedMetricsColored = np.uint8(cm.nipy_spectral(normalisedMetrics)*255) normalisedMetricsColored = np.uint8(cm.nipy_spectral(normalisedMetrics)*255)
normalisedMetricsColoredBGR = cv2.cvtColor(normalisedMetricsColored, cv2.COLOR_RGB2BGR) normalisedMetricsColoredBGR = cv2.cvtColor(normalisedMetricsColored, cv2.COLOR_RGB2BGR)
@ -630,22 +632,25 @@ while True:
if keyPress == ord('1'): if keyPress == ord('1'):
coordinates['tl'] = currentPoint coordinates['tl'] = currentPoint
recalculate = True recalculate = True
logger.warn('Calibrate 1')
elif keyPress == ord('2'): elif keyPress == ord('2'):
coordinates['tr'] = currentPoint coordinates['tr'] = currentPoint
recalculate = True recalculate = True
logger.warn('Calibrate 2')
elif keyPress == ord('3'): elif keyPress == ord('3'):
coordinates['bl'] = currentPoint coordinates['bl'] = currentPoint
recalculate = True recalculate = True
logger.warn('Calibrate 3')
elif keyPress == ord('4'): elif keyPress == ord('4'):
coordinates['br'] = currentPoint coordinates['br'] = currentPoint
recalculate = True recalculate = True
logger.warn('Calibrate 4')
elif keyPress == ord('t') and transform is not None: elif keyPress == ord('t') and transform is not None:
logger.info("Coordinates {}".format(coordinates) ) logger.info("Coordinates {}".format(coordinates) )
logger.info("Drawing area {}".format(screenDrawCorners)) logger.info("Drawing area {}".format(screenDrawCorners))
logger.info("Test point {}".format(currentPoint )) logger.info("Test point {}".format(currentPoint ))
logger.info("Transformed point {}".format(transform(currentPoint))) logger.info("Transformed point {}".format(transform(currentPoint)))
if recalculate is True and not any (x is None for x in coordinates.values()): if recalculate is True and not any (x is None for x in coordinates.values()):
logger.debug(coordinates.values()) logger.debug(coordinates.values())
pickle.dump( coordinates, open( "coordinates.p", "wb" ) ) pickle.dump( coordinates, open( "coordinates.p", "wb" ) )