def stop(self):
        # TODO: redundancy between all gaze mappers -> might be moved to parent class
        audio.say("Stopping Calibration")
        logger.info("Stopping Calibration")
        self.screen_marker_state = 0
        self.active = False
        self.close_window()
        self.button.status_text = ""

        if self.g_pool.binocular:
            cal_pt_cloud = calibrate.preprocess_data(list(self.pupil_list), list(self.ref_list), id_filter=(0, 1))
            cal_pt_cloud_eye0 = calibrate.preprocess_data(list(self.pupil_list), list(self.ref_list), id_filter=(0,))
            cal_pt_cloud_eye1 = calibrate.preprocess_data(list(self.pupil_list), list(self.ref_list), id_filter=(1,))
            logger.info("Collected %s binocular data points." % len(cal_pt_cloud))
            logger.info("Collected %s data points for eye 0." % len(cal_pt_cloud_eye0))
            logger.info("Collected %s data points for eye 1." % len(cal_pt_cloud_eye1))
        else:
            cal_pt_cloud = calibrate.preprocess_data(self.pupil_list, self.ref_list)
            logger.info("Collected %s data points." % len(cal_pt_cloud))

        if (
            self.g_pool.binocular
            and (len(cal_pt_cloud_eye0) < 20 or len(cal_pt_cloud_eye1) < 20)
            or len(cal_pt_cloud) < 20
        ):
            logger.warning("Did not collect enough data.")
            return

        cal_pt_cloud = np.array(cal_pt_cloud)
        map_fn, params = calibrate.get_map_from_cloud(
            cal_pt_cloud, self.g_pool.capture.frame_size, return_params=True, binocular=self.g_pool.binocular
        )
        np.save(os.path.join(self.g_pool.user_dir, "cal_pt_cloud.npy"), cal_pt_cloud)
        # replace current gaze mapper with new
        if self.g_pool.binocular:
            # get monocular models for fallback (if only one pupil is detected)
            cal_pt_cloud_eye0 = np.array(cal_pt_cloud_eye0)
            cal_pt_cloud_eye1 = np.array(cal_pt_cloud_eye1)
            _, params_eye0 = calibrate.get_map_from_cloud(
                cal_pt_cloud_eye0, self.g_pool.capture.frame_size, return_params=True
            )
            _, params_eye1 = calibrate.get_map_from_cloud(
                cal_pt_cloud_eye1, self.g_pool.capture.frame_size, return_params=True
            )
            self.g_pool.plugins.add(
                Bilateral_Gaze_Mapper, args={"params": params, "params_eye0": params_eye0, "params_eye1": params_eye1}
            )
            np.save(os.path.join(self.g_pool.user_dir, "cal_pt_cloud_eye0.npy"), cal_pt_cloud_eye0)
            np.save(os.path.join(self.g_pool.user_dir, "cal_pt_cloud_eye1.npy"), cal_pt_cloud_eye1)

        else:
            self.g_pool.plugins.add(Simple_Gaze_Mapper, args={"params": params})
    def stop(self):
        audio.say("Stopping Calibration")
        logger.info('Stopping Calibration')
        self.screen_marker_state = 0
        self.active = False
        self.close_window()
        self.button.status_text = ''

        cal_pt_cloud = calibrate.preprocess_data(self.pupil_list,
                                                 self.ref_list)

        logger.info("Collected %s data points." % len(cal_pt_cloud))

        if len(cal_pt_cloud) < 20:
            logger.warning("Did not collect enough data.")
            return

        cal_pt_cloud = np.array(cal_pt_cloud)
        map_fn, params = calibrate.get_map_from_cloud(cal_pt_cloud,
                                                      self.world_size,
                                                      return_params=True)
        np.save(os.path.join(self.g_pool.user_dir, 'cal_pt_cloud.npy'),
                cal_pt_cloud)

        #replace current gaze mapper with new
        self.g_pool.plugins.add(Simple_Gaze_Mapper(self.g_pool, params))
Example #3
0
    def stop(self):
        # TODO: redundancy between all gaze mappers -> might be moved to parent class
        audio.say("Stopping Calibration")
        logger.info("Stopping Calibration")
        self.active = False
        self.button.status_text = ''

        #img_size = self.first_img.shape[1],self.first_img.shape[0]

        if self.g_pool.binocular:
            cal_pt_cloud = calibrate.preprocess_data(list(self.pupil_list),list(self.ref_list),id_filter=(0,1))
            cal_pt_cloud_eye0 = calibrate.preprocess_data(list(self.pupil_list),list(self.ref_list),id_filter=(0,))
            cal_pt_cloud_eye1 = calibrate.preprocess_data(list(self.pupil_list),list(self.ref_list),id_filter=(1,))
        else:
            cal_pt_cloud = calibrate.preprocess_data(self.pupil_list,self.ref_list)

        if self.g_pool.binocular:
            logger.info("Collected %s binocular data points." %len(cal_pt_cloud))
            logger.info("Collected %s data points for eye 0." %len(cal_pt_cloud_eye0))
            logger.info("Collected %s data points for eye 1." %len(cal_pt_cloud_eye1))
        else:
            logger.info("Collected %s data points." %len(cal_pt_cloud))

        if self.g_pool.binocular and (len(cal_pt_cloud) < 20 or len(cal_pt_cloud_eye0) < 20 or len(cal_pt_cloud_eye1) < 20) or len(cal_pt_cloud) < 20:
            logger.warning("Did not collect enough data.")
            return

        cal_pt_cloud = np.array(cal_pt_cloud)
        map_fn,params = calibrate.get_map_from_cloud(cal_pt_cloud,self.g_pool.capture.frame_size,return_params=True, binocular=self.g_pool.binocular)
        np.save(os.path.join(self.g_pool.user_dir,'cal_pt_cloud.npy'),cal_pt_cloud)
        #replace current gaze mapper with new
        if self.g_pool.binocular:
            # get monocular models for fallback (if only one pupil is detected)
            cal_pt_cloud_eye0 = np.array(cal_pt_cloud_eye0)
            cal_pt_cloud_eye1 = np.array(cal_pt_cloud_eye1)
            _,params_eye0 = calibrate.get_map_from_cloud(cal_pt_cloud_eye0,self.g_pool.capture.frame_size,return_params=True)
            _,params_eye1 = calibrate.get_map_from_cloud(cal_pt_cloud_eye1,self.g_pool.capture.frame_size,return_params=True)
            self.g_pool.plugins.add(Bilateral_Gaze_Mapper,args={'params':params, 'params_eye0':params_eye0, 'params_eye1':params_eye1})
        else:
            self.g_pool.plugins.add(Simple_Gaze_Mapper,args={'params':params})
    def stop(self):
        audio.say("Stopping Calibration")
        logger.info("Stopping Calibration")
        self.active = False
        cal_pt_cloud = calibrate.preprocess_data(self.pupil_list,self.ref_list)
        logger.info("Collected %s data points." %len(cal_pt_cloud))
        if len(cal_pt_cloud) < 20:
            logger.warning("Did not collect enough data.")
            return
        cal_pt_cloud = np.array(cal_pt_cloud)

        img_size = self.first_img.shape[1],self.first_img.shape[0]
        self.g_pool.map_pupil = calibrate.get_map_from_cloud(cal_pt_cloud,img_size)
        np.save(os.path.join(self.g_pool.user_dir,'cal_pt_cloud.npy'),cal_pt_cloud)
