def __init__(self,g_pool):
super().__init__(g_pool)
self.menu=None
logger.error("This will be implemented as part of gaze mapper soon.")
self.alive= False
return
width,height = self.g_pool.capture.frame_size
if g_pool.app == 'capture':
cal_pt_path = os.path.join(g_pool.user_dir,"user_calibration_data")
else:
cal_pt_path = os.path.join(g_pool.rec_dir,"user_calibration_data")
try:
user_calibration_data = load_object(cal_pt_path)
except:
logger.warning("Please calibrate first")
self.close()
return
if self.g_pool.binocular:
fn_input_eye1 = cal_pt_cloud[:,2:4].transpose()
cal_pt_cloud[:,0:2] = np.array(map_fn(fn_input_eye0, fn_input_eye1)).transpose()
cal_pt_cloud[:,2:4] = cal_pt_cloud[:,4:6]
else:
fn_input = cal_pt_cloud[:,0:2].transpose()
cal_pt_cloud[:,0:2] = np.array(map_fn(fn_input)).transpose()
ref_pts = cal_pt_cloud[inlier_map][:,np.newaxis,2:4]
ref_pts = np.array(ref_pts,dtype=np.float32)
logger.debug("calibration ref_pts %s"%ref_pts)
if len(ref_pts)== 0:
logger.warning("Calibration is bad. Please re-calibrate")
self.close()
return
self.calib_bounds = cv2.convexHull(ref_pts)
# create a list [[px1,py1],[wx1,wy1],[px2,py2],[wx2,wy2]...] of outliers and inliers for gl_lines
self.outliers = np.concatenate((cal_pt_cloud[~inlier_map][:,0:2],cal_pt_cloud[~inlier_map][:,2:4])).reshape(-1,2)
self.inliers = np.concatenate((cal_pt_cloud[inlier_map][:,0:2],cal_pt_cloud[inlier_map][:,2:4]),axis=1).reshape(-1,2)
self.inlier_ratio = cal_pt_cloud[inlier_map].shape[0]/float(cal_pt_cloud.shape[0])
self.inlier_count = cal_pt_cloud[inlier_map].shape[0]
# hull = cv2.approxPolyDP(self.calib_bounds, 0.001,closed=True)
full_screen_area = 1.
logger.debug("calibration bounds %s"%self.calib_bounds)
self.calib_area_ratio = cv2.contourArea(self.calib_bounds)/full_screen_area
评论列表
文章目录