COCO Dataset person_keypoints.json 解析

本文详细解析了COCO数据集的person_keypoints.json结构,包括全局信息、图片及标注信息,阐述了人体关键点的标注方式及可见性标记,展示了如何使用pycocotools库读取和展示数据。

COCO json–person_keypoints

person_keypoins.json 结构

在这里插入图片描述
“info”, “licenses”,"categories"全局通用
“images”跟“annotations”放着图片跟label信息,用image id匹配。
具体结构请看下文:

one image

pick one image, we will show what this image information is

person_keypoint.json

{
    "categories": [
        {
            "skeleton": [
                [16,14],
                [14,12],
                [17, 5],
                [15,13],
                [12,13],
                [6 ,12],
                [7 ,13],
                [6 , 7],
                [6 , 8],
                [7 , 9],
                [8 ,10],
                [9 ,11],
                [2 , 3],
                [1 , 2],
                [1 , 3],
                [2 , 4],
                [3 , 5],
                [4 , 6],
                [5 , 7]
            ],
            "name": "person", # 子类(具体类别)
            "supercategory": "person", # 主类
            "id": 1, # class id
            "keypoints": [
                "nose",
                "left_eye",
                "right_eye",
                "left_ear",
                "right_ear",
                "left_shoulder",
                "right_shoulder",
                "left_elbow",
                "right_elbow",
                "left_wrist",
                "right_wrist",
                "left_hip",
                "right_hip",
                "left_knee",
                "right_knee",
                "left_ankle",
                "right_ankle"
            ]
        }
    ],
    "licenses": [
        {
            "id": 1,
            "name": "Attribution-NonCommercial-ShareAlike License",
            "url": "http://creativecommons.org/licenses/by-nc-sa/2.0/"
        },
        {
            "id": 2,
            "name": "Attribution-NonCommercial License",
            "url": "http://creativecommons.org/licenses/by-nc/2.0/"
        },
        {
            "id": 3,
            "name": "Attribution-NonCommercial-NoDerivs License",
            "url": "http://creativecommons.org/licenses/by-nc-nd/2.0/"
        },
        {
            "id": 4,
            "name": "Attribution License",
            "url": "http://creativecommons.org/licenses/by/2.0/"
        },
        {
            "id": 5,
            "name": "Attribution-ShareAlike License",
            "url": "http://creativecommons.org/licenses/by-sa/2.0/"
        },
        {
            "id": 6,
            "name": "Attribution-NoDerivs License",
            "url": "http://creativecommons.org/licenses/by-nd/2.0/"
        },
        {
            "id": 7,
            "name": "No known copyright restrictions",
            "url": "http://flickr.com/commons/usage/"
        },
        {
            "id": 8,
            "name": "United States Government Work",
            "url": "http://www.usa.gov/copyright.shtml"
        }
    ],
    "annotations": [
        {
            "iscrowd": 0,
            "bbox": [
                339.88, 22.16, 153.88, 300.73 # [x,y,w,h] 对象定位框
            ],
            "image_id": 391895, # match the images: "id" 
            "segmentation": [
                [
                    352.55, 146.82, # 多边形(对象mask)第一个点 x,y, 如果对象被遮挡,对象被分成多个区域
                    353.61, 137.66,
                    356.07, 112.66,
                    ......
                    353.61, 152.25,
                    353.26, 149.43
                ],
                [
                    450.45, 196.54,
                    461.71, 195.13,
                    466.29, 209.22,
                    ......
                    449.04, 229.57,
                    448.33, 199.29
                ]
            ],
            "num_keypoints": 14,
            "id": 202758,
            "category_id": 1, 
            "keypoints": [
           		# 如果关键点在物体segment内,则认为可见.
           		# v=0 表示这个关键点没有标注(这种情况下x=y=v=0)
           		# v=1 表示这个关键点标注了但是不可见(被遮挡了)
           		# v=2 表示这个关键点标注了同时也可见
                368,  61,   1,
                369,  52,   2,
                0,     0,   0,
                382,  48,   2,
                0,     0,   0,
                368,  84,   2,
                435,  81,   2,
                362, 125,   2,
                446, 125,   2,
                360, 153,   2,
                0,     0,   0,
                397, 167,   1,
                439, 166,   1,
                369, 193,   2,
                461, 234,   2,
                361, 246,   2,
                474, 287,   2
            ],
            "area": 14107.2713
        },
        {
            "iscrowd": 0,
            "bbox": [
                471.64,
                172.82,
                35.92,
                48.1
            ],
            "image_id": 391895,
            "segmentation": [
                [
                    477.41, 217.71,
                    475.06, 212.15,
                    ......
                    478.27, 218.57
                ]
            ],
            "num_keypoints": 0,
            "id": 1260346,
            "category_id": 1,
            "keypoints": [
                0,0,0,
                0,0,0,
                0,0,0,
                0,0,0,
                0,0,0,
                0,0,0,
                0,0,0,
                0,0,0,
                0,0,0,
                0,0,0,
                0,0,0,
                0,0,0,
                0,0,0,
                0,0,0,
                0,0,0,
                0,0,0,
                0,0,0
            ],
            "area": 708.26055
        }
    ],
    "images": [
        {
            "id": 391895, # match the annotations: "image_id" 
            "date_captured": "2013-11-14 11:18:45",
            "coco_url": "http://images.cocodataset.org/val2014/COCO_val2014_000000391895.jpg",
            "height": 360,
            "flickr_url": "http://farm9.staticflickr.com/8186/8119368305_4e622c8349_z.jpg",
            "file_name": "COCO_val2014_000000391895.jpg",
            "license": 3,
            "width": 640
        }
    ],
    "info": {
        "version": "1.0",
        "description": "COCO 2014 Dataset",
        "year": 2014,
        "contributor": "COCO Consortium",
        "url": "http://cocodataset.org",
        "date_created": "2017/09/01"
    }
}