Example #5
0
    def stop(self):
        logger.info("Stopping Touchup")
        self.smooth_pos = 0.,0.
        self.sample_site = -2,-2
        self.counter = 0
        self.active = False
        self.button.status_text = ''


        offset_pt_clound = np.array(calibrate.preprocess_data(self.gaze_list,self.ref_list))
        if len(offset_pt_clound)<3:
            logger.error('Did not sample enough data for touchup please retry.')
            return

        #Calulate the offset for gaze to target
        offset =  offset_pt_clound[:,:2]-offset_pt_clound[:,2:]
        mean_offset  = np.mean(offset,axis=0)

        cal_pt_cloud = np.load(os.path.join(self.g_pool.user_dir,'cal_pt_cloud.npy'))
        #deduct the offset from the old calibration ref point position. Thus shifiting the calibtation.
        # p["norm_pos"][0], p["norm_pos"][1],ref_pt['norm_pos'][0],ref_pt['norm_pos'][1]

        cal_pt_cloud[:,-2::] -= mean_offset

        if self.g_pool.binocular:
            cal_pt_cloud_eye0 = np.load(os.path.join(self.g_pool.user_dir,'cal_pt_cloud_eye0.npy'))
            cal_pt_cloud_eye1 = np.load(os.path.join(self.g_pool.user_dir,'cal_pt_cloud_eye1.npy'))
            #Do the same for the individual eye in binocular
            #p0["norm_pos"][0], p0["norm_pos"][1],p1["norm_pos"][0], p1["norm_pos"][1],ref_pt['norm_pos'][0],ref_pt['norm_pos'][1]
            cal_pt_cloud_eye0[:,-2::] -= mean_offset
            cal_pt_cloud_eye1[:,-2::] -= mean_offset



        #then recalibtate the with old but shifted data.
        map_fn,params = calibrate.get_map_from_cloud(cal_pt_cloud,self.g_pool.capture.frame_size,return_params=True, binocular=self.g_pool.binocular)
        np.save(os.path.join(self.g_pool.user_dir,'cal_pt_cloud.npy'),cal_pt_cloud)
        #replace current gaze mapper with new
        if self.g_pool.binocular:
            # get monocular models for fallback (if only one pupil is detected)
            cal_pt_cloud_eye0 = np.array(cal_pt_cloud_eye0)
            cal_pt_cloud_eye1 = np.array(cal_pt_cloud_eye1)
            _,params_eye0 = calibrate.get_map_from_cloud(cal_pt_cloud_eye0,self.g_pool.capture.frame_size,return_params=True)
            _,params_eye1 = calibrate.get_map_from_cloud(cal_pt_cloud_eye1,self.g_pool.capture.frame_size,return_params=True)
            self.g_pool.plugins.add(Bilateral_Gaze_Mapper,args={'params':params, 'params_eye0':params_eye0, 'params_eye1':params_eye1})
            np.save(os.path.join(self.g_pool.user_dir,'cal_pt_cloud_eye0.npy'),cal_pt_cloud_eye0)
            np.save(os.path.join(self.g_pool.user_dir,'cal_pt_cloud_eye1.npy'),cal_pt_cloud_eye1)

        else:
            self.g_pool.plugins.add(Simple_Gaze_Mapper,args={'params':params})
Example #6
0
    def stop(self):
        audio.say("Stopping Calibration")
        logger.info("Stopping Calibration")
        self.active = False
        cal_pt_cloud = calibrate.preprocess_data(self.pupil_list,
                                                 self.ref_list)
        logger.info("Collected %s data points." % len(cal_pt_cloud))
        if len(cal_pt_cloud) < 20:
            logger.warning("Did not collect enough data.")
            return
        cal_pt_cloud = np.array(cal_pt_cloud)

        img_size = self.first_img.shape[1], self.first_img.shape[0]
        self.g_pool.map_pupil = calibrate.get_map_from_cloud(
            cal_pt_cloud, img_size)
        np.save(os.path.join(self.g_pool.user_dir, 'cal_pt_cloud.npy'),
                cal_pt_cloud)
    def stop(self):
        audio.say("Stopping Calibration")
        logger.info("Stopping Calibration")
        self.smooth_pos = 0,0
        self.counter = 0
        self.active = False
        self.button.status_text = ''
        print 'button:', self.button.status_text

        cal_pt_cloud = calibrate.preprocess_data(self.pupil_list,self.ref_list)
        logger.info("Collected %s data points." %len(cal_pt_cloud))
        if len(cal_pt_cloud) < 20:
            logger.warning("Did not collect enough data.")
            return
        cal_pt_cloud = np.array(cal_pt_cloud)
        map_fn,params = calibrate.get_map_from_cloud(cal_pt_cloud,self.world_size,return_params=True)
        np.save(os.path.join(self.g_pool.user_dir,'cal_pt_cloud.npy'),cal_pt_cloud)

        self.g_pool.plugins.add(Simple_Gaze_Mapper(self.g_pool,params))
    def stop(self):
        audio.say("Stopping Calibration")
        logger.info('Stopping Calibration')
        self.screen_marker_state = 0
        self.active = False
        self.window_should_close = True

        cal_pt_cloud = calibrate.preprocess_data(self.pupil_list,self.ref_list)

        logger.info("Collected %s data points." %len(cal_pt_cloud))

        if len(cal_pt_cloud) < 20:
            logger.warning("Did not collect enough data.")
            return

        cal_pt_cloud = np.array(cal_pt_cloud)
        map_fn = calibrate.get_map_from_cloud(cal_pt_cloud,self.world_size)
        self.g_pool.map_pupil = map_fn
        np.save(os.path.join(self.g_pool.user_dir,'cal_pt_cloud.npy'),cal_pt_cloud)
