def find_object_by_color(conn, detection_table_long, object_color_table, output_table, object_name, object_color, color_cluster_min_size=0, object_column='OBJECT_NAME', color_column='COLOR_NAME', color_cluster_size_column='COLOR_CLUSTER_PERCENT', id_column='_LABEL_', replace=True): conn.loadactionset('fedSql') #object_ids = object_color_table[object_color_table[color_column] == object_color][id_column].values object_ids = object_color_table[ (object_color_table[color_column] == object_color) & (object_color_table[color_cluster_size_column] > color_cluster_min_size)][id_column].values object_ids = "', '".join(object_ids) object_ids = "('{}')".format(object_ids) conn.loadactionset('fedSql') if replace == True: replace_option = "{options replace=true}" else: replace_option = "{options replace=false}" query = ' create table {} {} as '.format(output_table, replace_option) query += " select * from {} ".format(detection_table_long.name) query += " where {} = \'{}\' and {} in {} ".format(object_column, object_name, id_column, object_ids) res = conn.fedSql.execDirect(query=query) img_tbl = ImageTable.from_table(conn.CASTable(output_table)) return img_tbl
def test_filter_by_filename_3(self): if self.data_dir is None: unittest.TestCase.skipTest(self, "DLPY_DATA_DIR is not set in the environment variables") img_path = self.data_dir+'giraffe_dolphin_small' table = ImageTable.load_files(self.s, path=img_path) filename = ['giraffe_', 'dolphin_'] filtered = filter_by_filename(table, filename, filtered_name=None) filtered = ImageTable.from_table(filtered) self.assertTrue(filtered.label_freq.loc['Giraffe'][1]>0) self.assertTrue(filtered.label_freq.loc['Dolphin'][1]>0)
def setUp(self): swat.reset_option() swat.options.cas.print_messages = False swat.options.interactive_mode = False self.s = swat.CAS(HOST, PORT, USER, PASSWD, protocol=PROTOCOL) if type(self).server_type is None: # Set once per class and have every test use it. No need to change between tests. type(self).server_type = tm.get_cas_host_type(self.s) self.srcLib = tm.get_casout_lib(self.server_type) filename = os.path.join(os.path.dirname(__file__), 'datasources', 'ImageData.sashdat') r = tm.load_data(self.s, filename, self.server_type) self.tablename = r['tableName'] self.assertNotEqual(self.tablename, None) self.table = ImageTable.from_table(r['casTable'])