keypoint

“keypoints”是长度为3K的数组,K是对某类定义的关键点总数,这里人体的keypoint就是17个.位置为[x,y],关键点可见性v.
(1-‘nose’ 2-‘left_eye’ 3-‘right_eye’ 4-‘left_ear’ 5-‘right_ear’ 6-‘left_shoulder’ 7-‘right_shoulder’ 8-‘left_elbow’ -‘right_elbow’ 10-‘left_wrist’ 11-‘right_wrist’ 12-‘left_hip’ 13-‘right_hip’ 14-‘left_knee’ 15-‘right_knee’ 16-‘left_ankle’ 17-‘right_ankle’ )
在这里插入图片描述

OpenPose的姿态识别用了COCO数据库,coco有17个keypoint, OpenPose增加了一个, 用两侧肩膀生成一个中心点代表脖子,就是如下图openpose编号为1的人体中心点.
在这里插入图片描述

Display above image(ID=391895) label

# -*- coding:utf-8 -*-

from __future__ import print_function
from pycocotools.coco import COCO
import os, sys, zipfile
import shutil
import numpy as np
import skimage.io as io
import matplotlib.pyplot as plt
import pylab
pylab.rcParams['figure.figsize'] = (8.0, 10.0)

annFile='./pickOne_person_keypoints_2014_.json'
coco=COCO(annFile)

# display COCO categories and supercategories
cats = coco.loadCats(coco.getCatIds())
nms=[cat['name'] for cat in cats]
print('COCO categories: \n{}\n'.format(' '.join(nms)))

nms = set([cat['supercategory'] for cat in cats])
print('COCO supercategories: \n{}'.format(' '.join(nms)))

imgIds = coco.getImgIds(imgIds = [391895])
# imgIds = coco.getImgIds()
img = coco.loadImgs(imgIds[0])[0]
dataDir = '../data/mscoco2014'
dataType = 'val2014'
I = io.imread('%s/%s/%s'%(dataDir,dataType,img['file_name']))

plt.axis('off')
plt.imshow(I)
plt.show()


