Commit a9dfdca2ebe6652adcc4dba3d6cb43bf05f19609

Authored by Scott Klum
2 parents 5cd55024 d96da824

Merge branch 'master' of https://github.com/biometrics/openbr

.travis.yml
... ... @@ -2,7 +2,7 @@ language: cpp
2 2 compiler: gcc
3 3 before_install:
4 4 - sudo apt-get update -qq
5   - - sudo apt-get install -qq cmake libqt4-dev libopencv-dev
  5 + - sudo apt-get install -qq cmake qt5-default libqt5svg5-dev
6 6  
7 7 before_script:
8 8 - mkdir build
... ...
CMakeLists.txt
... ... @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 2.8.9)
3 3  
4 4 # Global settings
5 5 set(BR_SHARE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/share/openbr")
  6 +set(BR_SCRIPTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/scripts")
6 7 set(CMAKE_AUTOMOC ON)
7 8 set(CPACK_PACKAGE_NAME "OpenBR")
8 9 set(CPACK_PACKAGE_VENDOR "OpenBiometrics")
... ... @@ -137,6 +138,9 @@ endif()
137 138 install(FILES CHANGELOG.md LICENSE.txt README.md DESTINATION .)
138 139 install(DIRECTORY share DESTINATION .)
139 140 install(DIRECTORY ${BR_THIRDPARTY_SHARE} DESTINATION share)
  141 +# install C API Python wrapper
  142 +execute_process(COMMAND python -c "import site, sys; sys.stdout.write(site.getsitepackages()[-1])" OUTPUT_VARIABLE PYTHON_SITE_DIR)
  143 +install(DIRECTORY ${BR_SCRIPTS_DIR}/brpy DESTINATION ${PYTHON_SITE_DIR})
140 144  
141 145 # Package
142 146 set(CPACK_PACKAGE_EXECUTABLES "OpenBR" "OpenBR")
... ...
README.md
... ... @@ -12,6 +12,6 @@ To optionally check out a particular [tagged release](https://github.com/biometr
12 12  
13 13 **[Build Instructions](http://openbiometrics.org/doxygen/latest/installation.html)**
14 14  
15   -[![Build Status](https://travis-ci.org/biometrics/openbr.png)](https://travis-ci.org/biometrics/openbr)
16 15  
17 16 [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/biometrics/openbr/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
  17 +
... ...
openbr/openbr.cpp
... ... @@ -53,6 +53,12 @@ void br_compare(const char *target_gallery, const char *query_gallery, const cha
53 53 Compare(File(target_gallery), File(query_gallery), File(output));
54 54 }
55 55  
  56 +void br_compare_n(int num_targets, const char *target_galleries[], const char *query_gallery, const char *output)
  57 +{
  58 + if (num_targets > 1) Compare(QtUtils::toStringList(num_targets, target_galleries).join(";")+"(separator=;)", File(query_gallery), File(output));
  59 + else Compare(File(target_galleries[0]), File(query_gallery), File(output));
  60 +}
  61 +
56 62 void br_pairwise_compare(const char *target_gallery, const char *query_gallery, const char *output)
57 63 {
58 64 PairwiseCompare(File(target_gallery), File(query_gallery), File(output));
... ... @@ -447,7 +453,7 @@ br_gallery br_make_gallery(const char *gallery)
447 453 br_template_list br_load_from_gallery(br_gallery gallery)
448 454 {
449 455 Gallery *gal = reinterpret_cast<Gallery*>(gallery);
450   - TemplateList *tl = static_cast<TemplateList*>(malloc(sizeof(TemplateList)));
  456 + TemplateList *tl = new TemplateList();
451 457 *tl = gal->read();
452 458 return (br_template_list)tl;
453 459 }
... ...
openbr/openbr.h
... ... @@ -102,6 +102,12 @@ BR_EXPORT void br_combine_masks(int num_input_masks, const char *input_masks[],
102 102 */
103 103 BR_EXPORT void br_compare(const char *target_gallery, const char *query_gallery, const char *output = "");
104 104  
  105 +/*!
  106 + * \brief Convenience function for comparing to multiple targets.
  107 + * \see br_compare
  108 + */
  109 +BR_EXPORT void br_compare_n(int num_targets, const char *target_galleries[], const char *query_gallery, const char *output);
  110 +
105 111 BR_EXPORT void br_pairwise_compare(const char *target_gallery, const char *query_gallery, const char *output = "");
106 112  
107 113 /*!
... ...
scripts/brpy/__init__.py 0 → 100644
  1 +from ctypes import *
  2 +import os
  3 +
  4 +def _string_args(n):
  5 + s = []
  6 + for i in range(n):
  7 + s.append(c_char_p)
  8 + return s
  9 +
  10 +def _var_string_args(n):
  11 + s = [c_int, POINTER(c_char_p)]
  12 + s.extend(_string_args(n))
  13 + return s
  14 +
  15 +def init_brpy(br_loc='/usr/local/lib'):
  16 + """Takes the ctypes lib object for br and initializes all function inputs and outputs"""
  17 + br_loc += '/libopenbr.%s'
  18 + if os.path.exists(br_loc % 'dylib'):
  19 + br = cdll.LoadLibrary(br_loc % 'dylib')
  20 + elif os.path.exists(br_loc % 'so'):
  21 + br = cdll.LoadLibrary(br_loc % 'so')
  22 + else:
  23 + raise ValueError('Neither .so nor .dylib libopenbr found in %s' % br_loc)
  24 +
  25 + plot_args = _var_string_args(1) + [c_bool]
  26 + br.br_about.restype = c_char_p
  27 + br.br_cat.argtypes = _var_string_args(1)
  28 + br.br_cluster.argtypes = [c_int, POINTER(c_char_p), c_float, c_char_p]
  29 + br.br_combine_masks.argtypes = _var_string_args(2)
  30 + br.br_compare.argtypes = _string_args(3)
  31 + br.br_compare_n.argtypes = [c_int, POINTER(c_char_p)] + _string_args(2)
  32 + br.br_pairwise_compare.argtypes = _string_args(3)
  33 + br.br_convert.argtypes = _string_args(3)
  34 + br.br_enroll.argtypes = _string_args(2)
  35 + br.br_enroll_n.argtypes = _var_string_args(1)
  36 + br.br_eval.argtypes = _string_args(3)
  37 + br.br_eval.restype = c_float
  38 + br.br_eval_classification.argtypes = _string_args(4)
  39 + br.br_eval_clustering.argtypes = _string_args(2)
  40 + br.br_eval_detection.argtypes = _string_args(3)
  41 + br.br_eval_detection.restype = c_float
  42 + br.br_eval_landmarking.argtypes = _string_args(3) + [c_int, c_int]
  43 + br.br_eval_landmarking.restype = c_float
  44 + br.br_eval_regression.argtypes = _string_args(4)
  45 + br.br_fuse.argtypes = _var_string_args(3)
  46 + br.br_initialize.argtypes = _var_string_args(1)
  47 + br.br_is_classifier.argtypes = [c_char_p]
  48 + br.br_is_classifier.restype = c_bool
  49 + br.br_make_mask.argtypes = _string_args(3)
  50 + br.br_make_pairwise_mask.argtypes = _string_args(3)
  51 + br.br_most_recent_message.restype = c_char_p
  52 + br.br_objects.argtypes = _string_args(2) + [c_bool]
  53 + br.br_objects.restype = c_char_p
  54 + br.br_plot.argtypes = plot_args
  55 + br.br_plot.restype = c_bool
  56 + br.br_plot_detection.argtypes = plot_args
  57 + br.br_plot_detection.restype = c_bool
  58 + br.br_plot_landmarking.argtypes = plot_args
  59 + br.br_plot_landmarking.restype = c_bool
  60 + br.br_plot_metadata.argtypes = plot_args
  61 + br.br_plot_metadata.restype = c_bool
  62 + br.br_progress.restype = c_float
  63 + br.br_read_pipe.argtypes = [c_char_p, POINTER(c_int), POINTER(POINTER(c_char_p))]
  64 + br.br_scratch_path.restype = c_char_p
  65 + br.br_sdk_path.restype = c_char_p
  66 + br.br_get_header.argtypes = [c_char_p, POINTER(c_char_p), POINTER(c_char_p)]
  67 + br.br_set_header.argtypes = _string_args(3)
  68 + br.br_set_property.argtypes = _string_args(2)
  69 + br.br_time_remaining.restype = c_int
  70 + br.br_train.argtypes = _string_args(2)
  71 + br.br_train_n.argtypes = _var_string_args(1)
  72 + br.br_version.restype = c_char_p
  73 + br.br_slave_process.argtypes = [c_char_p]
  74 + br.br_load_img.argtypes = [c_char_p, c_int]
  75 + br.br_load_img.restype = c_void_p
  76 + br.br_unload_img.argtypes = [c_void_p]
  77 + br.br_unload_img.restype = POINTER(c_ubyte)
  78 + br.br_template_list_from_buffer.argtypes = [c_char_p, c_int]
  79 + br.br_template_list_from_buffer.restype = c_void_p
  80 + br.br_free_template.argtypes = [c_void_p]
  81 + br.br_free_template_list.argtypes = [c_void_p]
  82 + br.br_free_output.argtypes = [c_void_p]
  83 + br.br_img_rows.argtypes = [c_void_p]
  84 + br.br_img_rows.restype = c_int
  85 + br.br_img_cols.argtypes = [c_void_p]
  86 + br.br_img_cols.restype = c_int
  87 + br.br_img_channels.argtypes = [c_void_p]
  88 + br.br_img_channels.restype = c_int
  89 + br.br_img_is_empty.argtypes = [c_void_p]
  90 + br.br_img_is_empty.restype = c_bool
  91 + br.br_get_filename.argtypes = [c_void_p]
  92 + br.br_get_filename.restype = c_char_p
  93 + br.br_set_filename.argtypes = [c_void_p, c_char_p]
  94 + br.br_get_metadata_string.argtypes = [c_void_p, c_char_p]
  95 + br.br_get_metadata_string.restype = c_char_p
  96 + br.br_enroll_template.argtypes = [c_void_p]
  97 + br.br_enroll_template.restype = c_void_p
  98 + br.br_enroll_template_list.argtypes = [c_void_p]
  99 + br.br_enroll_template_list.restype = c_void_p
  100 + br.br_compare_template_lists.argtypes = [c_void_p, c_void_p]
  101 + br.br_compare_template_lists.restype = c_void_p
  102 + br.br_get_matrix_output_at.argtypes = [c_void_p, c_int, c_int]
  103 + br.br_get_matrix_output_at.restype = c_float
  104 + br.br_get_template.argtypes = [c_void_p, c_int]
  105 + br.br_get_template.restype = c_void_p
  106 + br.br_num_templates.argtypes = [c_void_p]
  107 + br.br_num_templates.restype = c_int
  108 + br.br_make_gallery.argtypes = [c_char_p]
  109 + br.br_make_gallery.restype = c_void_p
  110 + br.br_load_from_gallery.argtypes = [c_void_p]
  111 + br.br_load_from_gallery.restype = c_void_p
  112 + br.br_add_to_gallery.argtypes = [c_void_p, c_void_p]
  113 + br.br_close_gallery.argtypes = [c_void_p]
  114 +
  115 + return br
... ...