diff --git a/src/demo.c b/src/demo.c index 2fd54cf5..7066e6f5 100644 --- a/src/demo.c +++ b/src/demo.c @@ -208,13 +208,13 @@ void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int while(1){ ++count; { - if(pthread_create(&fetch_thread, 0, fetch_in_thread, 0)) error("Thread creation failed"); - if(pthread_create(&detect_thread, 0, detect_in_thread, 0)) error("Thread creation failed"); - - float nms = .45; // 0.4F + const float nms = .45; // 0.4F int local_nboxes = nboxes; detection *local_dets = dets; + if(pthread_create(&fetch_thread, 0, fetch_in_thread, 0)) error("Thread creation failed"); + if(pthread_create(&detect_thread, 0, detect_in_thread, 0)) error("Thread creation failed"); + //if (nms) do_nms_obj(local_dets, local_nboxes, l.classes, nms); // bad results if (nms) { if (l.nms_kind == DEFAULT_NMS) do_nms_sort(local_dets, local_nboxes, l.classes, nms); @@ -237,7 +237,7 @@ void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int int timeout = 3; // 3 seconds int http_post_port = 80; // 443 https, 80 http if (send_http_post_request(http_post_host, http_post_port, filename, - dets, nboxes, classes, names, frame_id, ext_output, timeout)) + local_dets, nboxes, classes, names, frame_id, ext_output, timeout)) { if (time_limit_sec > 0) send_http_post_once = 1; } diff --git a/src/image_opencv.cpp b/src/image_opencv.cpp index 3ce30e42..39b9eb8d 100644 --- a/src/image_opencv.cpp +++ b/src/image_opencv.cpp @@ -763,6 +763,7 @@ extern "C" image get_image_from_stream_resize(cap_cv *cap, int w, int h, int c, if (once) { once = 0; do { + if (src) delete src; src = (cv::Mat*)get_capture_frame_cv(cap); if (!src) return make_empty_image(0, 0, 0); } while (src->cols < 1 || src->rows < 1 || src->channels() < 1); @@ -794,6 +795,7 @@ extern "C" image get_image_from_stream_letterbox(cap_cv *cap, int w, int h, int if (once) { once = 0; do { + if (src) delete src; src = (cv::Mat*)get_capture_frame_cv(cap); if (!src) return make_empty_image(0, 0, 0); } while (src->cols < 1 || src->rows < 1 || src->channels() < 1);