Commit 511dae911a29fd3eb3e699d330de5720fba36de0
1 parent
eaeb3531
Fix image loading from char buffer
Showing
2 changed files
with
4 additions
and
5 deletions
openbr/openbr.cpp
| @@ -299,11 +299,10 @@ void br_slave_process(const char * baseName) | @@ -299,11 +299,10 @@ void br_slave_process(const char * baseName) | ||
| 299 | delete worker; | 299 | delete worker; |
| 300 | } | 300 | } |
| 301 | 301 | ||
| 302 | -br_template br_load_img(const char *data) | 302 | +br_template br_load_img(const char *data, int len) |
| 303 | { | 303 | { |
| 304 | - int size = strlen(data); | ||
| 305 | - std::vector<char> buf(data, data+size); | ||
| 306 | - cv::Mat img = cv::imdecode(cv::Mat(buf), CV_LOAD_IMAGE_ANYDEPTH); | 304 | + std::vector<char> buf(data, data+len); |
| 305 | + cv::Mat img = cv::imdecode(cv::Mat(buf), CV_LOAD_IMAGE_COLOR); | ||
| 307 | Template *tmpl = new Template(img); | 306 | Template *tmpl = new Template(img); |
| 308 | return (br_template)tmpl; | 307 | return (br_template)tmpl; |
| 309 | } | 308 | } |
openbr/openbr.h
| @@ -425,7 +425,7 @@ typedef void* br_template; | @@ -425,7 +425,7 @@ typedef void* br_template; | ||
| 425 | * \brief Load an image from a string buffer. | 425 | * \brief Load an image from a string buffer. |
| 426 | * Easy way to pass an image in memory from another programming language to openbr. | 426 | * Easy way to pass an image in memory from another programming language to openbr. |
| 427 | */ | 427 | */ |
| 428 | -BR_EXPORT br_template br_load_img(const char *data); | 428 | +BR_EXPORT br_template br_load_img(const char *data, int len); |
| 429 | BR_EXPORT unsigned char* br_unload_img(br_template tmpl); | 429 | BR_EXPORT unsigned char* br_unload_img(br_template tmpl); |
| 430 | BR_EXPORT int br_img_rows(br_template tmpl); | 430 | BR_EXPORT int br_img_rows(br_template tmpl); |
| 431 | BR_EXPORT int br_img_cols(br_template tmpl); | 431 | BR_EXPORT int br_img_cols(br_template tmpl); |