Example #9
0
    def stop(self):
        audio.say("Stopping Calibration")
        logger.info("Stopping Calibration")
        self.active = False
        self.button.status_text = ''

        cal_pt_cloud = calibrate.preprocess_data(self.pupil_list,self.ref_list)
        logger.info("Collected %s data points." %len(cal_pt_cloud))
        if len(cal_pt_cloud) < 20:
            logger.warning("Did not collect enough data.")
            return
        cal_pt_cloud = np.array(cal_pt_cloud)

        img_size = self.first_img.shape[1],self.first_img.shape[0]
        map_fn,params = calibrate.get_map_from_cloud(cal_pt_cloud,img_size,return_params=True)
        np.save(os.path.join(self.g_pool.user_dir,'cal_pt_cloud.npy'),cal_pt_cloud)

        #replace gaze mapper
        self.g_pool.plugins.add(Simple_Gaze_Mapper(self.g_pool,params))
    def stop(self):
        audio.say("Stopping Calibration")
        logger.info('Stopping Calibration')
        self.screen_marker_state = 0
        self.active = False
        self.window_should_close = True

        cal_pt_cloud = calibrate.preprocess_data(self.pupil_list,self.ref_list)

        logger.info("Collected %s data points." %len(cal_pt_cloud))

        if len(cal_pt_cloud) < 20:
            logger.warning("Did not collect enough data.")
            return

        cal_pt_cloud = np.array(cal_pt_cloud)
        map_fn = calibrate.get_map_from_cloud(cal_pt_cloud,self.world_size)
        self.g_pool.map_pupil = map_fn
        np.save(os.path.join(self.g_pool.user_dir,'cal_pt_cloud.npy'),cal_pt_cloud)
Example #11
0
    def stop(self):
        audio.say("Stopping Accuracy Test")
        logger.info('Stopping Accuracy_Test')
        self.screen_marker_state = 0
        self.active = False
        self.close_window()

        pt_cloud = preprocess_data(self.gaze_list,self.ref_list)

        logger.info("Collected %s data points." %len(pt_cloud))

        if len(pt_cloud) < 20:
            logger.warning("Did not collect enough data.")
            return

        pt_cloud = np.array(pt_cloud)
        np.save(os.path.join(self.g_pool.user_dir,'accuracy_test_pt_cloud.npy'),pt_cloud)
        gaze,ref = pt_cloud[:,0:2],pt_cloud[:,2:4]
        error_lines = np.array([[g,r] for g,r in zip(gaze,ref)])
        self.error_lines = error_lines.reshape(-1,2)
        self.pt_cloud = pt_cloud
    def stop(self):
        audio.say("Stopping Calibration")
        logger.info('Stopping Calibration')
        self.screen_marker_state = 0
        self.active = False
        self.close_window()
        self.button.status_text = ''

        cal_pt_cloud = calibrate.preprocess_data(self.pupil_list,self.ref_list)

        logger.info("Collected %s data points." %len(cal_pt_cloud))

        if len(cal_pt_cloud) < 20:
            logger.warning("Did not collect enough data.")
            return

        cal_pt_cloud = np.array(cal_pt_cloud)
        map_fn,params = calibrate.get_map_from_cloud(cal_pt_cloud,self.g_pool.capture.frame_size,return_params=True)
        np.save(os.path.join(self.g_pool.user_dir,'cal_pt_cloud.npy'),cal_pt_cloud)

        #replace current gaze mapper with new
        self.g_pool.plugins.add(Simple_Gaze_Mapper,args={'params':params})
