美文网首页
YOLOv2(一) 参考资料

YOLOv2(一) 参考资料

作者: NoneLand | 来源:发表于2017-09-06 14:25 被阅读517次

参考资料

使用

画框源码

void draw_box(image a, int x1, int y1, int x2, int y2, float r, float g, float b)
{
    //normalize_image(a);
    int i;
    if(x1 < 0) x1 = 0;
    if(x1 >= a.w) x1 = a.w-1;
    if(x2 < 0) x2 = 0;
    if(x2 >= a.w) x2 = a.w-1;

    if(y1 < 0) y1 = 0;
    if(y1 >= a.h) y1 = a.h-1;
    if(y2 < 0) y2 = 0;
    if(y2 >= a.h) y2 = a.h-1;

    for(i = x1; i <= x2; ++i){
        a.data[i + y1*a.w + 0*a.w*a.h] = r;
        a.data[i + y2*a.w + 0*a.w*a.h] = r;

        a.data[i + y1*a.w + 1*a.w*a.h] = g;
        a.data[i + y2*a.w + 1*a.w*a.h] = g;

        a.data[i + y1*a.w + 2*a.w*a.h] = b;
        a.data[i + y2*a.w + 2*a.w*a.h] = b;
    }
    for(i = y1; i <= y2; ++i){
        a.data[x1 + i*a.w + 0*a.w*a.h] = r;
        a.data[x2 + i*a.w + 0*a.w*a.h] = r;

        a.data[x1 + i*a.w + 1*a.w*a.h] = g;
        a.data[x2 + i*a.w + 1*a.w*a.h] = g;

        a.data[x1 + i*a.w + 2*a.w*a.h] = b;
        a.data[x2 + i*a.w + 2*a.w*a.h] = b;
    }
}

代码在./src/image.c中,从源码中可以看出,YOLO预测值为矩阵的左上角坐标和右下角坐标。(并不是,这是经过转换之后,在网络中流动的是anchor box,即(x,y)在box中心的高度,然后再根据数据结果,进行转换。

YOLOv2 中的Box格式----anchor box

用于准备数据的voc_label.py

def convert(size, box):
    dw = 1./size[0]
    dh = 1./size[1]
    x = (box[0] + box[1])/2.0
    y = (box[2] + box[3])/2.0
    w = box[1] - box[0]
    h = box[3] - box[2]
    x = x*dw
    w = w*dw
    y = y*dh
    h = h*dh
    return (x,y,w,h)

size是图像的widthheightbox参数为xmin, xmax,yin,ymax。所以传入的是矩形框左上和右下两个角点的坐标,然后输出值是标准化的图像中心坐标和图像宽度和高度。
实例如下:

2008_000002.xml

<annotation>
    <folder>VOC2012</folder>
    <filename>2008_000002.jpg</filename>
    <source>
        <database>The VOC2008 Database</database>
        <annotation>PASCAL VOC2008</annotation>
        <image>flickr</image>
    </source>
    <size>
        <width>500</width>
        <height>375</height>
        <depth>3</depth>
    </size>
    <segmented>0</segmented>
    <object>
        <name>tvmonitor</name>
        <pose>Frontal</pose>
        <truncated>0</truncated>
        <occluded>0</occluded>
        <bndbox>
            <xmin>34</xmin>
            <ymin>11</ymin>
            <xmax>448</xmax>
            <ymax>293</ymax>
        </bndbox>
        <difficult>0</difficult>
    </object>
</annotation>

经过转换得到的标记文件如下:

19 0.482 0.405333333333 0.828 0.752

其中,第一个数值表示分类标签,后四个值分别表示均一化的x, y, width, height

由视频提取图像和标记

opencv add vs numpy add

相关文章

  • YOLOv2(一) 参考资料

    参考资料 Yolo-v2训练voc及自己的数据集 【YOLO学习】使用YOLO v2训练自己的数据 Python ...

  • Yolov2网络结构

    为了便于理解Yolov2网络结构,参照AlexeyAB提供的Yolov2网络cfg文件绘制网络结构图Yolov2代...

  • YOLO概述

    参考 Real-time Object Detection with YOLO, YOLOv2 and now Y...

  • YOLOv2,YOLOv3

    目录: •YOLOv2 • YOLOv3 YOLO9000: Better, Faster, Stronger ...

  • YOLOv2

  • yolov2算法详解

    yolov2原文叫《YOLO9000:Better, Faster, Stronger》[https://arxi...

  • 读论文系列:Object Detection CVPR2017

    YOLOv2/YOLO9000 YOLO9000: Better, Faster, Stronger YOLOv2...

  • 初探蓝牙

    参考资料1 参考资料2 参考资料3 参考资料4 参考资料5 参考资料6 参考资料7 iOS后台运行BLE 参考资料...

  • YOLOv2 in PyTorch

    This is a PyTorch implementation of YOLOv2. This project ...

  • yolov2 output

    grid网格 13x13 每个网格: 候选框(anchor)= 5 每个候选框: (centerx,cent...

网友评论

      本文标题:YOLOv2(一) 参考资料

      本文链接:https://www.haomeiwen.com/subject/eyttnttx.html