From 2cd37ec73eae3e4d0a554b9ec20c01a8309a089a Mon Sep 17 00:00:00 2001 From: AlexeyAB Date: Tue, 22 Jan 2019 17:31:07 +0300 Subject: [PATCH] Another minor fix --- src/detector.c | 4 ++-- src/http_stream.cpp | 12 ++++++++---- src/http_stream.h | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/detector.c b/src/detector.c index 193df65e..8984a563 100644 --- a/src/detector.c +++ b/src/detector.c @@ -1274,8 +1274,8 @@ void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filenam if (!input) break; strtok(input, "\n"); } - //image im = load_image_resize(input, net.w, net.h, net.c); - //image sized = copy_image(im); + //image im; + //image sized = load_image_resize(input, net.w, net.h, net.c, &im); image im = load_image(input, 0, 0, net.c); image sized = resize_image(im, net.w, net.h); int letterbox = 0; diff --git a/src/http_stream.cpp b/src/http_stream.cpp index 5938d8e6..dbac6f5d 100644 --- a/src/http_stream.cpp +++ b/src/http_stream.cpp @@ -593,7 +593,7 @@ image image_data_augmentation(IplImage* ipl, int w, int h, } -image load_image_resize(char *filename, int w, int h, int c) +image load_image_resize(char *filename, int w, int h, int c, image *im) { image out; cv::Mat img(h, w, CV_8UC3); @@ -607,15 +607,19 @@ image load_image_resize(char *filename, int w, int h, int c) } //throw std::runtime_error("runtime_error"); cv::Mat loaded_image = cv::imread(filename, flag); + cv::cvtColor(loaded_image, loaded_image, cv::COLOR_RGB2BGR); + IplImage tmp1 = loaded_image; + *im = ipl_to_image(&tmp1); + cv::resize(loaded_image, img, cv::Size(w, h), 0, 0, CV_INTER_LINEAR); - cv::cvtColor(img, img, cv::COLOR_RGB2BGR); - IplImage tmp = img; - out = ipl_to_image(&tmp); + IplImage tmp2 = img; + out = ipl_to_image(&tmp2); } catch (...) { fprintf(stderr, "OpenCV can't load image %s channels\n", filename); out = make_image(w, h, c); + *im = make_image(w, h, c); } return out; } diff --git a/src/http_stream.h b/src/http_stream.h index 34091064..d7ec815c 100644 --- a/src/http_stream.h +++ b/src/http_stream.h @@ -26,7 +26,7 @@ image image_data_augmentation(IplImage* ipl, int w, int h, int pleft, int ptop, int swidth, int sheight, int flip, float jitter, float dhue, float dsat, float dexp); -image load_image_resize(char *filename, int w, int h, int c); +image load_image_resize(char *filename, int w, int h, int c, image *im); #endif // OPENCV #ifdef __cplusplus