Commit bd736b99465dfdd94df481ae5a30402cd05bee63
1 parent
64c0a61e
fixed janus edge cases
Showing
2 changed files
with
4 additions
and
2 deletions
openbr/janus.cpp
| @@ -74,6 +74,7 @@ janus_error janus_augment(const janus_image image, const janus_attribute_list at | @@ -74,6 +74,7 @@ janus_error janus_augment(const janus_image image, const janus_attribute_list at | ||
| 74 | 74 | ||
| 75 | janus_error janus_finalize_template(janus_template template_, janus_flat_template flat_template, size_t *bytes) | 75 | janus_error janus_finalize_template(janus_template template_, janus_flat_template flat_template, size_t *bytes) |
| 76 | { | 76 | { |
| 77 | + *bytes = 0; | ||
| 77 | foreach (const cv::Mat &m, *template_) { | 78 | foreach (const cv::Mat &m, *template_) { |
| 78 | assert(m.isContinuous()); | 79 | assert(m.isContinuous()); |
| 79 | const size_t templateBytes = m.rows * m.cols * m.elemSize(); | 80 | const size_t templateBytes = m.rows * m.cols * m.elemSize(); |
| @@ -118,7 +119,8 @@ janus_error janus_verify(const janus_flat_template a, const size_t a_bytes, cons | @@ -118,7 +119,8 @@ janus_error janus_verify(const janus_flat_template a, const size_t a_bytes, cons | ||
| 118 | if (*similarity != *similarity) // True for NaN | 119 | if (*similarity != *similarity) // True for NaN |
| 119 | return JANUS_UNKNOWN_ERROR; | 120 | return JANUS_UNKNOWN_ERROR; |
| 120 | 121 | ||
| 121 | - *similarity /= comparisons; | 122 | + if (comparisons > 0) *similarity /= comparisons; |
| 123 | + else *similarity = std::numeric_limits<double>::lowest(); | ||
| 122 | return JANUS_SUCCESS; | 124 | return JANUS_SUCCESS; |
| 123 | } | 125 | } |
| 124 | 126 |