def _map_monocular(self,p):
if '3d' not in p['method']:
return None
p_id = p['id']
gaze_point = np.array(p['circle_3d']['normal'] ) * self.last_gaze_distance + np.array( p['sphere']['center'] )
image_point, _ = cv2.projectPoints( np.array([gaze_point]) , self.rotation_vectors[p_id], self.translation_vectors[p_id] , self.camera_matrix , self.dist_coefs )
image_point = image_point.reshape(-1,2)
image_point = normalize( image_point[0], self.world_frame_size , flip_y = True)
image_point = _clamp_norm_point(image_point)
if p_id == 0:
eye_center = self.eye0_to_World(p['sphere']['center'])
gaze_3d = self.eye0_to_World(gaze_point)
else:
eye_center = self.eye1_to_World(p['sphere']['center'])
gaze_3d = self.eye1_to_World(gaze_point)
normal_3d = np.dot( self.rotation_matricies[p_id], np.array( p['circle_3d']['normal'] ) )
g = {
'topic':'gaze',
'norm_pos':image_point,
'eye_centers_3d':{p['id']:eye_center.tolist()},
'gaze_normals_3d':{p['id']:normal_3d.tolist()},
'gaze_point_3d':gaze_3d.tolist(),
'confidence':p['confidence'],
'timestamp':p['timestamp'],
'base_data':[p]}
if self.visualizer.window:
if p_id == 0:
self.gaze_pts_debug0.append(gaze_3d)
self.sphere0['center'] = eye_center
self.sphere0['radius'] = p['sphere']['radius']
else:
self.gaze_pts_debug1.append(gaze_3d)
self.sphere1['center'] = eye_center
self.sphere1['radius'] = p['sphere']['radius']
return g
评论列表
文章目录