# load and display instance annotations
# 加载实例掩膜
# catIds = coco.getCatIds(catNms=['person','dog','skateboard']);
# catIds=coco.getCatIds()
catIds=[]
for ann in coco.dataset['annotations']:
    if ann['image_id']==imgIds[0]:
        catIds.append(ann['category_id'])

plt.imshow(I); plt.axis('off')
annIds = coco.getAnnIds(imgIds=img['id'], catIds=catIds, iscrowd=None)
anns = coco.loadAnns(annIds)
coco.showAnns(anns)

# initialize COCO api for person keypoints annotations
annFile = '{}/annotations/person_keypoints_{}.json'.format(dataDir,dataType)
coco_kps=COCO(annFile)

# load and display keypoints annotations
# 加载肢体关键点
plt.imshow(I); plt.axis('off')
ax = plt.gca()
annIds = coco_kps.getAnnIds(imgIds=img['id'], catIds=catIds, iscrowd=None)
anns = coco_kps.loadAnns(annIds)
coco_kps.showAnns(anns)

# initialize COCO api for caption annotations
annFile = '{}/annotations/captions_{}.json'.format(dataDir,dataType)
coco_caps=COCO(annFile)

# load and display caption annotations
# 加载文本描述
annIds = coco_caps.getAnnIds(imgIds=img['id']);
anns = coco_caps.loadAnns(annIds)
coco_caps.showAnns(anns)
plt.imshow(I); plt.axis('off'); plt.show()

original image
在这里插入图片描述

segment & kepoints
在这里插入图片描述

caption annotations
A man with a red helmet on a small moped on a dirt road.
Man riding a motor bike on a dirt road on the countryside.
A man riding on the back of a motorcycle.
A dirt path with a young person on a motor bike rests to the foreground of a verdant area with a bridge and a background of cloud-wreathed mountains.
A man in a red shirt and a red hat is on a motorcycle on a hill side.

git: https://github.com/Frizy-up/openpose-plus/tree/master

标题SpringBoot智能在线预约挂号系统研究AI更换标题第1章引言介绍智能在线预约挂号系统的研究背景、意义、国内外研究现状及论文创新点。1.1研究背景与意义阐述智能在线预约挂号系统对提升医疗服务效率的重要性。1.2国内外研究现状分析国内外智能在线预约挂号系统的研究与应用情况。1.3研究方法及创新点概述本文采用的技术路线、研究方法及主要创新点。第2章相关理论总结智能在线预约挂号系统相关理论,包括系统架构、开发技术等。2.1系统架构设计理论介绍系统架构设计的基本原则和常用方法。2.2SpringBoot开发框架理论阐述SpringBoot框架的特点、优势及其在系统开发中的应用。2.3数据库设计与管理理论介绍数据库设计原则、数据模型及数据库管理系统。2.4网络安全与数据保护理论讨论网络安全威胁、数据保护技术及其在系统中的应用。第3章SpringBoot智能在线预约挂号系统设计详细介绍系统的设计方案,包括功能模块划分、数据库设计等。3.1系统功能模块设计划分系统功能模块,如用户管理、挂号管理、医生排班等。3.2数据库设计与实现设计数据库表结构,确定字段类型、主键及外键关系。3.3用户界面设计设计用户友好的界面,提升用户体验。3.4系统安全设计阐述系统安全策略,包括用户认证、数据加密等。第4章系统实现与测试介绍系统的实现过程,包括编码、测试及优化等。4.1系统编码实现采用SpringBoot框架进行系统编码实现。4.2系统测试方法介绍系统测试的方法、步骤及测试用例设计。4.3系统性能测试与分析对系统进行性能测试,分析测试结果并提出优化建议。4.4系统优化与改进根据测试结果对系统进行优化和改进,提升系统性能。第5章研究结果呈现系统实现后的效果,包括功能实现、性能提升等。5.1系统功能实现效果展示系统各功能模块的实现效果,如挂号成功界面等。5.2系统性能提升效果对比优化前后的系统性能
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值