def set_stim_size(s): global stim, stimI, stimSpikeSyncer newStim = copy.deepcopy(stim) newStim.size_x = s newStim.size_y = s i = stimSpikeSyncer.find_stim(newStim) if i != -1: stimI = i stim = stimSpikeSyncer.stimList[i] get_spikes() atb.init() # global bar bar = atb.Bar(name="Controls", label="Controls", help="Scene controls", position=(10, 10), size=(200, 320)) # channel = ct.c_int(1) # stim_id = ct.c_int(1) # stim_x = ct.c_float(1) # stim_y = ct.c_float(1) # stim_size = ct.c_int(1) bar.add_var("Channel", getter=get_channel, setter=set_channel, vtype=ct.c_int) bar.add_var("Stim/I", getter=get_stim_i, setter=set_stim_i, vtype=ct.c_int) bar.add_var("Stim/Name", getter=get_stim_name, setter=set_stim_name,
def __init__(self, c): self.controller = c self.tracker_view = TrackerView() self.gui_frame_rate = 0.0 self.n_frames = 0 self.frame_count = 0 self.frame_rate_accum = 0.0 self.frame_rates = [] self.start_time = None self.last_time = 0 self.last_update_time = time.time() self.update_interval = 1 / 10000. atb.init() # Try grabbing current Width x Height for window to draw: # W = self.controller.get_camera_attribute('Width') # H = self.controller.get_camera_attribute('Height') # print "DEFINING WINDOW!!!! " + str(W) + ", " + str(H) self.window = glumpy.Window(656, 492) # (900, 700) # --------------------------------------------------------------------- # STAGE CONTROLS # --------------------------------------------------------------------- self.stages_bar = atb.Bar( name='stages', label='Stage Controls', iconified='true', help='Controls for adjusting stages', position=(10, 10), size=(200, 300), ) self.stages_bar.add_var('X/x_set', label='set value', target=c, attr='x_set') self.stages_bar.add_button('go_rel_x', lambda: c.go_rel_x(), group='X', label='move relative') self.stages_bar.add_button('go_abs_x', lambda: c.go_x(), group='X', label='move absolute') self.stages_bar.add_var('Y/y_set', label='set value', target=c, attr='y_set') self.stages_bar.add_button('go_rel_y', lambda: c.go_rel_y(), group='Y', label='move relative') self.stages_bar.add_button('go_abs_y', lambda: c.go_y(), group='Y', label='move absolute') self.stages_bar.add_var('R/r_set', label='set value', target=c, attr='r_set') self.stages_bar.add_button('go_rel_r', lambda: c.go_rel_r(), group='R', label='move relative') self.stages_bar.add_button('go_abs_r', lambda: c.go_r(), group='R', label='move absolute') self.stages_bar.add_button('up', lambda: c.up(), group='Jog', label='up') self.stages_bar.add_button('down', lambda: c.down(), group='Jog', label='down') self.stages_bar.add_button('left', lambda: c.left(), group='Jog', label='left') self.stages_bar.add_button('right', lambda: c.right(), group='Jog', label='right') # --------------------------------------------------------------------- # FOCUS AND ZOOM CONTROLS # --------------------------------------------------------------------- self.focus_zoom_bar = atb.Bar( name='focus_and_zoom', label='Focus/Zoom Controls', iconified='true', help='Controls for adjusting power focus and zoom', position=(10, 10), size=(200, 300), ) self.focus_zoom_bar.add_var('Focus/focus_step', label='focus step', target=c, attr='focus_step') self.focus_zoom_bar.add_button('focus_plus', lambda: c.focus_plus(), group='Focus', label='focus plus') self.focus_zoom_bar.add_button('focus_minus', lambda: c.focus_minus(), group='Focus', label='focus minus') self.focus_zoom_bar.add_var('Zoom/zoom_step', label='zoom step', target=c, attr='zoom_step') self.focus_zoom_bar.add_button('zoom_plus', lambda: c.zoom_plus(), group='Zoom', label='zoom plus') self.focus_zoom_bar.add_button('zoom_minus', lambda: c.zoom_minus(), group='Zoom', label='zoom minus') # --------------------------------------------------------------------- # LED CONTROLS # --------------------------------------------------------------------- self.led_bar = atb.Bar( name='leds', label='LED Controls', iconified='true', help='Controls for adjusting illumination', position=(20, 20), size=(200, 180), ) self.led_bar.add_var( 'Side/Ch1_mA', #target=c, #attr='IsetCh1', label='I Ch1 (mA)', vtype=atb.TW_TYPE_UINT32, setter=lambda x: c.led_set_current(1, x), getter=lambda: c.led_soft_current(1), min=0, max=1000, ) self.led_bar.add_var('Side/Ch1_status', label='Ch1 status', vtype=atb.TW_TYPE_BOOL8, getter=lambda: c.led_soft_status(1), setter=lambda x: c.led_set_status(1, x)) self.led_bar.add_var( 'Top/Ch2_mA', #target=c, #attr='IsetCh2', label='I Ch2 (mA)', vtype=atb.TW_TYPE_UINT32, setter=lambda x: c.led_set_current(2, x), getter=lambda: c.led_soft_current(2), min=0, max=1000, ) self.led_bar.add_var('Top/Ch2_status', vtype=atb.TW_TYPE_BOOL8, getter=lambda: c.led_soft_status(2), setter=lambda x: c.led_set_status(2, x)) # -------------------------------------------------------------------- # GUI # -------------------------------------------------------------------- self.gui_bar = atb.Bar( name='GUI', label='GUI', iconified='true', help='GUI Status', position=(60, 60), size=(200, 180), ) self.gui_bar.add_var('gui_framerate', label='gui frame rate', vtype=atb.TW_TYPE_FLOAT, min=1, max=200, step=0.1, readonly=True, getter=lambda: float(self.gui_frame_rate)) # -------------------------------------------------------------------- # CAMERA # -------------------------------------------------------------------- self.cam_bar = atb.Bar( name='Camera', label='Camera', iconified='true', help='Camera acquisition parameters', position=(60, 60), size=(200, 180), ) self.cam_bar.add_var( 'Recording/status', label='REC', vtype=atb.TW_TYPE_UINT32, getter=lambda: c.get_recording_status('recording'), setter=lambda x: c.set_recording_status('recording', int(x)), #attr='recording', ) self.cam_bar.add_var( 'Recording/name', label='name', vtype=atb.TW_TYPE_CDSTRING, getter=lambda: c.get_recording_name('subname'), setter=lambda x: c.set_recording_name(str(x)), #attr='recording', ) PixelFormat = atb.enum('PixelFormat', { 'Mono8': 0, 'Mono12Packed': 1, 'Mono16': 2 }) self.cam_bar.add_var( 'PixelFormat', label='pixel format', vtype=PixelFormat, getter=lambda: c.get_pixel_format('PixelFormat'), setter=lambda x: c.set_pixel_format('PixelFormat', int(x)), ) self.cam_bar.add_var( 'BytesPerFrame', label='total bytes per frame', vtype=atb.TW_TYPE_UINT32, min=1, max=645504, step=1, getter=lambda: c.get_camera_attribute('TotalBytesPerFrame'), # setter=lambda x: c.set_camera_attribute('BinningX', int(x)), ) self.cam_bar.add_var( 'framerate', label='frame rate', vtype=atb.TW_TYPE_FLOAT, min=1, max=125, step=0.1, readonly=True, getter=lambda: float(c.get_frame_rate()), ) self.cam_bar.add_var( 'Binning/binningX', label='binning X', vtype=atb.TW_TYPE_UINT32, min=1, max=4, step=1, getter=lambda: c.get_camera_attribute('BinningX'), setter=lambda x: c.set_camera_attribute('BinningX', int(x)), ) self.cam_bar.add_var( 'Binning/binningY', label='binning Y', vtype=atb.TW_TYPE_UINT32, min=1, max=4, step=1, getter=lambda: c.get_camera_attribute('BinningY'), setter=lambda x: c.set_camera_attribute('BinningY', int(x)), ) ExposureMode = atb.enum('ExposureMode', { 'Manual': 0, 'AutoOnce': 1, 'Auto': 2 }) self.cam_bar.add_var( 'Exposure/mode', label='mode', vtype=ExposureMode, getter=lambda: c.get_exposure_mode('ExposureMode'), setter=lambda x: c.set_exposure_mode('ExposureMode', int(x)), ) self.cam_bar.add_var( 'Exposure/value', label='time (us)', vtype=atb.TW_TYPE_UINT32, min=0, max=150000, step=1, getter=lambda: c.get_camera_attribute('ExposureValue'), setter=lambda x: c.set_camera_attribute('ExposureValue', int(x)), ) self.cam_bar.add_var( 'gain', label='Gain', vtype=atb.TW_TYPE_UINT32, min=1, max=50, step=1, #target=c, getter=lambda: c.get_camera_attribute('GainValue'), setter=lambda x: c.set_camera_attribute('GainValue', int(x)), attr='gain', ) # self.cam_bar.add_var( # 'exposure', # label='exposure', # vtype=atb.TW_TYPE_UINT32, # min=5000, # max=30000, # step=1000, # target=c, # attr='exposure', # ) self.cam_bar.add_var( 'ROI/roi_width', label='width', vtype=atb.TW_TYPE_UINT32, min=1, max=656, #656, step=1, #target=c, getter=lambda: c.get_camera_attribute('Width'), setter=lambda x: c.set_camera_attribute('Width', int(x)), attr='roi_width', ) self.cam_bar.add_var( 'ROI/roi_height', label='height', vtype=atb.TW_TYPE_UINT32, min=1, max=492, #492, step=1, #target=c, getter=lambda: c.get_camera_attribute('Height'), setter=lambda x: c.set_camera_attribute('Height', int(x)), attr='roi_height', ) # self.cam_bar.add_var( # 'ROI/roi_offset_x', # label='offset x', # vtype=atb.TW_TYPE_UINT32, # min=0, # max=800, # step=1, # target=c, # attr='roi_offset_x', # ) # self.cam_bar.add_var( # 'ROI/roi_offset_y', # label='offset y', # vtype=atb.TW_TYPE_UINT32, # min=0, # max=800, # step=1, # target=c, # attr='roi_offset_y', # ) # Event Handlers def on_init(): self.tracker_view.prepare_opengl() def on_draw(): self.tracker_view.draw((self.window.width, self.window.height)) def on_idle(dt): self.update_tracker_view() # time.sleep(0.05) def on_key_press(symbol, modifiers): if symbol == glumpy.key.ESCAPE: c.stop_continuous_acquisition() print "Controller has %i refs" % sys.getrefcount(c) c.release() self.controller = None print "Controller has %i refs" % sys.getrefcount(c) c.shutdown() #print "Shutting down controller..." #print "Shut down controller", c.shutdown() #c.continuously_acquiring = False #c.acq_thread.join() sys.exit() self.window.push_handlers(atb.glumpy.Handlers(self.window)) self.window.push_handlers(on_init, on_draw, on_key_press, on_idle) self.window.draw()
def setup_atb(self): atb.init() self.bar = atb.Bar(name="Controls", label="Controls", help="Scene controls", color=(50, 50, 50), alpha=50, text='light', position=(10, 10), size=(200, 440)) self.bar.add_var("World/Zoom", step=0.01, min=0.01, max=1.0, getter=self.trackball._get_zoom, setter=self.trackball._set_zoom) self.bar.add_var("World/Distance", step=1, min=1, max=300, getter=self.trackball._get_distance, setter=self.trackball._set_distance) self.bar.add_var("World/Show_World", self.tb_show, help="Show/Hide Trackball Camera") self.bar.add_separator("") self.bar.add_var("Eye/Show_Eye", self.eye_show, help="Show/Hide Eye Camera") self.bar.add_var("Eye/Camera", step=1, min=0, max=self.camera_manager.get_num_cams() - 1, getter=self.eye._get_current, setter=self._set_current_camera, key="SPACE") self.bar.add_separator("") self.bar.add_var("Image/Scale", step=0.00001, min=0.00001, getter=self.camera_manager.get_img_scale, setter=self.camera_manager.set_img_scale) self.bar.add_button("Show_Images", self.camera_manager.pyramid_show, key="1", help="Show All Images") self.bar.add_button("Hide_Images", self.camera_manager.pyramid_hide, key="2", help="Hide All Images") self.bar.add_button("Show_Cones", self.camera_manager.cone_show, key="3", help="Show All Fixation Cones") self.bar.add_button("Hide_Cones", self.camera_manager.cone_hide, key="4", help="Hide All Images") self.bar.add_separator("") self.bar.add_var("Points/Show_Points", self.points_show, key="RETURN", help="Show/Hide Points") self.bar.add_var("Points/Size", step=0.5, min=1.0, max=20.0, getter=self.point_manager._get_scale, setter=self.point_manager._set_scale) self.bar.add_button("Square Point", self.point_manager._make_square, key="9", help="Render square points") self.bar.add_button("Circular Point", self.point_manager._make_smooth, key="0", help="Render smooth points") self.bar.add_separator("") self.bar.add_var("Background/Color", self.color, open=False) self.bar.add_separator("") self.bar.add_var("Background/Fullscreen", self.full, help="Fullscreen mode for presentation") self.bar.add_button("Quit", self.quit, key="ESCAPE", help="Quit application")
def __init__(self, c): self.controller = c self.tracker_view = TrackerView() self.show_feature_map = c_bool(False) self.display_starburst = c_bool(False) self.n_frames = 0 self.frame_count = 0 self.frame_rate_accum = 0.0 self.frame_rates = [] self.start_time = None self.last_time = 0 self.last_update_time = time.time() self.calibration_file = '' atb.init() self.window = glumpy.Window(900, 600) self.window.draw() self.gaze_bar = atb.Bar(name='gaze', label='Gaze Info', iconified='false', help='Current Gaze', position=(10, 10), size=(100, 200)) # self.gaze_bar.add_var('Gaze/Status', label='Calibration Status', # target=c, attr='calibration_status', readonly=True) self.gaze_bar.add_var('Gaze/H', label='Horizontal Gaze', target=c, attr='gaze_azimuth', readonly=True) self.gaze_bar.add_var('Gaze/V', label='Vertical Gaze', target=c, attr='gaze_elevation', readonly=True) # self.gaze_bar.add_var('FPS', label='FPS', target=c, # attr='conduit_fps', readonly=True) # --------------------------------------------------------------------- # STAGE CONTROLS # --------------------------------------------------------------------- # self.stages_bar = atb.Bar( # name='stages', # label='Stage Controls', # iconified='true', # help='Controls for adjusting stages', # position=(10, 10), # size=(200, 300), # ) # self.stages_bar.add_var('X/x_set', label='set value', target=c, # attr='x_set') # self.stages_bar.add_button('go_rel_x', lambda: c.go_rel_x(), group='X', # label='move relative') # self.stages_bar.add_button('go_abs_x', lambda: c.go_x(), group='X', # label='move absolute') # self.stages_bar.add_var('Y/y_set', label='set value', target=c, # attr='y_set') # self.stages_bar.add_button('go_rel_y', lambda: c.go_rel_y(), group='Y', # label='move relative') # self.stages_bar.add_button('go_abs_y', lambda: c.go_y(), group='Y', # label='move absolute') # self.stages_bar.add_var('R/r_set', label='set value', target=c, # attr='r_set') # self.stages_bar.add_button('go_rel_r', lambda: c.go_rel_r(), group='R', # label='move relative') # self.stages_bar.add_button('go_abs_r', lambda: c.go_r(), group='R', # label='move absolute') # self.stages_bar.add_button('up', lambda: c.up(), group='Jog', # label='up') # self.stages_bar.add_button('down', lambda: c.down(), group='Jog', # label='down') # self.stages_bar.add_button('left', lambda: c.left(), group='Jog', # label='left') # self.stages_bar.add_button('right', lambda: c.right(), group='Jog', # label='right') # --------------------------------------------------------------------- # FOCUS AND ZOOM CONTROLS # --------------------------------------------------------------------- # self.focus_zoom_bar = atb.Bar( # name='focus_and_zoom', # label='Focus/Zoom Controls', # iconified='true', # help='Controls for adjusting power focus and zoom', # position=(10, 10), # size=(200, 300), # ) # self.focus_zoom_bar.add_var('Focus/focus_step', label='focus step', # target=c, attr='focus_step') # self.focus_zoom_bar.add_button('focus_plus', lambda: c.focus_plus(), # group='Focus', label='focus plus') # self.focus_zoom_bar.add_button('focus_minus', lambda: c.focus_minus(), # group='Focus', label='focus minus') # self.focus_zoom_bar.add_var('Zoom/zoom_step', label='zoom step', # target=c, attr='zoom_step') # self.focus_zoom_bar.add_button('zoom_plus', lambda: c.zoom_plus(), # group='Zoom', label='zoom plus') # self.focus_zoom_bar.add_button('zoom_minus', lambda: c.zoom_minus(), # group='Zoom', label='zoom minus') # --------------------------------------------------------------------- # LED CONTROLS # --------------------------------------------------------------------- # self.led_bar = atb.Bar( # name='leds', # label='LED Controls', # iconified='true', # help='Controls for adjusting illumination', # position=(20, 20), # size=(200, 180), # ) # self.led_bar.add_var( # 'Side/Ch1_mA', # #target=c, # #attr='IsetCh1', # label='I Ch1 (mA)', # vtype=atb.TW_TYPE_UINT32, # setter=lambda x: c.leds.set_current(1, x), # getter=lambda: c.leds.soft_current(1), # min=0, # max=1000, # ) # self.led_bar.add_var('Side/Ch1_status', label='Ch1 status', # vtype=atb.TW_TYPE_BOOL8, # getter=lambda: c.leds.soft_status(1), # setter=lambda x: c.leds.set_status(1, x)) # self.led_bar.add_var( # 'Top/Ch2_mA', # #target=c, # #attr='IsetCh2', # label='I Ch2 (mA)', # vtype=atb.TW_TYPE_UINT32, # setter=lambda x: c.leds.set_current(2, x), # getter=lambda: c.leds.soft_current(2), # min=0, # max=1000, # ) # self.led_bar.add_var('Top/Ch2_status', vtype=atb.TW_TYPE_BOOL8, # getter=lambda: c.leds.soft_status(2), # setter=lambda x: c.leds.set_status(2, x)) #self.led_bar.add_var( # 'Channel3/Ch3_mA', # target=c, # attr='IsetCh3', # label='I Ch3 (mA)', # setter=lambda x: c.leds.set_current(3,x), # min=0, # max=250, # ) # self.led_bar.add_var('Channel3/Ch3_status', label='Ch3 status', # vtype=atb.TW_TYPE_BOOL8, # getter=lambda: c.leds.soft_status(3), # setter=lambda x: c.leds.set_status(3, x)) # # self.led_bar.add_var( # 'Channel4/Ch4_mA', # target=c, # attr='IsetCh4', # label='I Ch4 (mA)', # setter=lambda x: c.leds.set_current(4,x), # min=0, # max=250, # ) # self.led_bar.add_var('Channel4/Ch4_status', label='Ch4 status', # vtype=atb.TW_TYPE_BOOL8, # getter=lambda: c.leds.soft_status(4), # setter=lambda x: c.leds.set_status(4, x)) # --------------------------------------------------------------------- # RADIAL FEATURE FINDER # --------------------------------------------------------------------- if True: radial_ff = c.radial_ff self.radial_ff_bar = atb.Bar( name='RadialFF', label='Radial Symmetry', help='Parameters for initial (symmetry-based) image processing', iconified='true', position=(30, 30), size=(250, 180), ) self.radial_ff_bar.add_var( 'target_kpixels', label='Target kPixels', vtype=atb.TW_TYPE_FLOAT, min=50., max=1000., step=10., target=radial_ff, attr='target_kpixels', ) self.radial_ff_bar.add_var( 'min_radius_fraction', label='Min. radius (fraction)', vtype=atb.TW_TYPE_FLOAT, min=0.01, max=0.5, step=0.01, target=radial_ff, attr='min_radius_fraction', ) self.radial_ff_bar.add_var( 'max_radius_fraction', label='Max. radius (fraction)', vtype=atb.TW_TYPE_FLOAT, min=0.1, max=0.8, step=0.01, target=radial_ff, attr='max_radius_fraction', ) self.radial_ff_bar.add_var( 'radius_steps', label='Radius steps', vtype=atb.TW_TYPE_UINT32, min=1, max=10, step=1, target=radial_ff, attr='radius_steps', ) self.radial_ff_bar.add_var( 'alpha', label='Alpha', vtype=atb.TW_TYPE_FLOAT, min=1., max=50., step=1., target=radial_ff, attr='alpha', ) self.radial_ff_bar.add_var('show_transform', label='Show Transform', vtype=atb.TW_TYPE_BOOL8, target=self, attr='show_feature_map') self.radial_ff_bar.add_var('Albino/albino_mode_enable', label='Mode Enabled', vtype=atb.TW_TYPE_BOOL8, target=radial_ff, attr='albino_mode') self.radial_ff_bar.add_var( 'Albino/albino_threshold', label='Threshold', vtype=atb.TW_TYPE_FLOAT, min=0.1, max=50., step=1., target=radial_ff, attr='albino_threshold', ) self.radial_ff_bar.add_var( 'RestrictRegion/top', label='top', vtype=atb.TW_TYPE_UINT32, min=0, max=300, step=1, target=radial_ff, attr='restrict_top', ) self.radial_ff_bar.add_var( 'RestrictRegion/left', label='left', vtype=atb.TW_TYPE_UINT32, min=0, max=300, step=1, target=radial_ff, attr='restrict_left', ) self.radial_ff_bar.add_var( 'RestrictRegion/right', label='right', vtype=atb.TW_TYPE_UINT32, min=0, max=300, step=1, target=radial_ff, attr='restrict_right', ) self.radial_ff_bar.add_var( 'RestrictRegion/bottom', label='bottom', vtype=atb.TW_TYPE_UINT32, min=0, max=300, step=1, target=radial_ff, attr='restrict_bottom', ) # --------------------------------------------------------------------- # STARBURST FEATURE FINDER # --------------------------------------------------------------------- self.sb_ff_bar = atb.Bar( name='StarburstFF', label='Starburst', iconified='true', help= "Parameters for the refinement phase ('starburst') image processing", position=(40, 40), size=(200, 250), ) sb_ff = c.starburst_ff self.sb_ff_bar.add_var( 'Pupil/n_pupil_rays', label='n rays', vtype=atb.TW_TYPE_UINT32, min=1, max=100, step=1, target=sb_ff, attr='pupil_n_rays', ) self.sb_ff_bar.add_var( 'Pupil/pupil_min_radius', label='min radius', vtype=atb.TW_TYPE_UINT32, min=1, max=100, step=1, target=sb_ff, attr='pupil_min_radius', ) self.sb_ff_bar.add_var( 'Pupil/pupil_threshold', label='edge detect threshold', vtype=atb.TW_TYPE_FLOAT, min=0.1, max=5.0, step=0.1, target=sb_ff, attr='pupil_threshold', ) self.sb_ff_bar.add_var( 'CR/n_cr_rays', label='n rays', vtype=atb.TW_TYPE_UINT32, min=1, max=100, step=1, target=sb_ff, attr='cr_n_rays', ) self.sb_ff_bar.add_var( 'CR/cr_min_radius', label='min radius', vtype=atb.TW_TYPE_UINT32, min=1, max=100, step=1, target=sb_ff, attr='cr_min_radius', ) self.sb_ff_bar.add_var( 'CR/cr_threshold', label='edge detect threshold', vtype=atb.TW_TYPE_FLOAT, min=0.1, max=5.0, step=0.1, target=sb_ff, attr='cr_threshold', ) fit_algos = { 0: 'circle_least_squares', 1: 'circle_least_squares_ransac', 2: 'ellipse_least_squares' } fit_algos_rev = dict([(val, key) for (key, val) in fit_algos.items()]) FittingAlgorithm = atb.enum('FittingAlgorithm', { 'circle lst sq': 0, 'circle ransac': 1, 'ellipse lst sq': 2 }) self.sb_ff_bar.add_var('Fitting/circle_fit', label='circle fit method', vtype=FittingAlgorithm, getter=lambda: \ fit_algos_rev[sb_ff.fitting_algorithm], setter=lambda x: \ setattr(sb_ff, 'fitting_algorithm', fit_algos[x])) self.sb_ff_bar.add_var('Display/show_rays', self.display_starburst) # --------------------------------------------------------------------- # CALIBRATION # --------------------------------------------------------------------- # self.cal_bar = atb.Bar( # name='Calibration', # label='Calibration', # iconified='true', # help='Auto-calibration steps', # position=(50, 50), # size=(250, 300), # refresh=0.5 # ) # self.cal_bar.add_button('calibrate', lambda: c.calibrate(), # label='Calibrate (full)') # self.cal_bar.add_separator('Sub-phases') # self.cal_bar.add_button('cal_center_h', lambda: \ # c.calibrate_center_horizontal(), # label='Center Horizontal') # self.cal_bar.add_button('cal_center_v', lambda: \ # c.calibrate_center_vertical(), # label='Center Vertical') # self.cal_bar.add_button('cal_center_d', lambda: \ # c.calibrate_center_depth(), label='Center Depth' # ) # self.cal_bar.add_button('cal_pupil_rad', lambda: \ # c.calibrate_find_pupil_radius(), # label='Find Pupil Radius') # self.cal_bar.add_separator('Info') # self.cal_bar.add_var('d', label='Distance to CR curv. center', # vtype=atb.TW_TYPE_FLOAT, target=c.calibrator, # attr='d') # readonly = True, # self.cal_bar.add_var('Rp', label='Pupil rotation radius (Rp)[mm]', # vtype=atb.TW_TYPE_FLOAT, target=c.calibrator, # attr='Rp_mm') # readonly = True, # # Calibration Files # try: # self.refresh_calibration_file_list() # self.cal_bar.add_separator('Calibration Files') # self.cal_bar.add_var('current_calibration_file', # vtype=self.cal_enum, label='Calibration File', # getter=lambda: \ # self.get_calibration_file_atb(), # setter=lambda x: \ # self.set_calibration_file_atb(x)) # # setter = lambda x: sb_ff.__dict__.__setitem__('fitting_algorithm', fit_algos[x])) # # getter=lambda: self.get_calibration_file_atb, # # setter=lambda x: self.set_calibration_file_atb(x)) # self.cal_bar.add_separator('Calibration Save') # self.cal_file_save_name = ctypes.c_char_p('') # self.cal_bar.add_var('calibration_file_save_name', # vtype=atb.TW_TYPE_CDSTRING, target=self, # attr='cal_file_save_name') # self.cal_bar.add_button('save_calibration', lambda: \ # self.save_calibration_file_atb(self.cal_file_save_name)) # except Exception as E: # logging.warning("Error setting calibration file list: %s" % E) # logging.warning("""Unable to use calibration-file saving # infrastructure. A patched version of glumpy # is required to enable this feature.""") # -------------------------------------------------------------------- # CAMERA # -------------------------------------------------------------------- self.cam_bar = atb.Bar( name='Camera', label='Camera', iconified='true', help='Camera acquisition parameters', position=(60, 60), size=(200, 180), ) cam = c.camera # def saving(x=None): # if not hasattr(c.feature_finder, 'save'): # return False # if x is None: # return c.feature_finder.save # c.feature_finder.save = x # self.cam_bar.add_var( # 'save', # label='save', # vtype=atb.TW_TYPE_BOOL8, # getter=lambda: saving(), # setter=lambda x: saving(x), # ) # self.cam_bar.add_var( # 'binning', # label='binning', # vtype=atb.TW_TYPE_UINT32, # min=1, # max=16, # step=1, # target=cam, # attr='binning', # ) # self.cam_bar.add_var( # 'gain', # label='gain', # vtype=atb.TW_TYPE_UINT32, # min=1, # max=16, # step=1, # target=cam, # attr='gain', # ) # self.cam_bar.add_var( # 'exposure', # label='exposure', # vtype=atb.TW_TYPE_UINT32, # min=5000, # max=30000, # step=1000, # target=c, # attr='exposure', # ) self.cam_bar.add_var( 'ROI/roi_width', label='width', vtype=atb.TW_TYPE_UINT32, min=1, max=800, step=1, target=cam, attr='roi_width', ) self.cam_bar.add_var( 'ROI/roi_height', label='height', vtype=atb.TW_TYPE_UINT32, min=1, max=800, step=1, target=cam, attr='roi_height', ) # Event Handlers def on_init(): self.tracker_view.prepare_opengl() def on_draw(): self.window.clear() self.tracker_view.draw((self.window.width, self.window.height)) def on_idle(dt): # if dt < 0.02: # return self.update_tracker_view() self.window.draw() def on_key_press(symbol, modifiers): if symbol == glumpy.key.ESCAPE: c.stop_continuous_acquisition() logging.debug("Controller has %i refs" % sys.getrefcount(c)) c.release() self.controller = None logging.debug("Controller has %i refs" % sys.getrefcount(c)) c.shutdown() sys.exit() self.window.push_handlers(atb.glumpy.Handlers(self.window)) self.window.push_handlers(on_init, on_draw, on_key_press, on_idle) self.window.draw()