diff --git a/src/demo.c b/src/demo.c index 3aca9705..53e8bd10 100644 --- a/src/demo.c +++ b/src/demo.c @@ -54,6 +54,7 @@ void draw_detections_cv(IplImage* show_img, int num, float thresh, box *boxes, f void draw_detections_cv_v3(IplImage* show_img, detection *dets, int num, float thresh, char **names, image **alphabet, int classes, int ext_output); void show_image_cv_ipl(IplImage *disp, const char *name); void save_cv_png(IplImage *img, const char *name); +void save_cv_jpg(IplImage *img, const char *name); image get_image_from_stream_resize(CvCapture *cap, int w, int h, int c, IplImage** in_img, int cpp_video_capture, int dont_close); image get_image_from_stream_letterbox(CvCapture *cap, int w, int h, int c, IplImage** in_img, int cpp_video_capture, int dont_close); int get_stream_fps(CvCapture *cap, int cpp_video_capture); @@ -140,6 +141,7 @@ double get_wall_time() void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int cam_index, const char *filename, char **names, int classes, int frame_skip, char *prefix, char *out_filename, int http_stream_port, int json_port, int dont_show, int ext_output) { + in_img = det_img = show_img = NULL; //skip = frame_skip; image **alphabet = load_alphabet(); int delay = frame_skip; @@ -274,9 +276,7 @@ void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int }else{ char buff[256]; sprintf(buff, "%s_%08d.jpg", prefix, count); - save_cv_png(buff, show_img); - //cvSaveImage(buff, show_img, 0); - //save_image(disp, buff); + if(show_img) save_cv_jpg(show_img, buff); } // if you run it with param -http_port 8090 then open URL in your web-browser: http://localhost:8090 @@ -302,6 +302,7 @@ void demo(char *cfgfile, char *weightfile, float thresh, float hier_thresh, int if (flag_exit == 1) break; if(delay == 0){ + printf("\n show_img = det_img; \n"); show_img = det_img; } det_img = in_img; diff --git a/src/image.c b/src/image.c index 06112cb4..a4443cdd 100644 --- a/src/image.c +++ b/src/image.c @@ -508,6 +508,14 @@ void save_cv_png(IplImage *img, const char *name) cvRelease(&img_rgb); } +void save_cv_jpg(IplImage *img, const char *name) +{ + IplImage* img_rgb = cvCreateImage(cvSize(img->width, img->height), 8, 3); + cvCvtColor(img, img_rgb, CV_RGB2BGR); + stbi_write_jpg(name, img_rgb->width, img_rgb->height, 3, (char *)img_rgb->imageData, 80); + cvRelease(&img_rgb); +} + void draw_detections_cv_v3(IplImage* show_img, detection *dets, int num, float thresh, char **names, image **alphabet, int classes, int ext_output) { int i, j; @@ -802,7 +810,7 @@ void draw_train_loss(IplImage* img, int img_size, float avg_loss, float max_img_ int k = cvWaitKey(20); if (k == 's' || current_batch == (max_batches - 1) || current_batch % 100 == 0) { //cvSaveImage("chart.jpg", img, 0); - save_cv_png("chart.png", img); + save_cv_png(img, "chart.png"); cvPutText(img, "- Saved", cvPoint(250, img_size - 10), &font, CV_RGB(255, 0, 0)); } else