Commit d96da8244cb73e4f93bd50d02e37ba4ac1ca910b

Authored by Austin Blanton
1 parent 4486aaf1

Add convenience function for comparing with multiple targets in C API

openbr/openbr.cpp
@@ -53,6 +53,12 @@ void br_compare(const char *target_gallery, const char *query_gallery, const cha @@ -53,6 +53,12 @@ void br_compare(const char *target_gallery, const char *query_gallery, const cha
53 Compare(File(target_gallery), File(query_gallery), File(output)); 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 void br_pairwise_compare(const char *target_gallery, const char *query_gallery, const char *output) 62 void br_pairwise_compare(const char *target_gallery, const char *query_gallery, const char *output)
57 { 63 {
58 PairwiseCompare(File(target_gallery), File(query_gallery), File(output)); 64 PairwiseCompare(File(target_gallery), File(query_gallery), File(output));
@@ -447,7 +453,7 @@ br_gallery br_make_gallery(const char *gallery) @@ -447,7 +453,7 @@ br_gallery br_make_gallery(const char *gallery)
447 br_template_list br_load_from_gallery(br_gallery gallery) 453 br_template_list br_load_from_gallery(br_gallery gallery)
448 { 454 {
449 Gallery *gal = reinterpret_cast<Gallery*>(gallery); 455 Gallery *gal = reinterpret_cast<Gallery*>(gallery);
450 - TemplateList *tl = static_cast<TemplateList*>(malloc(sizeof(TemplateList))); 456 + TemplateList *tl = new TemplateList();
451 *tl = gal->read(); 457 *tl = gal->read();
452 return (br_template_list)tl; 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,6 +102,12 @@ BR_EXPORT void br_combine_masks(int num_input_masks, const char *input_masks[],
102 */ 102 */
103 BR_EXPORT void br_compare(const char *target_gallery, const char *query_gallery, const char *output = ""); 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 BR_EXPORT void br_pairwise_compare(const char *target_gallery, const char *query_gallery, const char *output = ""); 111 BR_EXPORT void br_pairwise_compare(const char *target_gallery, const char *query_gallery, const char *output = "");
106 112
107 /*! 113 /*!