Skip to content

Commit

Permalink
text_filename_change
Browse files Browse the repository at this point in the history
txt file can change name by import data name
  • Loading branch information
chiyuzhang94 committed May 9, 2018
1 parent 5ca58f6 commit a52b660
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/detector.c
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ void test_detector(char *datacfg, char *cfgfile, char *weightfile, char *filenam
int nboxes = 0;
detection *dets = get_network_boxes(&net, im.w, im.h, thresh, hier_thresh, 0, 1, &nboxes, letterbox);
if (nms) do_nms_sort(dets, nboxes, l.classes, nms);
draw_detections_v3(im, dets, nboxes, thresh, names, alphabet, l.classes);
draw_detections_v3(im, dets, nboxes, thresh, names, alphabet, l.classes, filename);
free_detections(dets, nboxes);
save_image(im, "predictions");
if (!dont_show) {
Expand Down
28 changes: 14 additions & 14 deletions src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,20 @@ image **load_alphabet()
return alphabets;
}

void draw_detections_v3(image im, detection *dets, int num, float thresh, char **names, image **alphabet, int classes)
void draw_detections_v3(image im, detection *dets, int num, float thresh, char **names, image **alphabet, int classes, char *filename)
{
int i, j;
// char video_name[200] = {0};
// strcat(video_name,filename);
// strcat(video_name,".txt");
char video_name[200] = {0};
strcat(video_name,filename);
strcat(video_name,".txt");

FILE *pFile;
if ((pFile=fopen("yolo_v3_detec.txt", "r"))==NULL){
pFile=fopen("yolo_v3_detec.txt", "a");
if ((pFile=fopen(video_name, "r"))==NULL){
pFile=fopen(video_name, "a");
fprintf(pFile,"#object, left, right, top, bottom, prob\n");
}
else{
pFile=fopen("yolo_v3_detec.txt", "a");
pFile=fopen(video_name, "a");
}

for (i = 0; i < num; ++i) {
Expand Down Expand Up @@ -422,21 +422,21 @@ void draw_detections(image im, int num, float thresh, box *boxes, float **probs,

#ifdef OPENCV

void draw_detections_cv_v3(IplImage* show_img, detection *dets, int num, float thresh, char **names, image **alphabet, int classes)
void draw_detections_cv_v3(IplImage* show_img, detection *dets, int num, float thresh, char **names, image **alphabet, int classes, char *filename)
{
int i, j;

// char video_name[200] = {0};
// strcat(video_name,filename);
// strcat(video_name,"cv.txt");
char video_name[200] = {0};
strcat(video_name,filename);
strcat(video_name,"cv.txt");

FILE *pFile;
if ((pFile=fopen("yolo_v3_detec_cv.txt", "r"))==NULL){
pFile=fopen("yolo_v3_detec_cv.txt", "a");
if ((pFile=fopen(video_name, "r"))==NULL){
pFile=fopen(video_name, "a");
fprintf(pFile,"#object, left, right, top, bottom, prob\n");
}
else{
pFile=fopen("yolo_v3_detec_cv.txt", "a");
pFile=fopen(video_name, "a");
}

if (!show_img) return;
Expand Down
2 changes: 1 addition & 1 deletion src/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void draw_bbox(image a, box bbox, int w, float r, float g, float b);
void draw_label(image a, int r, int c, image label, const float *rgb);
void write_label(image a, int r, int c, image *characters, char *string, float *rgb);
void draw_detections(image im, int num, float thresh, box *boxes, float **probs, char **names, image **labels, int classes);
void draw_detections_v3(image im, detection *dets, int num, float thresh, char **names, image **alphabet, int classes);
void draw_detections_v3(image im, detection *dets, int num, float thresh, char **names, image **alphabet, int classes, char *filename);
image image_distance(image a, image b);
void scale_image(image m, float s);
image crop_image(image im, int dx, int dy, int w, int h);
Expand Down

0 comments on commit a52b660

Please sign in to comment.