Some changes

This commit is contained in:
Ruben van de Ven 2019-02-06 09:22:36 +01:00
parent 6007282ab3
commit 215a059a32
1 changed files with 9 additions and 4 deletions

View File

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