mirror of
https://github.com/pjreddie/darknet.git
synced 2023-08-10 21:13:14 +03:00
You can specify filename for output video by using -out_filename res.avi
This commit is contained in:
@ -367,6 +367,7 @@ void test_coco(char *cfgfile, char *weightfile, char *filename, float thresh)
|
||||
|
||||
void run_coco(int argc, char **argv)
|
||||
{
|
||||
char *out_filename = find_char_arg(argc, argv, "-out_filename", 0);
|
||||
char *prefix = find_char_arg(argc, argv, "-prefix", 0);
|
||||
float thresh = find_float_arg(argc, argv, "-thresh", .2);
|
||||
int cam_index = find_int_arg(argc, argv, "-c", 0);
|
||||
@ -384,5 +385,5 @@ void run_coco(int argc, char **argv)
|
||||
else if(0==strcmp(argv[2], "train")) train_coco(cfg, weights);
|
||||
else if(0==strcmp(argv[2], "valid")) validate_coco(cfg, weights);
|
||||
else if(0==strcmp(argv[2], "recall")) validate_coco_recall(cfg, weights);
|
||||
else if(0==strcmp(argv[2], "demo")) demo(cfg, weights, thresh, cam_index, filename, coco_classes, 80, frame_skip, prefix);
|
||||
else if(0==strcmp(argv[2], "demo")) demo(cfg, weights, thresh, cam_index, filename, coco_classes, 80, frame_skip, prefix, out_filename);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ double get_wall_time()
|
||||
return (double)time.tv_sec + (double)time.tv_usec * .000001;
|
||||
}
|
||||
|
||||
void demo(char *cfgfile, char *weightfile, float thresh, int cam_index, const char *filename, char **names, int classes, int frame_skip, char *prefix)
|
||||
void demo(char *cfgfile, char *weightfile, float thresh, int cam_index, const char *filename, char **names, int classes, int frame_skip, char *prefix, char *out_filename)
|
||||
{
|
||||
//skip = frame_skip;
|
||||
image **alphabet = load_alphabet();
|
||||
@ -194,7 +194,7 @@ void demo(char *cfgfile, char *weightfile, float thresh, int cam_index, const ch
|
||||
|
||||
if(!prefix){
|
||||
//show_image(disp, "Demo");
|
||||
show_image_cv_ipl(show_img, "Demo");
|
||||
show_image_cv_ipl(show_img, "Demo", out_filename);
|
||||
int c = cvWaitKey(1);
|
||||
if (c == 10){
|
||||
if(frame_skip == 0) frame_skip = 60;
|
||||
@ -244,7 +244,7 @@ void demo(char *cfgfile, char *weightfile, float thresh, int cam_index, const ch
|
||||
}
|
||||
}
|
||||
#else
|
||||
void demo(char *cfgfile, char *weightfile, float thresh, int cam_index, const char *filename, char **names, int classes, int frame_skip, char *prefix)
|
||||
void demo(char *cfgfile, char *weightfile, float thresh, int cam_index, const char *filename, char **names, int classes, int frame_skip, char *prefix, char *out_filename)
|
||||
{
|
||||
fprintf(stderr, "Demo needs OpenCV for webcam images.\n");
|
||||
}
|
||||
|
@ -2,6 +2,6 @@
|
||||
#define DEMO
|
||||
|
||||
#include "image.h"
|
||||
void demo(char *cfgfile, char *weightfile, float thresh, int cam_index, const char *filename, char **names, int classes, int frame_skip, char *prefix);
|
||||
void demo(char *cfgfile, char *weightfile, float thresh, int cam_index, const char *filename, char **names, int classes, int frame_skip, char *prefix, char *out_filename);
|
||||
|
||||
#endif
|
||||
|
@ -509,6 +509,7 @@ void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filenam
|
||||
|
||||
void run_detector(int argc, char **argv)
|
||||
{
|
||||
char *out_filename = find_char_arg(argc, argv, "-out_filename", 0);
|
||||
char *prefix = find_char_arg(argc, argv, "-prefix", 0);
|
||||
float thresh = find_float_arg(argc, argv, "-thresh", .24);
|
||||
int cam_index = find_int_arg(argc, argv, "-c", 0);
|
||||
@ -555,6 +556,6 @@ void run_detector(int argc, char **argv)
|
||||
int classes = option_find_int(options, "classes", 20);
|
||||
char *name_list = option_find_str(options, "names", "data/names.list");
|
||||
char **names = get_labels(name_list);
|
||||
demo(cfg, weights, thresh, cam_index, filename, names, classes, frame_skip, prefix);
|
||||
demo(cfg, weights, thresh, cam_index, filename, names, classes, frame_skip, prefix, out_filename);
|
||||
}
|
||||
}
|
||||
|
12
src/image.c
12
src/image.c
@ -518,7 +518,7 @@ void show_image_cv(image p, const char *name)
|
||||
}
|
||||
|
||||
|
||||
void show_image_cv_ipl(IplImage *disp, const char *name)
|
||||
void show_image_cv_ipl(IplImage *disp, const char *name, const char *out_filename)
|
||||
{
|
||||
if (disp == NULL) return;
|
||||
char buff[256];
|
||||
@ -529,7 +529,7 @@ void show_image_cv_ipl(IplImage *disp, const char *name)
|
||||
++windows;
|
||||
cvShowImage(buff, disp);
|
||||
|
||||
|
||||
if(out_filename)
|
||||
{
|
||||
CvSize size;
|
||||
{
|
||||
@ -539,10 +539,10 @@ void show_image_cv_ipl(IplImage *disp, const char *name)
|
||||
static CvVideoWriter* output_video = NULL; // cv::VideoWriter output_video;
|
||||
if (output_video == NULL)
|
||||
{
|
||||
const char* output_name = "test_dnn_out.avi";
|
||||
//output_video = cvCreateVideoWriter(output_name, CV_FOURCC('H', '2', '6', '4'), 25, size, 1);
|
||||
output_video = cvCreateVideoWriter(output_name, CV_FOURCC('D', 'I', 'V', 'X'), 25, size, 1);
|
||||
//output_video = cvCreateVideoWriter(output_name, CV_FOURCC('M', 'J', 'P', 'G'), 25, size, 1);
|
||||
//const char* output_name = "test_dnn_out.avi";
|
||||
//output_video = cvCreateVideoWriter(out_filename, CV_FOURCC('H', '2', '6', '4'), 25, size, 1);
|
||||
output_video = cvCreateVideoWriter(out_filename, CV_FOURCC('D', 'I', 'V', 'X'), 25, size, 1);
|
||||
//output_video = cvCreateVideoWriter(out_filename, CV_FOURCC('M', 'J', 'P', 'G'), 25, size, 1);
|
||||
}
|
||||
|
||||
cvWriteFrame(output_video, disp); // comment this line to improve FPS !!!
|
||||
|
@ -340,6 +340,7 @@ void test_yolo(char *cfgfile, char *weightfile, char *filename, float thresh)
|
||||
|
||||
void run_yolo(int argc, char **argv)
|
||||
{
|
||||
char *out_filename = find_char_arg(argc, argv, "-out_filename", 0);
|
||||
char *prefix = find_char_arg(argc, argv, "-prefix", 0);
|
||||
float thresh = find_float_arg(argc, argv, "-thresh", .2);
|
||||
int cam_index = find_int_arg(argc, argv, "-c", 0);
|
||||
@ -356,5 +357,5 @@ void run_yolo(int argc, char **argv)
|
||||
else if(0==strcmp(argv[2], "train")) train_yolo(cfg, weights);
|
||||
else if(0==strcmp(argv[2], "valid")) validate_yolo(cfg, weights);
|
||||
else if(0==strcmp(argv[2], "recall")) validate_yolo_recall(cfg, weights);
|
||||
else if(0==strcmp(argv[2], "demo")) demo(cfg, weights, thresh, cam_index, filename, voc_names, 20, frame_skip, prefix);
|
||||
else if(0==strcmp(argv[2], "demo")) demo(cfg, weights, thresh, cam_index, filename, voc_names, 20, frame_skip, prefix, out_filename);
|
||||
}
|
||||
|
Reference in New Issue
Block a user