在/darkent/src/目录下:
image.c文件的的239行的draw_detections函数输出boundingbox的位置信息,此处屏蔽掉标签信息,因为没有用
void draw_detections(image im, detection *dets, int num, float thresh, char **names, image **alphabet, int classes)
{
int i,j;
draw_box(im, 320, 240, 372, 290, 255, 0, 0); //画标准位置框,用于标定停车位置
for(i = 0; i < num; ++i){
char labelstr[4096] = {0};
int class = -1;
for(j = 0; j < classes; ++j){
if (dets[i].prob[j] > thresh){
if (class < 0) {
strcat(labelstr, names[j]);
class = j;
} else {
strcat(labelstr, ", ");
strcat(labelstr, names[j]);
}
printf("%s: %.0f%%\n", names[j], dets[i].prob[j]*100);
}
}
if(class >= 0){
int width = im.h * .006;
/*
if(0){
width = pow(prob, 1./2.)*10+1;
alphabet = 0;
}
*/
//printf("%d %s: %.0f%%\n", i, names[class], prob*100);
int offset = class*123457 % classes;
float red = get_color(2,offset,classes);
float green = get_color(1,offset,classes);
float blue = get_color(0,offset,classes);
float rgb[3];
//width = prob*20+2;
rgb[0] = red;
rgb[1] = green;
rgb[2] = blue;
box b = dets[i].bbox;
//printf("%f %f %f %f\n", b.x, b.y, b.w, b.h);
int left = (b.x-b.w/2.)*im.w;
int right = (b.x+b.w/2.)*im.w;
int top = (b.y-b.h/2.)*im.h;
int bot = (b.y+b.h/2.)*im.h;
if(left < 0) left = 0;
if(right > im.w-1) right = im.w-1;
if(top < 0) top = 0;
if(bot > im.h-1) bot = im.h-1;
//printf("BoxPosition:left=%d top=%d right=%d bot=%d\n",left,top,right,bot); //打印检测框位置
int BiaodingErrorx = 10;
int BiaodingErrory = 20;
int ErrorX = 320 - left - BiaodingErrorx;
int ErrorY = 240 - top - BiaodingErrory;
if((abs(ErrorX) <= 2) && (abs(ErrorY) <= 2)) //误差范围设置阈值
printf("Located Finish!\n");
else
printf("ErrorX = %d,ErrorY = %d\n",ErrorX,ErrorY);
draw_box_width(im, left, top, right, bot, width, red, green, blue); //画检测物体的框
//draw_label(im, top + width, left, left, rgb);
//此处为label标记处,屏蔽掉即可
/*
if (alphabet)
{
image label = get_label(alphabet, labelstr, (im.h*.03));
draw_label(im, top + width, left, label, rgb);
free_image(label);
}
if (dets[i].mask)
{
image mask = float_to_image(14, 14, 1, dets[i].mask);
image resized_mask = resize_image(mask, b.w*im.w, b.h*im.h);
image tmask = threshold_image(resized_mask, .5);
embed_image(tmask, im, left, top);
free_image(mask);
free_image(resized_mask);
free_image(tmask);
}
*/
}
}
}
./darknet detector demo cfg/voc.data cfg/yolov3.cfg /home/sq123/2blogexample/backup/yolov3_1000.weights -thresh 0.4