Example #13
0
    def stop(self):
        audio.say("Stopping Calibration")
        logger.info("Stopping Calibration")
        self.smooth_pos = 0, 0
        self.counter = 0
        self.active = False
        self.button.status_text = ''
        print 'button:', self.button.status_text

        cal_pt_cloud = calibrate.preprocess_data(self.pupil_list,
                                                 self.ref_list)
        logger.info("Collected %s data points." % len(cal_pt_cloud))
        if len(cal_pt_cloud) < 20:
            logger.warning("Did not collect enough data.")
            return
        cal_pt_cloud = np.array(cal_pt_cloud)
        map_fn, params = calibrate.get_map_from_cloud(cal_pt_cloud,
                                                      self.world_size,
                                                      return_params=True)
        np.save(os.path.join(self.g_pool.user_dir, 'cal_pt_cloud.npy'),
                cal_pt_cloud)

        self.g_pool.plugins.add(Simple_Gaze_Mapper(self.g_pool, params))
Example #14
0
    def stop(self):
        logger.info("Stopping Touchup")
        self.smooth_pos = 0., 0.
        self.sample_site = -2, -2
        self.counter = 0
        self.active = False
        self.button.status_text = ''

        offset_pt_clound = np.array(
            calibrate.preprocess_data(self.gaze_list, self.ref_list))
        if len(offset_pt_clound) < 3:
            logger.error(
                'Did not sample enough data for touchup please retry.')
            return

        #Calulate the offset for gaze to target
        offset = offset_pt_clound[:, :2] - offset_pt_clound[:, 2:]
        mean_offset = np.mean(offset, axis=0)

        cal_pt_cloud = np.load(
            os.path.join(self.g_pool.user_dir, 'cal_pt_cloud.npy'))
        #deduct the offset from the old calibration ref point position. Thus shifiting the calibtation.
        # p["norm_pos"][0], p["norm_pos"][1],ref_pt['norm_pos'][0],ref_pt['norm_pos'][1]

        cal_pt_cloud[:, -2::] -= mean_offset

        if self.g_pool.binocular:
            cal_pt_cloud_eye0 = np.load(
                os.path.join(self.g_pool.user_dir, 'cal_pt_cloud_eye0.npy'))
            cal_pt_cloud_eye1 = np.load(
                os.path.join(self.g_pool.user_dir, 'cal_pt_cloud_eye1.npy'))
            #Do the same for the individual eye in binocular
            #p0["norm_pos"][0], p0["norm_pos"][1],p1["norm_pos"][0], p1["norm_pos"][1],ref_pt['norm_pos'][0],ref_pt['norm_pos'][1]
            cal_pt_cloud_eye0[:, -2::] -= mean_offset
            cal_pt_cloud_eye1[:, -2::] -= mean_offset

        #then recalibtate the with old but shifted data.
        map_fn, params = calibrate.get_map_from_cloud(
            cal_pt_cloud,
            self.g_pool.capture.frame_size,
            return_params=True,
            binocular=self.g_pool.binocular)
        np.save(os.path.join(self.g_pool.user_dir, 'cal_pt_cloud.npy'),
                cal_pt_cloud)
        #replace current gaze mapper with new
        if self.g_pool.binocular:
            # get monocular models for fallback (if only one pupil is detected)
            cal_pt_cloud_eye0 = np.array(cal_pt_cloud_eye0)
            cal_pt_cloud_eye1 = np.array(cal_pt_cloud_eye1)
            _, params_eye0 = calibrate.get_map_from_cloud(
                cal_pt_cloud_eye0,
                self.g_pool.capture.frame_size,
                return_params=True)
            _, params_eye1 = calibrate.get_map_from_cloud(
                cal_pt_cloud_eye1,
                self.g_pool.capture.frame_size,
                return_params=True)
            self.g_pool.plugins.add(Bilateral_Gaze_Mapper,
                                    args={
                                        'params': params,
                                        'params_eye0': params_eye0,
                                        'params_eye1': params_eye1
                                    })
            np.save(
                os.path.join(self.g_pool.user_dir, 'cal_pt_cloud_eye0.npy'),
                cal_pt_cloud_eye0)
            np.save(
                os.path.join(self.g_pool.user_dir, 'cal_pt_cloud_eye1.npy'),
                cal_pt_cloud_eye1)

        else:
            self.g_pool.plugins.add(Simple_Gaze_Mapper,
                                    args={'params': params})