Automatic resize of map + map size for exhibit at Route du Nord
This commit is contained in:
parent
6d7c870be3
commit
bf5b68ce07
1 changed files with 17 additions and 13 deletions
|
@ -45,12 +45,16 @@ class Heatmap:
|
|||
self.canvas.pack(fill="both", expand=True)
|
||||
|
||||
self.mapSize = [1600,600]
|
||||
self.mapScreenWidth = 300
|
||||
self.mapScreenHeight = 250
|
||||
self.mapWindowRoot = Tk.Toplevel(master=self.windowRoot)
|
||||
# self.mapWindowRoot.configure(background="black")
|
||||
self.mapWindowRoot.geometry('%dx%d+0+800' % tuple(self.mapSize))
|
||||
self.mapWindowRoot.title("Tracking Overview")
|
||||
self.mapCanvas = Tk.Canvas(self.mapWindowRoot,width=self.mapSize[0],height=self.mapSize[1],bd=0, highlightthickness=0, relief='ridge')
|
||||
self.mapCanvas.create_rectangle(20, 50, 22, 350, fill="black", width=0, tags="screenTop")
|
||||
self.mapCanvas.create_rectangle(600, 50, 602, 300, fill="black", width=0, tags="screenSide")
|
||||
self.mapCanvas.create_rectangle(20, self.mapSize[1]/2 - self.mapScreenWidth /2, 22, self.mapSize[1]/2 + self.mapScreenWidth /2, fill="white", width=0, tags="screenTop")
|
||||
self.mapCanvas.create_rectangle(600, self.mapSize[1]/2 - self.mapScreenHeight /2, 602, self.mapSize[1]/2 + self.mapScreenHeight /2, fill="white", width=0, tags="screenSide")
|
||||
self.mapCanvas.configure(background='black')
|
||||
# self.mapImage = Image.new('RGB', (500,350))
|
||||
# self.mapDraw = ImageDraw.Draw(self.mapImage)
|
||||
self.mapCanvas.pack(fill="both", expand=True)
|
||||
|
@ -186,9 +190,8 @@ class Heatmap:
|
|||
|
||||
def updateMap(self):
|
||||
self.mapCanvas.delete("figure")
|
||||
virtualWidth = 300
|
||||
virtualHeight = 250
|
||||
mmPerPixel = abs(self.coordinates['tl'][0] - self.coordinates['tr'][0])/float(virtualWidth)
|
||||
|
||||
mmPerPixel = abs(self.coordinates['tl'][0] - self.coordinates['tr'][0])/float(self.mapScreenWidth)
|
||||
|
||||
for face in self.currentTargets:
|
||||
dx = face['head_pos'][0]/mmPerPixel #left/right
|
||||
|
@ -196,20 +199,20 @@ class Heatmap:
|
|||
dz = face['head_pos'][2]/mmPerPixel # front/back
|
||||
|
||||
p1x = int(20 + dz)
|
||||
p1y = int(virtualWidth / 2 + 50 - dx)
|
||||
p1y = int(self.mapSize[1]/2 - dx)
|
||||
|
||||
p2x = int(600 + dz)
|
||||
p2y = int(virtualHeight / 2 + 50 + dy)
|
||||
p2y = int(self.mapSize[1]/2 + dy)
|
||||
self.mapCanvas.create_oval(p1x-3, p1y-3, p1x+3, p1y+3, fill="red", width=0, tags="figure")
|
||||
self.mapCanvas.create_oval(p2x-3, p2y-3, p2x+3, p2y+3, fill="red", width=0, tags="figure")
|
||||
|
||||
p3x = int(20)
|
||||
p3y = int(virtualWidth + 50 - (float(face['target'][0]) / self.metricsSize[0] * virtualWidth))
|
||||
p3y = int(self.mapSize[1]/2 + self.mapScreenWidth/2 - (float(face['target'][0]) / self.metricsSize[0] * self.mapScreenWidth))
|
||||
|
||||
p4x = int(600)
|
||||
p4y = int(float(face['target'][1]) / self.metricsSize[1] * virtualHeight + 50)
|
||||
self.mapCanvas.create_line(p1x,p1y, p3x,p3y, fill="green", tags="figure")
|
||||
self.mapCanvas.create_line(p2x,p2y, p4x,p4y, fill="green", tags="figure")
|
||||
p4y = int(float(face['target'][1]) / self.metricsSize[1] * self.mapScreenHeight + self.mapSize[1]/2 - self.mapScreenHeight/2)
|
||||
self.mapCanvas.create_line(p1x,p1y, p3x,p3y, width=2, fill="#ff0", tags="figure")
|
||||
self.mapCanvas.create_line(p2x,p2y, p4x,p4y, width=2, fill="#ff0", tags="figure")
|
||||
|
||||
self.logger.debug("DRAW FACE TO", face, (p1x,p1y), "AND", (p2x,p2y))
|
||||
|
||||
|
@ -318,8 +321,9 @@ def main(openface_exec, coordinates_filename, tag, device=0):
|
|||
|
||||
# metrics matrix
|
||||
metricsSize = [1920,1080]
|
||||
metricsSize = [1920/2,1080/2]
|
||||
metricsSize = [800,600]
|
||||
metricsSize = [1440,900]
|
||||
# metricsSize = [1920/2,1080/2]
|
||||
# metricsSize = [800,600]
|
||||
|
||||
heatmap = Heatmap(metricsSize, logger, coordinates_filename, tag)
|
||||
# heatmap.runCam(openface_exec, device)
|
||||
|
|
Loading…
Reference in a new issue