diff --git a/pupil_src/player/main.py b/pupil_src/player/main.py index 4e2cc85de2..092ea5b312 100644 --- a/pupil_src/player/main.py +++ b/pupil_src/player/main.py @@ -238,6 +238,7 @@ def get_dt(): g_pool.rec_dir = rec_dir g_pool.rec_version = rec_version g_pool.meta_info = meta_info + g_pool.min_data_confidence = session_settings.get('min_data_confidence',0.6) g_pool.pupil_positions_by_frame = correlate_data(pupil_list,g_pool.timestamps) g_pool.gaze_positions_by_frame = correlate_data(gaze_list,g_pool.timestamps) g_pool.fixations_by_frame = [[] for x in g_pool.timestamps] #populated by the fixation detector plugin @@ -268,6 +269,12 @@ def set_scale(new_scale): g_pool.gui.scale = new_scale g_pool.gui.collect_menus() + def set_data_confidence(new_confidence): + g_pool.min_data_confidence = new_confidence + notification = {'subject':'min_data_confidence_changed'} + notification['_notify_time_'] = time()+.8 + g_pool.delayed_notifications[notification['subject']] = notification + def open_plugin(plugin): if plugin == "Select to load": return @@ -303,6 +310,7 @@ def do_export(_): g_pool.main_menu.append(ui.Slider('scale',g_pool.gui, setter=set_scale,step = .05,min=0.75,max=2.5,label='Interface Size')) g_pool.main_menu.append(ui.Info_Text('Player Version: %s'%g_pool.version)) g_pool.main_menu.append(ui.Info_Text('Recording Version: %s'%rec_version)) + g_pool.main_menu.append(ui.Slider('min_data_confidence',g_pool, setter=set_data_confidence,step=.05 ,min=0.0,max=1.0,label='Confidence threshold')) selector_label = "Select to load" @@ -464,6 +472,7 @@ def do_export(_): glfwPollEvents() session_settings['loaded_plugins'] = g_pool.plugins.get_initializers() + session_settings['min_data_confidence'] = g_pool.min_data_confidence session_settings['gui_scale'] = g_pool.gui.scale session_settings['ui_config'] = g_pool.gui.configuration session_settings['window_size'] = glfwGetWindowSize(main_window) diff --git a/pupil_src/player/player_methods.py b/pupil_src/player/player_methods.py index b96fc50c63..d3b4380da3 100644 --- a/pupil_src/player/player_methods.py +++ b/pupil_src/player/player_methods.py @@ -82,6 +82,8 @@ def update_recording_to_recent(rec_dir): update_recording_v074_to_v082(rec_dir) if rec_version < VersionFormat('0.8.3'): update_recording_v082_to_v083(rec_dir) + if rec_version < VersionFormat('0.8.6'): + update_recording_v083_to_v086(rec_dir) # How to extend: # if rec_version < VersionFormat('FUTURE FORMAT'): # update_recording_v081_to_FUTURE(rec_dir) @@ -150,6 +152,26 @@ def update_recording_v082_to_v083(rec_dir): csv_utils.write_key_value_file(csvfile,meta_info) +def update_recording_v083_to_v086(rec_dir): + logger.info("Updating recording from v0.8.3 format to v0.8.6 format") + pupil_data = load_object(os.path.join(rec_dir, "pupil_data")) + meta_info_path = os.path.join(rec_dir,"info.csv") + + for topic in pupil_data.keys(): + for d in pupil_data[topic]: + d['topic'] = topic + + save_object(pupil_data,os.path.join(rec_dir, "pupil_data")) + + with open(meta_info_path) as csvfile: + meta_info = csv_utils.read_key_value_file(csvfile) + meta_info['Capture Software Version'] = 'v0.8.6' + + with open(meta_info_path,'w') as csvfile: + csv_utils.write_key_value_file(csvfile,meta_info) + + + def update_recording_v073_to_v074(rec_dir): logger.info("Updating recording from v0.7x format to v0.7.4 format") pupil_data = load_object(os.path.join(rec_dir, "pupil_data")) diff --git a/pupil_src/player/vis_circle.py b/pupil_src/player/vis_circle.py index 420d05272d..f23e8796c9 100644 --- a/pupil_src/player/vis_circle.py +++ b/pupil_src/player/vis_circle.py @@ -42,7 +42,7 @@ def update(self,frame,events): else: thickness = self.thickness - pts = [denormalize(pt['norm_pos'],frame.img.shape[:-1][::-1],flip_y=True) for pt in events.get('gaze_positions',[])] + pts = [denormalize(pt['norm_pos'],frame.img.shape[:-1][::-1],flip_y=True) for pt in events.get('gaze_positions',[]) if pt['confidence']>=self.g_pool.min_data_confidence] for pt in pts: transparent_circle(frame.img, pt, radius=self.radius, color=(self.b, self.g, self.r, self.a), thickness=thickness) diff --git a/pupil_src/player/vis_cross.py b/pupil_src/player/vis_cross.py index 4e49038986..90b1aad8f4 100644 --- a/pupil_src/player/vis_cross.py +++ b/pupil_src/player/vis_cross.py @@ -32,7 +32,7 @@ def __init__(self, g_pool,inner=20,outer=100,color=(1.,0.0,0.0,1.0),thickness=1) self.thickness = thickness def update(self,frame,events): - pts = [denormalize(pt['norm_pos'],frame.img.shape[:-1][::-1],flip_y=True) for pt in events.get('gaze_positions',[])] + pts = [denormalize(pt['norm_pos'],frame.img.shape[:-1][::-1],flip_y=True) for pt in events.get('gaze_positions',[]) if pt['confidence']>=self.g_pool.min_data_confidence] bgra = (self.b*255,self.g*255,self.r*255,self.a*255) for pt in pts: lines = np.array( [((pt[0]-self.inner,pt[1]),(pt[0]-self.outer,pt[1])),((pt[0]+self.inner,pt[1]),(pt[0]+self.outer,pt[1])) , ((pt[0],pt[1]-self.inner),(pt[0],pt[1]-self.outer)) , ((pt[0],pt[1]+self.inner),(pt[0],pt[1]+self.outer))],dtype=np.int32 ) diff --git a/pupil_src/player/vis_light_points.py b/pupil_src/player/vis_light_points.py index ade3c0767b..aa737d0dd7 100644 --- a/pupil_src/player/vis_light_points.py +++ b/pupil_src/player/vis_light_points.py @@ -35,7 +35,7 @@ def update(self,frame,events): falloff = self.falloff img = frame.img - screen_gaze = [denormalize(g['norm_pos'],self.g_pool.capture.frame_size,flip_y=True) for g in events.get('gaze_positions',[])] + pts = [denormalize(pt['norm_pos'],frame.img.shape[:-1][::-1],flip_y=True) for pt in events.get('gaze_positions',[]) if pt['confidence']>=self.g_pool.min_data_confidence] overlay = np.ones(img.shape[:-1],dtype=img.dtype) diff --git a/pupil_src/player/vis_polyline.py b/pupil_src/player/vis_polyline.py index ac31a6cf40..005e005c8f 100644 --- a/pupil_src/player/vis_polyline.py +++ b/pupil_src/player/vis_polyline.py @@ -30,7 +30,7 @@ def __init__(self, g_pool,color=(1.0,0.0,0.4,1.0),thickness=2): self.thickness = thickness def update(self,frame,events): - pts = [denormalize(pt['norm_pos'],frame.img.shape[:-1][::-1],flip_y=True) for pt in events.get('gaze_positions',[])] + pts = [denormalize(pt['norm_pos'],frame.img.shape[:-1][::-1],flip_y=True) for pt in events.get('gaze_positions',[]) if pt['confidence']>=self.g_pool.min_data_confidence] bgra = (self.b*255,self.g*255,self.r*255,self.a*255) if pts: pts = np.array([pts],dtype=np.int32) diff --git a/pupil_src/shared_modules/offline_reference_surface.py b/pupil_src/shared_modules/offline_reference_surface.py index 778fac3fe6..1300f08f20 100644 --- a/pupil_src/shared_modules/offline_reference_surface.py +++ b/pupil_src/shared_modules/offline_reference_surface.py @@ -203,7 +203,8 @@ def generate_heatmap(self,section): if c_e: frame_idx+=section.start for gp in self.gaze_on_srf_by_frame_idx(frame_idx,c_e['m_from_screen']): - all_gaze.append(gp['norm_pos']) + if gp['confidence']>=self.g_pool.min_data_confidence: + all_gaze.append(gp['norm_pos']) if not all_gaze: logger.warning("No gaze data on surface for heatmap found.") diff --git a/pupil_src/shared_modules/offline_surface_tracker.py b/pupil_src/shared_modules/offline_surface_tracker.py index d20e624168..262de8f042 100644 --- a/pupil_src/shared_modules/offline_surface_tracker.py +++ b/pupil_src/shared_modules/offline_surface_tracker.py @@ -151,11 +151,14 @@ def on_notify(self,notification): if notification['subject'] == 'gaze_positions_changed': logger.info('Gaze postions changed. Recalculating.') self.recalculate() + if notification['subject'] == 'min_data_confidence_changed': + logger.info('Min_data_confidence changed. Recalculating.') + self.recalculate() elif notification['subject'] == 'surfaces_changed': logger.info('Surfaces changed. Recalculating.') self.recalculate() elif notification['subject'] == 'min_marker_perimeter_changed': - logger.info('Min marper perimeter adjusted. Re-detecting surfaces.') + logger.info('Min marker perimeter adjusted. Re-detecting surfaces.') self.invalidate_surface_caches() elif notification['subject'] is "should_export": self.save_surface_statsics_to_file(notification['range'],notification['export_dir']) diff --git a/pupil_src/shared_modules/reference_surface.py b/pupil_src/shared_modules/reference_surface.py index 6bd3566989..734da622b1 100644 --- a/pupil_src/shared_modules/reference_surface.py +++ b/pupil_src/shared_modules/reference_surface.py @@ -406,7 +406,7 @@ def map_datum_to_surface(d,m_from_screen): mapped_pos = cv2.perspectiveTransform(pos , m_from_screen ) mapped_pos.shape = (2) on_srf = bool((0 <= mapped_pos[0] <= 1) and (0 <= mapped_pos[1] <= 1)) - return {'norm_pos':(mapped_pos[0],mapped_pos[1]),'on_srf':on_srf,'base_data':d } + return {'topic':d['topic']+"_on_surface",'norm_pos':(mapped_pos[0],mapped_pos[1]),'confidence':d['confidence'],'on_srf':on_srf,'base_data':d } def map_data_to_surface(self,data,m_from_screen): return [self.map_datum_to_surface(d,m_from_screen) for d in data]