Exemple #1
0
 def get_clustered(self, stimulus, heatMap = None):
     if heatMap == None:
         heatMap = self.get_heat_map(stimulus, scale=.5)
     
     nHeatLines = 3
     heatLines = np.zeros(heatMap.shape,'uint8')
     for i in range(nHeatLines):
         tmp_treshold = GAZE_DISP_HEAT_MAP_THRESHOLD + (255-GAZE_DISP_HEAT_MAP_THRESHOLD)/nHeatLines * i
         if i % 2 == 1:
             heatLines += cv2.threshold(heatMap,tmp_treshold,200,cv2.THRESH_BINARY)[1]
         else:
             heatLines -= cv2.threshold(heatMap,tmp_treshold,200,cv2.THRESH_BINARY)[1]
     
     heatLines = cv2.resize(heatLines, (stimulus.width, stimulus.height))
     
     contours, hierarchy = cv2.findContours(heatLines, cv.CV_RETR_TREE, cv.CV_CHAIN_APPROX_NONE)
     hierarchy_levels = self.get_hierarchy_levels(hierarchy)
     
     ovImg = np.zeros((stimulus.height, stimulus.width,3),'uint8')
     heat_colors = utils.autumn(nHeatLines)
     for i in range(len(contours)):
         c2 = cv2.approxPolyDP(contours[i], 2, 0)
         cv2.polylines(ovImg, [c2], 3, heat_colors[hierarchy_levels[i]], 1)
     
     #cv2.drawContours(ovImg, contours, 0, (155,130,0), 2)
     return ovImg
Exemple #2
0
 def get_each(self, stimulus, history_length = 0, approx = False):
     ovImg = np.zeros((stimulus.height, stimulus.width,3),'uint8')
     colors = utils.autumn(len(self.gazes))
     
     gaze_coords = self.getGazeMovieCoords(stimulus, history_length, approx)
     gaze_coords = sorted(gaze_coords,key=operator.itemgetter(3),reverse=True)
     for (i, x, y, prio) in gaze_coords:
         if prio == 1:
             cv2.circle(ovImg, (int(x*stimulus.width),int(y*stimulus.height)), 15, colors[int(i)])
         pts = cv2.ellipse2Poly((int(x*stimulus.width),int(y*stimulus.height)),(2,2),0,0,360,int(360/6))
         opacity = float(history_length-prio+2) / (history_length+1)
         cv2.fillConvexPoly(ovImg, pts, (int(colors[int(i)][0]*opacity), int(colors[int(i)][1]*opacity), int(colors[int(i)][2]*opacity)))
     return ovImg