mirror of https://github.com/AlexeyAB/darknet.git
Fixed memory leak in ./darknet detector demo ...
This commit is contained in:
parent
2a873f3448
commit
c7e3ba3ed4
10
src/demo.c
10
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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue