diff --git a/scripts/brpy/__init__.py b/scripts/brpy/__init__.py index bd9a37d..4060fbc 100644 --- a/scripts/brpy/__init__.py +++ b/scripts/brpy/__init__.py @@ -12,6 +12,14 @@ def _var_string_args(n): s.extend(_string_args(n)) return s +def _handle_string_func(func): + def call_func(*args): + howlong = func('', 0, *args) + msg = 'x'*(howlong-1) + func(msg, howlong, *args) + return msg + return call_func + def init_brpy(br_loc='/usr/local/lib'): """Takes the ctypes lib object for br and initializes all function inputs and outputs""" br_loc += '/libopenbr.%s' @@ -48,9 +56,14 @@ def init_brpy(br_loc='/usr/local/lib'): br.br_is_classifier.restype = c_bool br.br_make_mask.argtypes = _string_args(3) br.br_make_pairwise_mask.argtypes = _string_args(3) - br.br_most_recent_message.restype = c_char_p - br.br_objects.argtypes = _string_args(2) + [c_bool] - br.br_objects.restype = c_char_p + br.br_most_recent_message.argtypes = [c_char_p, c_int] + br.br_most_recent_message.restype = c_int + func = br.br_most_recent_message.__call__ + br.br_most_recent_message = _handle_string_func(func) + br.br_objects.argtypes = [c_char_p, c_int] + _string_args(2) + [c_bool] + br.br_objects.restype = c_int + func2 = br.br_objects.__call__ + br.br_objects = _handle_string_func(func2) br.br_plot.argtypes = plot_args br.br_plot.restype = c_bool br.br_plot_detection.argtypes = plot_args @@ -61,7 +74,10 @@ def init_brpy(br_loc='/usr/local/lib'): br.br_plot_metadata.restype = c_bool br.br_progress.restype = c_float br.br_read_pipe.argtypes = [c_char_p, POINTER(c_int), POINTER(POINTER(c_char_p))] - br.br_scratch_path.restype = c_char_p + br.br_scratch_path.argtypes = [c_char_p, c_int] + br.br_scratch_path.restype = c_int + func3 = br.br_scratch_path.__call__ + br.br_scratch_path = _handle_string_func(func3) br.br_sdk_path.restype = c_char_p br.br_get_header.argtypes = [c_char_p, POINTER(c_char_p), POINTER(c_char_p)] br.br_set_header.argtypes = _string_args(3) @@ -88,11 +104,15 @@ def init_brpy(br_loc='/usr/local/lib'): br.br_img_channels.restype = c_int br.br_img_is_empty.argtypes = [c_void_p] br.br_img_is_empty.restype = c_bool - br.br_get_filename.argtypes = [c_void_p] - br.br_get_filename.restype = c_char_p + br.br_get_filename.argtypes = [c_char_p, c_int, c_void_p] + br.br_get_filename.restype = c_int + func4 = br.br_get_filename.__call__ + br.br_get_filename = _handle_string_func(func4) br.br_set_filename.argtypes = [c_void_p, c_char_p] - br.br_get_metadata_string.argtypes = [c_void_p, c_char_p] - br.br_get_metadata_string.restype = c_char_p + br.br_get_metadata_string.argtypes = [c_char_p, c_int, c_void_p, c_char_p] + br.br_get_metadata_string.restype = c_int + func5 = br.br_get_metadata_string.__call__ + br.br_get_metadata_string = _handle_string_func(func5) br.br_enroll_template.argtypes = [c_void_p] br.br_enroll_template.restype = c_void_p br.br_enroll_template_list.argtypes = [c_void_p]