def __init__(self): Plugin.__init__(self) self.dispatcher = Dispatcher() self.dispatcher.define('learn', self.cmdDefine, access='member', argc=2) self.dispatcher.define('define', self.cmdDefine, access='member', argc=2) self.dispatcher.define('forget', self.cmdForget, access='member', argc=1) self.dispatcher.define('definfo', self.cmdDefInfo, access='moderator', argc=1)
def __init__(self, g_pool,atb_pos=(0,0)): Plugin.__init__(self) self.active = False self.detected = False self.g_pool = g_pool self.pos = None self.smooth_pos = 0.,0. self.smooth_vel = 0. self.sample_site = (-2,-2) self.counter = 0 self.counter_max = 30 self.candidate_ellipses = [] self.show_edges = c_bool(0) self.aperture = 7 self.dist_threshold = c_int(10) self.area_threshold = c_int(30) self.world_size = None self.stop_marker_found = False self.auto_stop = 0 self.auto_stop_max = 30 atb_label = "calibrate using handheld marker" # Creating an ATB Bar is required. Show at least some info about the Ref_Detector self._bar = atb.Bar(name = self.__class__.__name__, label=atb_label, help="ref detection parameters", color=(50, 50, 50), alpha=100, text='light', position=atb_pos,refresh=.3, size=(300, 100)) self._bar.add_button("start/stop", self.start_stop, key='c') self._bar.add_var("show edges",self.show_edges, group="Advanced")
def __init__(self, g_pool, atb_pos=(10, 400)): Plugin.__init__(self) self.context = zmq.Context() self.socket = self.context.socket(zmq.PUB) self.address = create_string_buffer("tcp://127.0.0.1:5000", 512) self.set_server(self.address) help_str = "Pupil Message server: Using ZMQ and the *Publish-Subscribe* scheme" self._bar = atb.Bar(name=self.__class__.__name__, label='Server', help=help_str, color=(50, 50, 50), alpha=100, text='light', position=atb_pos, refresh=.3, size=(300, 40)) self._bar.define("valueswidth=170") self._bar.add_var("server address", self.address, getter=lambda: self.address, setter=self.set_server) self._bar.add_button("close", self.close) self.exclude_list = [ 'ellipse', 'pos_in_roi', 'major', 'minor', 'axes', 'angle', 'center' ]
def __init__(self,g_pool,atb_pos=(0,0)): Plugin.__init__(self) self.collect_new = False self.calculated = False self.obj_grid = _gen_pattern_grid((4, 11)) self.img_points = [] self.obj_points = [] self.count = 10 self.img_shape = None self.display_grid = _make_grid() self.window_should_open = False self.window_should_close = False self._window = None self.fullscreen = c_bool(0) self.monitor_idx = c_int(0) self.monitor_handles = glfwGetMonitors() self.monitor_names = [glfwGetMonitorName(m) for m in self.monitor_handles] monitor_enum = atb.enum("Monitor",dict(((key,val) for val,key in enumerate(self.monitor_names)))) #primary_monitor = glfwGetPrimaryMonitor() atb_label = "estimate camera instrinsics" # Creating an ATB Bar is required. Show at least some info about the Ref_Detector self._bar = atb.Bar(name =self.__class__.__name__, label=atb_label, help="ref detection parameters", color=(50, 50, 50), alpha=100, text='light', position=atb_pos,refresh=.3, size=(300, 100)) self._bar.add_var("monitor",self.monitor_idx, vtype=monitor_enum) self._bar.add_var("fullscreen", self.fullscreen) self._bar.add_button(" show pattern ", self.do_open, key='c') self._bar.add_button(" Capture Pattern", self.advance, key="SPACE") self._bar.add_var("patterns to capture", getter=self.get_count)
def __init__(self, teh_bot): Plugin.__init__(self, teh_bot) random.seed() self.command_dictionary = { "choice": self.random, "question": self.question, "random": self.random, "scale": self.scale, } self.command_info = { "question": [ " %squestion QUESTION" % self.command_prefix, "Returns a positive or a negative response to your question", ], "scale": [ " %sscale STATEMENT" % self.command_prefix, " %sscale" % self.command_prefix, "Scales your statment in procent", "(random number between 1 and 100)", ], "random": [ " %srandom CHOICE1 CHOICE2 CHOICE3" % self.command_prefix, " %srandom CHOICE1, CHOICE2, CHOICE3" % self.command_prefix, " %srandom CHOICE1 or CHOICE2 or CHOICE3" % self.command_prefix, "Makes a random choice of the ones provided", " %srandom NUMBER1 - NUMBER2" % self.command_prefix, " %srandom NUMBER1 to NUMBER2" % self.command_prefix, "Selects a random number between the two provided", ], }
def __init__( self, address="225.1.1.1", port=5200, interface="0.0.0.0" ): Plugin.__init__(self, "broadcast") self.address = address self.port = port self.interface = interface try: # Instantiate a UDP socket self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) # Allow address reuse self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # Set the packets TTL self.sock.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_TTL, 1) # Do not loop messages back to the local sockets self.sock.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_LOOP, 0) # Bind to the port self.sock.bind(('', self.port)) # Set the interface to perform the multicast on self.sock.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_IF, socket.inet_aton(self.interface)) # Apply for messages sent to the specified address self.sock.setsockopt(socket.SOL_IP, socket.IP_ADD_MEMBERSHIP, socket.inet_aton(self.address) + socket.inet_aton(self.interface)) self._initialized = True except socket.error: pass
def __init__(self, g_pool, atb_pos=(0, 0)): Plugin.__init__(self) self.g_pool = g_pool self.first_img = None self.point = None self.count = 0 self.detected = False self.active = False self.pos = None self.r = 40.0 # radius of circle displayed self.ref_list = [] self.pupil_list = [] atb_label = "calibrate using natural features" self._bar = atb.Bar( name=self.__class__.__name__, label=atb_label, help="ref detection parameters", color=(50, 50, 50), alpha=100, text="light", position=atb_pos, refresh=0.3, size=(300, 100), ) self._bar.add_button("start/stop", self.start_stop, key="c")
def __init__(self,data): # call the plugin basic initializations Plugin.__init__(self,data) # set the name of your plugin self.setName("end_optimum_value_kruskal", "Make non-parametric over ALL tests.")
def __init__(self, g_pool, atb_pos=(0, 0)): Plugin.__init__(self) self.active = False self.detected = False self.g_pool = g_pool self.pos = None self.smooth_pos = 0., 0. self.smooth_vel = 0. self.sample_site = (-2, -2) self.counter = 0 self.counter_max = 30 self.candidate_ellipses = [] self.show_edges = c_bool(0) self.aperture = 7 self.dist_threshold = c_int(10) self.area_threshold = c_int(30) self.world_size = None self.stop_marker_found = False self.auto_stop = 0 self.auto_stop_max = 30 atb_label = "calibrate using handheld marker" # Creating an ATB Bar is required. Show at least some info about the Ref_Detector self._bar = atb.Bar(name=self.__class__.__name__, label=atb_label, help="ref detection parameters", color=(50, 50, 50), alpha=100, text='light', position=atb_pos, refresh=.3, size=(300, 100)) self._bar.add_button("start/stop", self.start_stop, key='c') self._bar.add_var("show edges", self.show_edges, group="Advanced")
def __init__(self, g_pool, atb_pos=(10, 400), on_char_fn=None): Plugin.__init__(self) self.g_pool = g_pool self.on_char_fn = on_char_fn self.order = .9 #excecute late in the plugin list. self.context = zmq.Context() self.socket = self.context.socket(zmq.REP) self.address = create_string_buffer('', 512) self.set_server(create_string_buffer("tcp://*:50020", 512)) help_str = "Pupil Remote using REQ RREP schema. " self._bar = atb.Bar(name=self.__class__.__name__, label='Remote', help=help_str, color=(50, 50, 50), alpha=100, text='light', position=atb_pos, refresh=.3, size=(300, 40)) self._bar.define("valueswidth=170") self._bar.add_var("server address", self.address, getter=lambda: self.address, setter=self.set_server) self._bar.add_button("close", self.close) self.exclude_list = [ 'ellipse', 'pos_in_roi', 'major', 'minor', 'axes', 'angle', 'center' ]
def __init__(self, global_calibrate,shared_pos,screen_marker_pos,screen_marker_state,atb_pos=(0,0)): Plugin.__init__(self) self.active = False self.detected = False self.publish = False self.global_calibrate = global_calibrate self.global_calibrate.value = False self.shared_pos = shared_pos self.pos = 0,0 # 0,0 is used to indicate no point detected self.smooth_pos = 0.,0. self.smooth_vel = 0. self.sample_site = (-2,-2) self.counter = 0 self.counter_max = 30 self.candidate_ellipses = [] self.show_edges = c_bool(0) self.aperture = c_int(7) self.dist_threshold = c_int(10) self.area_threshold = c_int(30) atb_label = "calibrate using handheld marker" # Creating an ATB Bar is required. Show at least some info about the Ref_Detector self._bar = atb.Bar(name = self.__class__.__name__, label=atb_label, help="ref detection parameters", color=(50, 50, 50), alpha=100, text='light', position=atb_pos,refresh=.3, size=(300, 100)) self._bar.add_button("start", self.start, key='c')
def __init__(self,g_pool,atb_pos=(0,0)): Plugin.__init__(self) self.window_should_open = False self.window_should_close = False self._window = None self.fullscreen = c_bool(0) self.realdata = c_bool(False) self.x = c_float(0) self.y = c_float(0) self.blink_time = c_float(1) self.should_blink = False self.blink_start = None atb_label = "android coordinate plugin" # Creating an ATB Bar. self._bar = atb.Bar(name =self.__class__.__name__, label=atb_label, help="ref detection parameters", color=(50, 50, 50), alpha=100, text='light', position=atb_pos,refresh=.3, size=(300, 100)) self._bar.add_var("real data", self.realdata) self._bar.add_var("X", self.x) self._bar.define("min=0 max=1 step=0.01", "X") self._bar.add_var("Y", self.y) self._bar.define("min=0 max=1 step=0.01", "Y") self._bar.add_var("blink time", self.blink_time, min=0,max=10,step=0.05,help="Simulated blink time") # self._bar.define("min=0 max=10000 step=50", "blink time") self._bar.add_button("simulate blink", self.schedule_blink)
def __init__(self, g_pool, atb_pos=(0, 0)): Plugin.__init__(self) self.g_pool = g_pool self.active = False self.detected = False self.screen_marker_state = 0 self.screen_marker_max = 70 # maximum bound for state self.active_site = 0 self.sites = [] self.display_pos = None self.on_position = False self.candidate_ellipses = [] self.pos = None self.show_edges = c_bool(0) self.dist_threshold = c_int(5) self.area_threshold = c_int(20) self.world_size = None self._window = None self.window_should_close = False self.window_should_open = False self.fullscreen = c_bool(1) self.monitor_idx = c_int(0) monitor_handles = glfwGetMonitors() self.monitor_names = [glfwGetMonitorName(m) for m in monitor_handles] monitor_enum = atb.enum( "Monitor", dict(((key, val) for val, key in enumerate(self.monitor_names)))) #primary_monitor = glfwGetPrimaryMonitor() self.frame = None self.timebase = 0 atb_label = "calibrate on screen" # Creating an ATB Bar is required. Show at least some info about the Ref_Detector self._bar = atb.Bar(name=self.__class__.__name__, label=atb_label, help="ref detection parameters", color=(50, 50, 50), alpha=100, text='light', position=atb_pos, refresh=.3, size=(300, 90)) self._bar.add_var("monitor", self.monitor_idx, vtype=monitor_enum) self._bar.add_var("fullscreen", self.fullscreen) self._bar.add_button(" start calibrating ", self.start, key='c') self._bar.add_var("show edges", self.show_edges, group="Detector Variables") self._bar.add_var("area threshold", self.area_threshold, group="Detector Variables") self._bar.add_var("eccetricity threshold", self.dist_threshold, group="Detector Variables")
def __init__(self,data): # call the plugin basic initializations Plugin.__init__(self,data) # set the name of your plugin self.setName("iteration_all_value_quantilebox", "For each Test, plot the sequence of iterations (for any run) as a set \ of quantile boxes. So we have one graphic for each Test.")
def __init__(self,data): # call the plugin basic initializations Plugin.__init__(self,data) # set the name of your plugin self.setName("iteration_all_value_median_logarithmic", "Convergence graph over iterations : plot median error of each run for \ a given iteration, using logarithmic scale.")
def __init__(self,data): # call the plugin basic initializations Plugin.__init__(self,data) # set the name of your plugin self.setName("end_optimum_value_successrate", "Plot the graph of success rates, considering a Test as a success when \ the given precision of the problem is reached.")
def __init__(self, plugin_name, config=None, object_group=None): Thread.__init__(self, name=plugin_name) Plugin.__init__(self, config=config, object_group=object_group, plugin_name=plugin_name) self._run_lock = Lock() self._running = False self.logger = logging.getLogger('allspark.' + plugin_name) self.daemon = True # thread dies with program
def __init__(self, session_str, fps, img_shape, shared_record, eye_tx): Plugin.__init__(self) self.session_str = session_str self.base_path = os.path.join(os.path.abspath(__file__).rsplit('pupil_src', 1)[0], "recordings") self.shared_record = shared_record self.frame_count = 0 self.timestamps = [] self.eye_tx = eye_tx self.start_time = time() # set up base folder called "recordings" try: os.mkdir(self.base_path) except: print "recordings folder already exists, using existing." session = os.path.join(self.base_path, self.session_str) try: os.mkdir(session) except: print "recordings session folder already exists, using existing." # set up self incrementing folder within session folder counter = 0 while True: self.path = os.path.join(self.base_path, session, "%03d/" % counter) try: os.mkdir(self.path) break except: print "We dont want to overwrite data, incrementing counter & trying to make new data folder" counter += 1 self.meta_info_path = os.path.join(self.path, "info.csv") with open(self.meta_info_path, 'w') as f: f.write("Pupil Recording Name:\t"+self.session_str+ "\n") f.write("Start Date: \t"+ strftime("%d.%m.%Y", localtime(self.start_time))+ "\n") f.write("Start Time: \t"+ strftime("%H:%M:%S", localtime(self.start_time))+ "\n") video_path = os.path.join(self.path, "world.avi") self.writer = cv2.VideoWriter(video_path, cv2.cv.CV_FOURCC(*'DIVX'), fps, (img_shape[1], img_shape[0])) self.height = img_shape[0] self.width = img_shape[1] # positions path to eye process self.shared_record.value = True self.eye_tx.send(self.path) atb_pos = (10, 540) self._bar = atb.Bar(name = self.__class__.__name__, label='REC: '+session_str, help="capture recording control", color=(220, 0, 0), alpha=150, text='light', position=atb_pos,refresh=.3, size=(300, 80)) self._bar.rec_name = create_string_buffer(512) self._bar.add_var("rec time",self._bar.rec_name, getter=lambda: create_string_buffer(self.get_rec_time_str(),512), readonly=True) self._bar.add_button("stop", self.stop_and_destruct, key="s", help="stop recording") self._bar.define("contained=true")
def __init__(self,data): # call the plugin basic initializations Plugin.__init__(self,data) # set the name of your plugin self.setName("end_optimum_solution_histogram2D","The positions distribution of optimums, in a 2D space. Use PCA if dimensions > 2..") # eigen vectors weight for the tests self.__eigenv = []
def __init__(self, g_pool): """ Constructor. """ Plugin.__init__(self, g_pool) # TODO check if this blocks too long for long recordings g_pool.odometry_bisector = self.init_bisector(g_pool.rec_dir) logger.info("Loaded odometry data") self.extrinsics = self.load_extrinsics(g_pool.rec_dir)
def __init__(self,data): # call the plugin basic initializations Plugin.__init__(self,data) # set the name of your plugin self.setName("iteration_optimum_value_quantilebox", "For each Test, plot the sequence of iterations (for any run) as a set \ of quantile boxes, instead of showing box for any point of the iteration,\ we only select the optimum for each run.")
def __init__(self,data): # call the plugin basic initializations Plugin.__init__(self,data) # set the name of your plugin self.setName("end_optimum_solution_points","Plot optima and the optimum in their neighborhood plan, PCA used if dimension > 2") # eigen vectors weight for the tests self.__eigenv = []
def __init__(self,data): # call the plugin basic initializations Plugin.__init__(self,data) # set the name of your plugin self.setName("end_optimum_solution_distribution_2D_kernelestimation", "Gaussian kernel estimation of end optimums distribution in the solution space.") # eigen vectors weight for the tests self.__eigenv = []
def __init__(self, teh_bot): Plugin.__init__(self, teh_bot) self.command_dictionary_only_priv_msg_to_bot = { "help": self.help, } self.command_info_only_priv_msg_to_bot = { "help": [ " %shelp" % self.command_prefix, "Shows information about the commands that the bot understands", ], }
def __init__(self,data): # call the plugin basic initializations Plugin.__init__(self,data) # set the name of your plugin self.setName("end_optimum_value_bestworst", "Plot the graph of optimas' values, to finally have one Point for each \ Test, we present 3 selections :\ 1- best optimum\ 2- worst optimum\ 3- median optimum value")
def __init__(self, parent): Plugin.__init__(self) self._parent = parent self._neighborhood = None self._title = _('My Turtle Art session') self._bundle_id = "org.laptop.TurtleArt" # This could be hashed from the file path (if resuming) self._activity_id = "1234567" self._nick = "" self._setup_has_been_called = False
def __init__(self,g_pool, session_str, fps, img_shape, record_eye, eye_tx): Plugin.__init__(self) self.g_pool = g_pool self.session_str = session_str self.record_eye = record_eye self.frame_count = 0 self.timestamps = [] self.gaze_list = [] self.eye_tx = eye_tx self.start_time = time() session = os.path.join(self.g_pool.rec_dir, self.session_str) try: os.mkdir(session) logger.debug("Created new recordings session dir %s"%session) except: logger.debug("Recordings session dir %s already exists, using it." %session) # set up self incrementing folder within session folder counter = 0 while True: self.rec_path = os.path.join(session, "%03d/" % counter) try: os.mkdir(self.rec_path) logger.debug("Created new recording dir %s"%self.rec_path) break except: logger.debug("We dont want to overwrite data, incrementing counter & trying to make new data folder") counter += 1 self.meta_info_path = os.path.join(self.rec_path, "info.csv") with open(self.meta_info_path, 'w') as f: f.write("Recording Name\t"+self.session_str+ "\n") f.write("Start Date\t"+ strftime("%d.%m.%Y", localtime(self.start_time))+ "\n") f.write("Start Time\t"+ strftime("%H:%M:%S", localtime(self.start_time))+ "\n") video_path = os.path.join(self.rec_path, "world.avi") self.writer = cv2.VideoWriter(video_path, cv2.cv.CV_FOURCC(*'DIVX'), fps, (img_shape[1], img_shape[0])) self.height = img_shape[0] self.width = img_shape[1] # positions path to eye process if self.record_eye: self.eye_tx.send(self.rec_path) atb_pos = (10, 540) self._bar = atb.Bar(name = self.__class__.__name__, label='REC: '+session_str, help="capture recording control", color=(220, 0, 0), alpha=150, text='light', position=atb_pos,refresh=.3, size=(300, 80)) self._bar.add_var("rec time",create_string_buffer(512), getter=lambda: create_string_buffer(self.get_rec_time_str(),512), readonly=True) self._bar.add_button("stop",self.on_stop, key="s", help="stop recording") self._bar.define("contained=true")
def __init__(self,g_pool,img_shape, atb_pos=(500,300)): Plugin.__init__(self) height,width = img_shape[:2] if g_pool.app == 'capture': cal_pt_path = os.path.join(g_pool.user_dir,"cal_pt_cloud.npy") else: # cal_pt_path = os.path.join(g_pool.rec_dir,"cal_pt_cloud.npy") logger.error('Plugin does only work in capture so far.') self.close() return try: cal_pt_cloud = np.load(cal_pt_path) except: logger.warning("Please calibrate first") self.close() return map_fn,inlier_map = get_map_from_cloud(cal_pt_cloud,(width, height),return_inlier_map=True) cal_pt_cloud[:,0:2] = np.array(map_fn(cal_pt_cloud[:,0:2].transpose())).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 = c_float(cal_pt_cloud[inlier_map].shape[0]/float(cal_pt_cloud.shape[0])) self.inlier_count = c_int(cal_pt_cloud[inlier_map].shape[0]) # hull = cv2.approxPolyDP(self.calib_bounds, 0.001,closed=True) full_screen_area = 2.* 2. logger.debug("calibration bounds %s"%self.calib_bounds) self.calib_area_ratio = c_float(cv2.contourArea(self.calib_bounds)/full_screen_area) help_str = "yellow: indicates calibration error, red:discarded outliners, outline shows the calibrated area." self._bar = atb.Bar(name = self.__class__.__name__, label='calibration results', help=help_str, color=(50, 50, 50), alpha=100, text='light', position=atb_pos,refresh=.3, size=(300, 140)) self._bar.add_var("number of used samples", self.inlier_count, readonly=True) self._bar.add_var("fraction of used data points", self.inlier_ratio, readonly=True,precision=2) self._bar.add_var("fraction of calibrated screen area", self.calib_area_ratio, readonly=True,precision=2) self._bar.add_button("close", self.close, key="x", help="close calibration results visualization")
def __init__(self, teh_bot): Plugin.__init__(self, teh_bot) self.last_urls = self.restore_object_from_file("last_urls") if not self.last_urls: self.last_urls = deque(["", "", "", "", "", "", "", ""]) self.last_messages = self.restore_object_from_file("last_messages") if not self.last_messages: self.last_messages = deque(["", "", "", "", "", "", "", ""]) self.command_dictionary_only_priv_msg_to_bot = {"messages": self.messages, "urls": self.urls} self.command_info_only_priv_msg_to_bot = { "messages": [" %smessages" % self.command_prefix, "Shows the last messages the bot have seen"], "urls": [" %surls" % self.command_prefix, "Shows the last urls the bot have seen"], }
def __init__(self, files, io): try: Plugin.__init__(self, files, io) self.metaconfig = files[2] self.initTouches() self.initRedirection() self.initConsoleMode() except TrchError: # There was an error parsing the plug-in XML raise except IndexError: # We didn't get the right number of files raise self.procs = []
def __init__(self, teh_bot): Plugin.__init__(self, teh_bot) self.command_dictionary = { "stat": self.stat, } self.command_info = { "stat": [ " %sstat USER" % self.command_prefix, " %sstat" % self.command_prefix, "Shows stats about the user", ], } self.user_data = self.restore_object_from_file("user_data") if not self.user_data: self.user_data = {}
def __init__(self, g_pool, atb_pos=(0,0)): Plugin.__init__(self) self.g_pool = g_pool self.active = False self.detected = False self.screen_marker_state = 0 self.screen_marker_max = 70 # maximum bound for state self.active_site = 0 self.sites = [] self.display_pos = None self.on_position = False self.candidate_ellipses = [] self.pos = None self.show_edges = c_bool(0) self.dist_threshold = c_int(5) self.area_threshold = c_int(20) self.world_size = None self._window = None self.window_should_close = False self.window_should_open = False self.fullscreen = c_bool(1) self.monitor_idx = c_int(0) monitor_handles = glfwGetMonitors() self.monitor_names = [glfwGetMonitorName(m) for m in monitor_handles] monitor_enum = atb.enum("Monitor",dict(((key,val) for val,key in enumerate(self.monitor_names)))) #primary_monitor = glfwGetPrimaryMonitor() atb_label = "calibrate on screen" # Creating an ATB Bar is required. Show at least some info about the Ref_Detector self._bar = atb.Bar(name = self.__class__.__name__, label=atb_label, help="ref detection parameters", color=(50, 50, 50), alpha=100, text='light', position=atb_pos,refresh=.3, size=(300, 100)) self._bar.add_var("monitor",self.monitor_idx, vtype=monitor_enum) self._bar.add_var("fullscreen", self.fullscreen) self._bar.add_button(" start calibrating ", self.start, key='c') self._bar.add_separator("Sep1") self._bar.add_var("show edges",self.show_edges) self._bar.add_var("area threshold", self.area_threshold) self._bar.add_var("eccetricity threshold", self.dist_threshold)
def __init__(self, teh_bot): Plugin.__init__(self, teh_bot) # Command pattern changed so that both the bot and konata recognise it as a command self.command_pattern = "^:(.+)!.+ PRIVMSG (.+) :!*(.+)$" random.seed self.command_dictionary = { "jankenpon": self.jankenpon, "rockpaperscissors": self.jankenpon, "rockpaperscissorslizardspock": self.jankenpon, } self.jankenpon = { "Rock": ["Lizard", "Spock"], "Paper": ["Rock", "Spock"], "Scissors": ["Paper", "Lizard"], "Spock": ["Rock", "Scissors"], "Lizard": ["Paper", "Spock"], }
def __init__(self, bot, channel, public_url="api.bithumb.com", currency=["BTC", "ETH", "DASH", "LTC", "ETC", "XRP"], interval=60): Plugin.__init__(self, bot, channel) self.public_url = public_url self.private_url = None self.currency = currency self.histogram = {} self.delta = {} self.INTERVAL = interval for C in self.currency: self.histogram[C] = {} self.delta[C] = []
def __init__(self, g_pool, atb_pos=(10,400)): Plugin.__init__(self) self.context = zmq.Context() self.socket = self.context.socket(zmq.PUB) self.address = create_string_buffer("tcp://127.0.0.1:5000",512) self.set_server(self.address) help_str = "Pupil Message server: Using ZMQ and the *Publish-Subscribe* scheme" self._bar = atb.Bar(name = self.__class__.__name__, label='Server', help=help_str, color=(50, 50, 50), alpha=100, text='light', position=atb_pos,refresh=.3, size=(300,40)) self._bar.define("valueswidth=170") self._bar.add_var("server address",self.address, getter=lambda:self.address, setter=self.set_server) self._bar.add_button("close", self.close) self.exclude_list = ['ellipse','pos_in_roi','major','minor','axes','angle','center']
def __init__(self, g_pool, fullscreen=False, monitor_idx=0): """ Constructor. """ Plugin.__init__(self, g_pool) self.collect_new = False self.calculated = False self.obj_grid = _gen_pattern_grid((4, 11)) self.img_points = [] self.img_points_left = [] self.img_points_right = [] self.obj_points = [] self.count = 10 self.display_grid = _make_grid() self._window = None # initialize empty menu self.menu = None # TODO merge these self.buttons = {"start_stop_button": None} self.button = None self.clicks_to_close = 5 self.window_should_close = False self.monitor_idx = monitor_idx self.fullscreen = fullscreen self.dist_mode = "Fisheye" self.show_undistortion = False self.glfont = fontstash.Context() self.glfont.add_font("opensans", get_opensans_font_path()) self.glfont.set_size(32) self.glfont.set_color_float((0.2, 0.5, 0.9, 1.0)) self.glfont.set_align_string(v_align="center") self.verbose = False self.odometry_queue = None self.video_queue = mp.Queue() self.pipeline = None self.t265_window = None self.t265_window_should_close = False self.last_video_frame = None
def __init__(self, g_pool, atb_pos=(10,400),on_char_fn = None): Plugin.__init__(self) self.g_pool = g_pool self.on_char_fn = on_char_fn self.order = .9 #excecute late in the plugin list. self.context = zmq.Context() self.socket = self.context.socket(zmq.REP) self.address = create_string_buffer('',512) self.set_server(create_string_buffer("tcp://*:50020",512)) help_str = "Pupil Remote using REQ RREP schema. " self._bar = atb.Bar(name = self.__class__.__name__, label='Remote', help=help_str, color=(50, 50, 50), alpha=100, text='light', position=atb_pos,refresh=.3, size=(300,40)) self._bar.define("valueswidth=170") self._bar.add_var("server address",self.address, getter=lambda:self.address, setter=self.set_server) self._bar.add_button("close", self.close) self.exclude_list = ['ellipse','pos_in_roi','major','minor','axes','angle','center']
def __init__(self, global_calibrate,shared_pos,screen_marker_pos,screen_marker_state,atb_pos=(0,0)): Plugin.__init__(self) self.first_img = None self.point = None self.count = 0 self.detected = False self.active = False self.global_calibrate = global_calibrate self.global_calibrate.value = False self.shared_pos = shared_pos self.pos = 0,0 # 0,0 is used to indicate no point detected self.var1 = c_int(0) self.r = 40.0 # radius of circle displayed atb_label = "calibrate using natural features" self._bar = atb.Bar(name = self.__class__.__name__, label=atb_label, help="ref detection parameters", color=(50, 50, 50), alpha=100, text='light', position=atb_pos,refresh=.3, size=(300, 100)) self._bar.add_button("Start", self.start, key='c') self._bar.add_button("Stop", self.stop)
def __init__(self, teh_bot): Plugin.__init__(self, teh_bot) self.last_urls = self.restore_object_from_file("last_urls") if not self.last_urls: self.last_urls = deque(["", "", "", "", "", "", "", ""]) self.last_messages = self.restore_object_from_file("last_messages") if not self.last_messages: self.last_messages = deque(["", "", "", "", "", "", "", ""]) self.command_dictionary_only_priv_msg_to_bot = { "messages": self.messages, "urls": self.urls, } self.command_info_only_priv_msg_to_bot = { "messages": [ " %smessages" % self.command_prefix, "Shows the last messages the bot have seen", ], "urls": [ " %surls" % self.command_prefix, "Shows the last urls the bot have seen", ], }
def __init__(self, address="225.1.1.1", port=5200, interface="0.0.0.0"): Plugin.__init__(self, "broadcast") self.address = address self.port = port self.interface = interface try: # Instantiate a UDP socket self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) # Allow address reuse self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # Set the packets TTL self.sock.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_TTL, 1) # Do not loop messages back to the local sockets self.sock.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_LOOP, 0) # Bind to the port self.sock.bind(('', self.port)) # Set the interface to perform the multicast on self.sock.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_IF, socket.inet_aton(self.interface)) # Apply for messages sent to the specified address self.sock.setsockopt( socket.SOL_IP, socket.IP_ADD_MEMBERSHIP, socket.inet_aton(self.address) + socket.inet_aton(self.interface)) self._initialized = True except socket.error: pass
def __init__(self, g_pool, atb_pos=(0, 0)): Plugin.__init__(self) self.g_pool = g_pool self.first_img = None self.point = None self.count = 0 self.detected = False self.active = False self.pos = None self.r = 40.0 # radius of circle displayed self.ref_list = [] self.pupil_list = [] atb_label = "calibrate using natural features" self._bar = atb.Bar(name=self.__class__.__name__, label=atb_label, help="ref detection parameters", color=(50, 50, 50), alpha=100, text='light', position=atb_pos, refresh=.3, size=(300, 100)) self._bar.add_button("start/stop", self.start_stop, key='c')
def __init__(self, g_pool, img_shape, atb_pos=(500, 300)): Plugin.__init__(self) height, width = img_shape[:2] if g_pool.app == 'capture': cal_pt_path = os.path.join(g_pool.user_dir, "cal_pt_cloud.npy") else: # cal_pt_path = os.path.join(g_pool.rec_dir,"cal_pt_cloud.npy") logger.error('Plugin does only work in capture so far.') self.close() return try: cal_pt_cloud = np.load(cal_pt_path) except: logger.warning("Please calibrate first") self.close() return map_fn, inlier_map = get_map_from_cloud(cal_pt_cloud, (width, height), return_inlier_map=True) cal_pt_cloud[:, 0:2] = np.array( map_fn(cal_pt_cloud[:, 0:2].transpose())).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 = c_float(cal_pt_cloud[inlier_map].shape[0] / float(cal_pt_cloud.shape[0])) self.inlier_count = c_int(cal_pt_cloud[inlier_map].shape[0]) # hull = cv2.approxPolyDP(self.calib_bounds, 0.001,closed=True) full_screen_area = 2. * 2. logger.debug("calibration bounds %s" % self.calib_bounds) self.calib_area_ratio = c_float( cv2.contourArea(self.calib_bounds) / full_screen_area) help_str = "yellow: indicates calibration error, red:discarded outliners, outline shows the calibrated area." self._bar = atb.Bar(name=self.__class__.__name__, label='calibration results', help=help_str, color=(50, 50, 50), alpha=100, text='light', position=atb_pos, refresh=.3, size=(300, 140)) self._bar.add_var("number of used samples", self.inlier_count, readonly=True) self._bar.add_var("fraction of used data points", self.inlier_ratio, readonly=True, precision=2) self._bar.add_var("fraction of calibrated screen area", self.calib_area_ratio, readonly=True, precision=2) self._bar.add_button("close", self.close, key="x", help="close calibration results visualization")
def __init__(self): Plugin.__init__(self) self.libplugin = LibDatabases() self.cdb = pyrax.cloud_databases
def __init__(self): Plugin.__init__(self) self._resource = None self._session = create_requests_retry_session()
def __init__(self, disper, script=None): Plugin.__init__(self, disper) if script: self.set_script(script) self._env = os.environ.copy() self._env['DISPER_VERSION'] = self.disper.version
def __init__(self, g_pool, session_str, fps, img_shape, record_eye, eye_tx, audio=-1): Plugin.__init__(self) self.g_pool = g_pool self.session_str = session_str self.record_eye = record_eye self.frame_count = 0 self.timestamps = [] self.gaze_list = [] self.eye_tx = eye_tx self.start_time = time() session = os.path.join(self.g_pool.rec_dir, self.session_str) try: os.mkdir(session) logger.debug("Created new recordings session dir %s" % session) except: logger.debug( "Recordings session dir %s already exists, using it." % session) # set up self incrementing folder within session folder counter = 0 while True: self.rec_path = os.path.join(session, "%03d/" % counter) try: os.mkdir(self.rec_path) logger.debug("Created new recording dir %s" % self.rec_path) break except: logger.debug( "We dont want to overwrite data, incrementing counter & trying to make new data folder" ) counter += 1 self.meta_info_path = os.path.join(self.rec_path, "info.csv") with open(self.meta_info_path, 'w') as f: f.write("Recording Name\t" + self.session_str + "\n") f.write("Start Date\t" + strftime("%d.%m.%Y", localtime(self.start_time)) + "\n") f.write("Start Time\t" + strftime("%H:%M:%S", localtime(self.start_time)) + "\n") if audio >= 0: audio_src = audio audio_path = os.path.join(self.rec_path, "world.wav") self.audio_writer = Audio_Capture(audio_src, audio_path) else: self.audio_writer = None video_path = os.path.join(self.rec_path, "world.avi") self.writer = cv2.VideoWriter(video_path, cv2.cv.CV_FOURCC(*'DIVX'), fps, (img_shape[1], img_shape[0])) self.height = img_shape[0] self.width = img_shape[1] # positions path to eye process if self.record_eye: self.eye_tx.send(self.rec_path) atb_pos = (10, 540) self._bar = atb.Bar(name=self.__class__.__name__, label='REC: ' + session_str, help="capture recording control", color=(220, 0, 0), alpha=150, text='light', position=atb_pos, refresh=.3, size=(300, 80)) self._bar.add_var( "rec time", create_string_buffer(512), getter=lambda: create_string_buffer(self.get_rec_time_str(), 512), readonly=True) self._bar.add_button("stop", self.on_stop, key="s", help="stop recording") self._bar.define("contained=true")
def __init__(self): Plugin.__init__(self) self.resource = None self.auth_dict = None
def __init__(self): Plugin.__init__(self)
def __init__(self, *args, **kwargs): Plugin.__init__(self, *args, **kwargs) # Patch the Plugin class Plugin.get_help_info = get_help_info
def __init__(self, g_pool, atb_pos=(0,0)): Plugin.__init__(self) self.g_pool = g_pool self.active = False self.detected = False self.screen_marker_state = 0 self.screen_marker_max = 70 # maximum bound for state self.active_site = 0 self.sites = [] self.display_pos = None self.on_position = False self.candidate_ellipses = [] self.pos = None #result calculation variables: self.world_size = None self.fov = c_float(90.) #taken from c930e specsheet, confirmed though mesurement within ~10deg. self.res = c_float(1.) self.outlier_thresh = c_float(5.) self.accuray = c_float(0) self.percision = c_float(0) try: self.pt_cloud = np.load(os.path.join(self.g_pool.user_dir,'accuray_test_pt_cloud.npy')) gaze,ref = self.pt_cloud[:,0:2],self.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) except Exception: self.error_lines = None self.pt_cloud = None self.show_edges = c_bool(0) self.dist_threshold = c_int(5) self.area_threshold = c_int(20) self._window = None self.window_should_close = False self.window_should_open = False self.fullscreen = c_bool(1) self.monitor_idx = c_int(0) monitor_handles = glfwGetMonitors() self.monitor_names = [glfwGetMonitorName(m) for m in monitor_handles] monitor_enum = atb.enum("Monitor",dict(((key,val) for val,key in enumerate(self.monitor_names)))) #primary_monitor = glfwGetPrimaryMonitor() atb_label = "screen marker based accuracy test" # Creating an ATB Bar is required. Show at least some info about the Ref_Detector self._bar = atb.Bar(name = self.__class__.__name__, label=atb_label, help="ref detection parameters", color=(50, 50, 50), alpha=100, text='light', position=atb_pos,refresh=.3, size=(300, 200)) self._bar.add_var("monitor",self.monitor_idx, vtype=monitor_enum) self._bar.add_var("fullscreen", self.fullscreen) self._bar.add_button(" start test ", self.start, key='c') accuray_help ='''Accuracy is calculated as the average angular offset (distance) (in degrees of visual angle) between fixations locations and the corresponding locations of the fixation targets.'''.replace("\n"," ").replace(" ",'') percision_help = '''Precision is calculated as the Root Mean Square (RMS) of the angular distance (in degrees of visual angle) between successive samples during a fixation.'''.replace("\n"," ").replace(" ",'') self._bar.add_var('diagonal FOV',self.fov,help="set the camera FOV here.",group='Error Calculation') self._bar.add_var('diagonal resolution',self.res,readonly= True ,group='Error Calculation') self._bar.add_var('outlier threshold deg',self.outlier_thresh ,group='Error Calculation') self._bar.add_var('angular accuray',self.accuray,readonly=True ,group='Error Calculation',help=accuray_help) self._bar.add_var('angular percision',self.percision,readonly=True ,group='Error Calculation',help=percision_help) self._bar.add_button('calculate result',self.calc_result ,group='Error Calculation') self._bar.add_var("show edges",self.show_edges, group="Detector Variables") self._bar.add_var("area threshold", self.area_threshold ,group="Detector Variables") self._bar.add_var("eccetricity threshold", self.dist_threshold, group="Detector Variables" )
def __init__(self): Plugin.__init__(self) self.libplugin = LibDNS()
def __init__(self, bot): Plugin.__init__(self, bot) self.event_type = 'team_join'