c++版本相對於官網上的c版本更加智能(c版本只能在linux上跑),而c++版本的yolov3也可以在win上跑。
找到home/yourpath/.../darknet/src/detector.c程序。
開頭的*GetFilename進行修改,申明的函數也帶進去,可以選擇直接粘貼過去。其中就參數6注意一下就行。
#include "darknet.h"
#include <sys/stat.h>
#include<stdio.h>
#include<time.h>
#include<sys/types.h>
static int coco_ids[] = {1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,19,20,21,22,23,24,25,27,28,31,32,33,34,35,36,37,38,39,40,41,42,43,44,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,67,70,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90};
char *GetFilename(char *p)
{
static char name[20]={""};
char *q = strrchr(p,'/') + 1;
strncpy(name,q,6);//注意後面的6,如果你的測試集的圖片的名字字符(不包括後綴)是其他長度,請改爲你需要的長度(官方的默認的長度是6)
return name;
}
然後ctrl+f搜索"save_image(im, "predictions")"將下面程序插入,然後註釋掉save_image(im, "predictions")
char b[512];
sprintf(b, "output/%s", GetFilename(input));
save_image(im, b);
修改完成在darknet路徑下make clean再make
然後將你需要批量測試圖片的絕對路徑保存於train.txt內,可以放在data文件夾下。(需要開始在darknet文件夾裏面創建output文件夾)注意:<>不能省略。
./darknet detector test cfg/voc.data cfg/yolov3.cfg yolov3.weights -dont_show -ext_output <data/train.txt> results.txt
對應着把cfg進行修改即可。
然後就坐等在daknet/output裏面的照片輸出完成,同時在result.txt裏面會保存每張照片裏面目標的座標信息。