def GetObjects(self, confidence_thresh=0.1, height_thresh=0.5, min_pts_num=3): point2grid = self.vldpc.idx_row * self.vldpc.cols + self.vldpc.idx_col # 在map中的索引 ind = range(point2grid.size) # 筛选点云数据 for point, z, i in zip(point2grid, self.vldpc.valid_z, ind): obs_id = self.id_img[point] if obs_id >= 0 and self.obstacles[ obs_id].score >= confidence_thresh: if height_thresh < 0 or z <= self.obstacles[ obs_id].height + height_thresh: self.obstacles[obs_id].cloud.append(i) j = 0 k = -1 for ob in self.obstacles: k += 1 if len(ob.cloud) < min_pts_num: continue self.valid_objects.append(k) self.objects.append(obj.Objects()) self.objects[j].cloud = ob.cloud self.objects[j].score = ob.score self.objects[j].type = self.GetObjectType(ob.meta_type) self.objects[j].type_probs = self.GetObjectTypeProbs( ob.meta_type_probs) j += 1
def backup(): ''' Emby backup. ''' from helper.utils import delete_folder, copytree path = settings('backupPath') folder_name = "Kodi%s.%s" % (xbmc.getInfoLabel('System.BuildVersion')[:2], xbmc.getInfoLabel('System.Date(dd-mm-yy)')) folder_name = dialog("input", heading=_(33089), defaultt=folder_name) if not folder_name: return backup = os.path.join(path, folder_name) if xbmcvfs.exists(backup + '/'): if not dialog("yesno", heading="{emby}", line1=_(33090)): return backup() delete_folder(backup) addon_data = xbmc.translatePath("special://profile/addon_data/plugin.video.emby").decode('utf-8') destination_data = os.path.join(backup, "addon_data", "plugin.video.emby") destination_databases = os.path.join(backup, "Database") if not xbmcvfs.mkdirs(path) or not xbmcvfs.mkdirs(destination_databases): LOG.info("Unable to create all directories") dialog("notification", heading="{emby}", icon="{emby}", message=_(33165), sound=False) return copytree(addon_data, destination_data) databases = objects.Objects().objects db = xbmc.translatePath(databases['emby']).decode('utf-8') xbmcvfs.copy(db, os.path.join(destination_databases, db.rsplit('\\', 1)[1])) LOG.info("copied emby.db") db = xbmc.translatePath(databases['video']).decode('utf-8') filename = db.rsplit('\\', 1)[1] xbmcvfs.copy(db, os.path.join(destination_databases, filename)) LOG.info("copied %s", filename) if settings('enableMusic.bool'): db = xbmc.translatePath(databases['music']).decode('utf-8') filename = db.rsplit('\\', 1)[1] xbmcvfs.copy(db, os.path.join(destination_databases, filename)) LOG.info("copied %s", filename) LOG.info("backup completed") dialog("ok", heading="{emby}", line1="%s %s" % (_(33091), backup))
def grid_init(): """ Initialise the game, upload a map wanted by the player, ask how many players will play (between 1 and 4) Return a grid, a list of players and a boolean to end the game if necessecary """ end = True map_valid = True # list of players players = [] numbers = ['1', '2', '3', '4'] rules.display_rules() map_names_lignes = file_gestion.display_listname('map_names') # the player choose a map while (map_valid): file = input("\nEnter the name of a map : ") try: my_file = file_gestion.file_reader(file) except FileNotFoundError: print("This map doesn't exist, please enter an other map's name") # both take in this case the same value map_valid = end = rules.keep_going() else: map_valid = not (my_file[3]) if (map_valid): print("This map is not valid, please enter another map") map_valid = end = rules.keep_going() number_valid = True number = 0 # then he choose a number of players while (number_valid): number = input("Please enter a number of players between 1 and 4: ") try: number_of_player = int(number) except ValueError: print("You didn't enter a digit-number") end = number_valid = rules.keep_going() else: if (0 < number_of_player and number_of_player <= 4): number_valid = False if (number_valid): print("To many players have been chose") # if end = True the, the map is valid as well as the number of player if (end): grid = Grid(my_file[0], my_file[1], my_file[2]) for i in range(number_of_player): players.append( objects.Objects(my_file[-1][i][0], my_file[-1][i][1], grid, numbers[i])) return (grid, players, end) return ((), (), end)
def grid_init(file, number_of_player): """ Initialise the game, upload a map wanted by the player, ask how many players will play (between 1 and 4) Return a grid, a list of players and a boolean to end the game if necessecary """ players = [] numbers = ['1', '2', '3', '4'] path = "maps/" my_file = file_gestion.file_reader(path + file) grid = Grid(my_file[0], my_file[1], my_file[2]) for i in range(number_of_player): players.append( objects.Objects(my_file[-1][i][0], my_file[-1][i][1], grid, numbers[i])) return (grid, players)
def get_fanart(item_id, path, server_id=None): ''' Get extra fanart for listitems. This is called by skinhelper. Images are stored locally, due to the Kodi caching system. ''' if not item_id and 'plugin.video.emby' in path: item_id = path.split('/')[-2] if not item_id: return LOG.info("[ extra fanart ] %s", item_id) get_server(server_id) objects = objects.Objects() list_li = [] directory = xbmc.translatePath("special://thumbnails/emby/%s/" % item_id).decode('utf-8') if not xbmcvfs.exists(directory): xbmcvfs.mkdirs(directory) item = EMBY['api'].get_item(item_id) obj = objects.map(item, 'Artwork') backdrops = api.API(item, EMBY['auth/server-address']).get_all_artwork(obj) tags = obj['BackdropTags'] for index, backdrop in enumerate(backdrops): tag = tags[index] fanart = os.path.join(directory, "fanart%s.jpg" % tag) li = xbmcgui.ListItem(tag, path=fanart) xbmcvfs.copy(backdrop, fanart) list_li.append((fanart, li, False)) else: LOG.debug("cached backdrop found") dirs, files = xbmcvfs.listdir(directory) for file in files: fanart = os.path.join(directory, file.decode('utf-8')) li = xbmcgui.ListItem(file, path=fanart) list_li.append((fanart, li, False)) xbmcplugin.addDirectoryItems(int(sys.argv[1]), list_li, len(list_li)) xbmcplugin.endOfDirectory(int(sys.argv[1]))
def setUp(self): my_file = file_gestion.file_reader("TheForest") self.grid = grids.Grid(my_file[0], my_file[1], my_file[2]) self.player_object = objects.Objects(my_file[-1][0][0], my_file[-1][0][1], self.grid, 1)