From 511dae911a29fd3eb3e699d330de5720fba36de0 Mon Sep 17 00:00:00 2001 From: Austin Blanton Date: Wed, 6 Nov 2013 13:06:59 -0500 Subject: [PATCH] Fix image loading from char buffer --- openbr/openbr.cpp | 7 +++---- openbr/openbr.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/openbr/openbr.cpp b/openbr/openbr.cpp index c9f5fc1..77cfbb4 100644 --- a/openbr/openbr.cpp +++ b/openbr/openbr.cpp @@ -299,11 +299,10 @@ void br_slave_process(const char * baseName) delete worker; } -br_template br_load_img(const char *data) +br_template br_load_img(const char *data, int len) { - int size = strlen(data); - std::vector buf(data, data+size); - cv::Mat img = cv::imdecode(cv::Mat(buf), CV_LOAD_IMAGE_ANYDEPTH); + std::vector buf(data, data+len); + cv::Mat img = cv::imdecode(cv::Mat(buf), CV_LOAD_IMAGE_COLOR); Template *tmpl = new Template(img); return (br_template)tmpl; } diff --git a/openbr/openbr.h b/openbr/openbr.h index bdbed31..3f41878 100644 --- a/openbr/openbr.h +++ b/openbr/openbr.h @@ -425,7 +425,7 @@ typedef void* br_template; * \brief Load an image from a string buffer. * Easy way to pass an image in memory from another programming language to openbr. */ -BR_EXPORT br_template br_load_img(const char *data); +BR_EXPORT br_template br_load_img(const char *data, int len); BR_EXPORT unsigned char* br_unload_img(br_template tmpl); BR_EXPORT int br_img_rows(br_template tmpl); BR_EXPORT int br_img_cols(br_template tmpl); -- libgit2 0.21.4