CrowdHumanテスト
3433 ワード
CrowdHumanテスト
hbox:head box
vbox:ボディboxが表示されます
fbox:連想拡張ボディbox
座標:x y w h
cv2.rectangle:x1 y1 x2 y2
x 1 y 1 x 2 y 2が境界を超えていれば、間違いを報告しないが、描けない.
height,width=img.shape[:2]
import cv2
import json
obj_str='{"ID": "284193,faa9000f2678b5e", "gtboxes": [{"tag": "person", "hbox": [123, 129, 63, 64], "head_attr": {"ignore": 0, "occ": 1, "unsure": 0}, "fbox": [61, 123, 191, 453], "vbox": [62, 126, 154, 446], "extra": {"box_id": 0, "occ": 1}}, {"tag": "person", "hbox": [214, 97, 58, 74], "head_attr": {"ignore": 0, "occ": 1, "unsure": 0}, "fbox": [165, 95, 187, 494], "vbox": [175, 95, 140, 487], "extra": {"box_id": 1, "occ": 1}}, {"tag": "person", "hbox": [318, 109, 58, 68], "head_attr": {"ignore": 0, "occ": 1, "unsure": 0}, "fbox": [236, 104, 195, 493], "vbox": [260, 106, 170, 487], "extra": {"box_id": 2, "occ": 1}}, {"tag": "person", "hbox": [486, 119, 61, 74], "head_attr": {"ignore": 0, "occ": 0, "unsure": 0}, "fbox": [452, 110, 169, 508], "vbox": [455, 113, 141, 501], "extra": {"box_id": 3, "occ": 1}}, {"tag": "person", "hbox": [559, 105, 53, 57], "head_attr": {"ignore": 0, "occ": 0, "unsure": 0}, "fbox": [520, 95, 163, 381], "vbox": [553, 98, 70, 118], "extra": {"box_id": 4, "occ": 1}}, {"tag": "person", "hbox": [596, 40, 72, 83], "head_attr": {"ignore": 0, "occ": 0, "unsure": 0}, "fbox": [546, 39, 202, 594], "vbox": [556, 39, 171, 588], "extra": {"box_id": 5, "occ": 1}}, {"tag": "person", "hbox": [731, 139, 69, 83], "head_attr": {"ignore": 0, "occ": 0, "unsure": 0}, "fbox": [661, 132, 183, 510], "vbox": [661, 132, 183, 510], "extra": {"box_id": 6, "occ": 0}}]}'
data = json.loads(obj_str)
img=cv2.imread("284193,faa9000f2678b5e.jpg")
print(data["ID"])
for obj in data["gtboxes"]:
# print('tag',obj['tag'])
print('hbox',obj['hbox'])
# draw_0 = cv2.rectangle(img, (obj['hbox'][0], obj['hbox'][1]), (obj['hbox'][0]+obj['hbox'][2], obj['hbox'][1]+obj['hbox'][3]), (255, 0, 0), 1)
# print('head_attr',obj['head_attr'])
print('fbox',obj['fbox'])
# draw_0 = cv2.rectangle(img, (obj['fbox'][0], obj['fbox'][1]),(obj['fbox'][0] + obj['fbox'][2], obj['fbox'][1] + obj['fbox'][3]), (0, 255, 0), 1)
print('vbox',obj['vbox'])
draw_0 = cv2.rectangle(img, (obj['vbox'][0], obj['vbox'][1]),(obj['vbox'][0] + obj['vbox'][2], obj['vbox'][1] + obj['vbox'][3]), (0, 0,255), 1)
# print('extra',obj['extra'])
cv2.imshow("'sdf",img)
cv2.waitKey()