COCO Dataset person_keypoints.json 解析

2023-05-16

DataSet

  • COCO json--person_keypoints
    • person_keypoins.json 结构
    • one image
    • person_keypoint.json
    • keypoint
    • Display above image(ID=391895) label

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

COCO Dataset person_keypoints.json 解析 的相关文章

  • 如何使用Gson仅从Json反序列化某些特定字段?

    我有以下 JSON 字符串 channel bvmt initValues data value instrumentIds TN0007250012 TN0007500010 instruments mnemonic ADWYA marc
  • 意外的令牌:尝试解析 JSON 字符串时

    我正在尝试解析这个 JSON 字符串 RESULTS name Thessaloniki GR type Sailing l sailing weather beach Porto 20Carras 20Marina 45904 name
  • 如何在 Jackson JSON(反)序列化中使用自定义键类型自定义序列化或转换 Map 属性?

    我正在序列化实例 JsonIdentityInfo generator ObjectIdGenerators PropertyGenerator class property id scope Entity1 class public cl
  • 使用 javax/json,如何将元素添加到现有的 JsonArray 中?

    我从文件中读取了一个 JSON 数组 但我想向该数组中添加其他条目 我将如何使用 javax json 库来做到这一点 private String getJson FileInputStream fis throws IOExceptio
  • 如何为本机启用现有 WCF 服务的 JSONP?

    我有一个现有的服务 如下方法 AspNetCompatibilityRequirements RequirementsMode AspNetCompatibilityRequirementsMode Allowed ServiceBehav
  • 如何将异常序列化为Json

    C 异常是 ISerialisable 因此它们不能也是 DataContract 因此我无法使用 JsonDataContractSerializer 将异常序列化为 JSON 的替代方案是什么 由于这个问题还没有真正得到解答 只需创建一
  • 处理 fanart.tv Web 服务响应 JSON 和 C#

    我正在尝试使用 fanart tv Webservice API 但有几个问题 我正在使用 Json Net Newtonsoft Json 并通过其他 Web 服务将 JSON 响应直接反序列化为 C 对象 这里的问题是元素名称正在更改
  • 如何从 JSON 响应重定向?

    所以我尝试使用 Flask 和 Javascript 上传器 Dropzone 上传文件并在上传完成后重定向 文件上传正常 但在烧瓶中使用传统的重定向 return redirect http somesite com 不执行任何操作 页面
  • 使用 Python 将对象列表转为 JSON

    我在转换时遇到问题Object实例到 JSON ob Object list name scaping myObj base url u number page for ob in list name json string json du
  • C# Newtonsoft 反序列化 JSON 数组

    我正在尝试使用 Newtonsoft 反序列化数组 以便我可以在列表框中显示来自基于云的服务器的文件 但无论我尝试什么 我总是会收到此错误 Newtonsoft Json JsonReaderException 解析值时遇到意外字符 路径
  • Flutter:将字符串转换为 Map

    我正在使用 SQFlite 在本地存储数据 我有一个表 其中有一个名为 json 的字段 该字段的类型为 TEXT 并存储转换为字符串的 json 例如 name Eduardo Age 23 性别男 到目前为止 一切正常 但随后我需要从数
  • 如何发送和接收大型 JSON 数据

    我对全栈开发比较陌生 目前正在尝试找出一种有效的方法send and fetch我的前端 React 和后端 Express 之间存在大量数据 同时最大限度地减少内存使用 具体来说 我正在构建一个地图应用程序 它需要我处理大型 JSON 文
  • Postgres JSONB:数组数组的 where 子句

    postgres 中有 v 9 5 如果有的话 create table json test id varchar NOT NULL data jsonb NOT NULL PRIMARY KEY id 其中 data 是 json 并且包
  • 为什么 json.Unmarshal 返回映射而不是预期的结构?

    看看这个游乐场 http play golang org p dWku6SPqj5 http play golang org p dWku6SPqj5 基本上 我正在工作的图书馆收到了interface 作为参数 然后需要json Unma
  • 如何舍入、取整、取整、截断

    如何对 jq jq 1 5 1 a5b5cbe 中的数字进行舍入 取整 取整和截断 例如 与 mass 188 72 我想 mass 188 有地板 mass 189 与天花板和圆形 舍入示例 5 52 gt 6 5 50 gt 5 or
  • Jackson 将单个项目反序列化到列表中

    我正在尝试使用一项服务 该服务为我提供了一个带有数组字段的实体 id 23233 items name item 1 name item 2 但是 当数组包含单个项目时 将返回该项目本身 而不是包含一个元素的数组 id 43567 item
  • 编码:类型错误:write() 参数必须是 str,而不是 bytes

    我对 python 有初步的了解 但不清楚处理二进制编码问题 我正在尝试运行 firefox webextensions 示例中的示例代码 其中 python 脚本发送由 javascript 程序读取的文本 我不断遇到编码错误 蟒蛇代码是
  • CodeIgniter 控制器 - JSON - AJAX

    我正在尝试通过 AJAX 使用 CodeIgniter 发送表单构建 并尝试使用 JSON 获取响应 但是 我只在打开开发人员选项卡时看到响应 我什至不确定这是否实际上是响应 因为它显示了两个 json 数据 它所显示的只是加载旋转器 然后
  • 键绑定 - 鼠标中键与 Sublime Text 2

    有谁知道是否可以将鼠标中键绑定到 Sublime Text 2 中的操作 我知道可以进行一些鼠标交互 因为您可以使用后退和前进按钮 基本上 我将使用此按钮通过 sFTP 插件上传文件 这样我需要按下的按钮数量就会从 3 个减少到 1 个 目
  • JSON 到 hashmap (杰克逊)

    我想将 JSON 转换为 HashMapJackson http jackson codehaus org 这是我的 JSON String json Opleidingen name Bijz trajecten zorg en welz

随机推荐