NUIST-DEV / front-end

0 stars 0 forks source link

增加锚框显示的功能 #1

Closed bkmashiro closed 1 year ago

bkmashiro commented 2 years ago

Hi, @zi-feng-0109 . 现在需要前端增加一个功能,即锚框显示。 这里举一个例子。 现在向后端发送图片 zidane 他会返回一个JSON,类似于:

[
    {
        "x1": 0.5804489850997925,
        "y1": 0.06721606850624084,
        "x2": 0.8920660018920898,
        "y2": 1.0,
        "confidence": 0.8810521960258484,
        "class": 0,
        "verbose": "person"
    },
    {
        "x1": 0.345318466424942,
        "y1": 0.6076700091362,
        "x2": 0.3880109190940857,
        "y2": 0.9860743880271912,
        "confidence": 0.6752132177352905,
        "class": 27,
        "verbose": "tie"
    },
    {
        "x1": 0.09611260890960693,
        "y1": 0.2684546709060669,
        "x2": 0.5591111183166504,
        "y2": 0.9996165037155151,
        "confidence": 0.6658140420913696,
        "class": 0,
        "verbose": "person"
    },
    {
        "x1": 0.7678149938583374,
        "y1": 0.42835745215415955,
        "x2": 0.8026295900344849,
        "y2": 0.5833152532577515,
        "confidence": 0.2600752115249634,
        "class": 27,
        "verbose": "tie"
    }
]

前端应该显示如图所示的标识了识别结果的图像。 zidane

bkmashiro commented 2 years ago

这里的坐标都是[0,1]之间的,0是0px,1是width/height px。乘回对应的长宽就能复原

bkmashiro commented 2 years ago

关于术语:(x1,y1)是锚框左上角坐标,(x2,y2)是右下角坐标。confidence是这个结果的置信度,class是这个结果对应的数字编号,verbose是这个结果对应的东西的名字(数字编号的人话版本)。 附上数字编号与单词对应:

{0: 'person',
 1: 'bicycle',
 2: 'car',
 3: 'motorcycle',
 4: 'airplane',
 5: 'bus',
 6: 'train',
 7: 'truck',
 8: 'boat',
 9: 'traffic light',
 10: 'fire hydrant',
 11: 'stop sign',
 12: 'parking meter',
 13: 'bench',
 14: 'bird',
 15: 'cat',
 16: 'dog',
 17: 'horse',
 18: 'sheep',
 19: 'cow',
 20: 'elephant',
 21: 'bear',
 22: 'zebra',
 23: 'giraffe',
 24: 'backpack',
 25: 'umbrella',
 26: 'handbag',
 27: 'tie',
 28: 'suitcase',
 29: 'frisbee',
 30: 'skis',
 31: 'snowboard',
 32: 'sports ball',
 33: 'kite',
 34: 'baseball bat',
 35: 'baseball glove',
 36: 'skateboard',
 37: 'surfboard',
 38: 'tennis racket',
 39: 'bottle',
 40: 'wine glass',
 41: 'cup',
 42: 'fork',
 43: 'knife',
 44: 'spoon',
 45: 'bowl',
 46: 'banana',
 47: 'apple',
 48: 'sandwich',
 49: 'orange',
 50: 'broccoli',
 51: 'carrot',
 52: 'hot dog',
 53: 'pizza',
 54: 'donut',
 55: 'cake',
 56: 'chair',
 57: 'couch',
 58: 'potted plant',
 59: 'bed',
 60: 'dining table',
 61: 'toilet',
 62: 'tv',
 63: 'laptop',
 64: 'mouse',
 65: 'remote',
 66: 'keyboard',
 67: 'cell phone',
 68: 'microwave',
 69: 'oven',
 70: 'toaster',
 71: 'sink',
 72: 'refrigerator',
 73: 'book',
 74: 'clock',
 75: 'vase',
 76: 'scissors',
 77: 'teddy bear',
 78: 'hair drier',
 79: 'toothbrush'}
bkmashiro commented 1 year ago

Done in commit 9b65520cf493f85bcb4cadddc4d8b1d6a495d1f1