COCO數據集的下載以及姿態關鍵點的數據處理


第一步、coco數據集下載鏈接
不過還在羅嗦一句,第一組是train數據,第二組是val驗證數據集,第三組是test驗證數據集。數據包括了物體檢測和keypoints身體關鍵點的檢測。

http://images.cocodataset.org/zips/train2017.zip
http://images.cocodataset.org/annotations/annotations_trainval2017.zip

http://images.cocodataset.org/zips/val2017.zip
http://images.cocodataset.org/annotations/stuff_annotations_trainval2017.zip

http://images.cocodataset.org/zips/test2017.zip
http://images.cocodataset.org/annotations/image_info_test2017.zip
這些就是全部的microsoft coco數據集2017的鏈接了。

COCO數據集現在有3種標注類型:object instances(目標實例), object keypoints(目標上的關鍵點), and image captions(看圖說話)

此外,每種類型又包含了訓練和驗證,所以共6個JSON文件

第二步、基本的JSON結構體類型

這3種類型共享下面所列的基本類型,包括info、image、license,而annotation類型則呈現出了多態:

{ "info": info, "licenses": [license], "images": [image], "annotations": [annotation], } info{ "year": int, "version": str, "description": str, "contributor": str, "url": str, "date_created": datetime, } license{ "id": int, "name": str, "url": str, } image{ "id": int, "width": int, "height": int, "file_name": str, "license": int, "flickr_url": str, "coco_url": str, "date_captured": datetime, } 

1,info類型,比如一個info類型的實例:

"info":{ "description":"This is stable 1.0 version of the 2014 MS COCO dataset.", "url":"http:\/\/mscoco.org", "version":"1.0","year":2014, "contributor":"Microsoft COCO group", "date_created":"2015-01-27 09:11:52.357475" }, 

2,Images是包含多個image實例的數組,對於一個image類型的實例:

{ "license":3, "file_name":"COCO_val2014_000000391895.jpg", "coco_url":"http:\/\/mscoco.org\/images\/391895", "height":360,"width":640,"date_captured":"2013-11-14 11:18:45", "flickr_url":"http:\/\/farm9.staticflickr.com\/8186\/8119368305_4e622c8349_z.jpg", "id":391895 }, 

3,licenses是包含多個license實例的數組,對於一個license類型的實例:

{ "url":"http:\/\/creativecommons.org\/licenses\/by-nc-sa\/2.0\/", "id":1, "name":"Attribution-NonCommercial-ShareAlike License" }, 

第三部、認識Object Keypoint 類型的標注格式

1,整體JSON文件格式

比如上圖中的person_keypoints_train2017.json、person_keypoints_val2017.json這兩個文件就是這種格式。

Object Keypoint這種格式的文件從頭至尾按照順序分為以下段落,看起來和Object Instance一樣啊:

{
    "info": info,
    "licenses": [license],
    "images": [image],
    "annotations": [annotation],
    "categories": [category]
}

是的,你打開這兩個文件,雖然內容很多,但從文件開始到結尾按照順序就是這5段。其中,info、licenses、images這三個結構體/類型 在第一節中已經說了,在不同的JSON文件中這三個類型是一樣的,定義是共享的。不共享的是annotation和category這兩種結構體,他們在不同類型的JSON文件中是不一樣的。

images數組和annotations數組的元素數量是相等的,等於圖片的數量。

2,annotations字段

這個類型中的annotation結構體包含了Object Instance中annotation結構體的所有字段,再加上2個額外的字段。

新增的keypoints是一個長度為3*k的數組,其中k是category中keypoints的總數量。每一個keypoint是一個長度為3的數組,第一和第二個元素分別是x和y坐標值,第三個元素是個標志位v,v為0時表示這個關鍵點沒有標注(這種情況下x=y=v=0),v為1時表示這個關鍵點標注了但是不可見(被遮擋了),v為2時表示這個關鍵點標注了同時也可見。

num_keypoints表示這個目標上被標注的關鍵點的數量(v>0),比較小的目標上可能就無法標注關鍵點。

annotation{ "keypoints": [x1,y1,v1,...], "num_keypoints": int, "id": int, "image_id": int, "category_id": int, "segmentation": RLE or [polygon], "area": float, "bbox": [x,y,width,height], "iscrowd": 0 or 1, } 

從person_keypoints_val2017.json文件中摘出一個annotation的實例如下:

{ "segmentation": [[125.12,539.69,140.94,522.43,100.67,496.54,84.85,469.21,73.35,450.52,104.99,342.65,168.27,290.88,179.78,288,189.84,286.56,191.28,260.67,202.79,240.54,221.48,237.66,248.81,243.42,257.44,256.36,253.12,262.11,253.12,275.06,299.15,233.35,329.35,207.46,355.24,206.02,363.87,206.02,365.3,210.34,373.93,221.84,363.87,226.16,363.87,237.66,350.92,237.66,332.22,234.79,314.97,249.17,271.82,313.89,253.12,326.83,227.24,352.72,214.29,357.03,212.85,372.85,208.54,395.87,228.67,414.56,245.93,421.75,266.07,424.63,276.13,437.57,266.07,450.52,284.76,464.9,286.2,479.28,291.96,489.35,310.65,512.36,284.76,549.75,244.49,522.43,215.73,546.88,199.91,558.38,204.22,565.57,189.84,568.45,184.09,575.64,172.58,578.52,145.26,567.01,117.93,551.19,133.75,532.49]], "num_keypoints": 10, "area": 47803.27955, "iscrowd": 0, "keypoints": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,142,309,1,177,320,2,191,398,2,237,317,2,233,426,2,306,233,2,92,452,2,123,468,2,0,0,0,251,469,2,0,0,0,162,551,2], "image_id": 425226,"bbox": [73.35,206.02,300.58,372.5],"category_id": 1, "id": 183126 }, 

3,categories字段

最后,對於每一個category結構體,相比Object Instance中的category新增了2個額外的字段,keypoints是一個長度為k的數組,包含了每個關鍵點的名字;skeleton定義了各個關鍵點之間的連接性(比如人的左手腕和左肘就是連接的,但是左手腕和右手腕就不是)。目前,COCO的keypoints只標注了person category (分類為人)。

定義如下:

{ "id": int, "name": str, "supercategory": str, "keypoints": [str], "skeleton": [edge] } 

從person_keypoints_val2017.json文件中摘出一個category的實例如下:

{ "supercategory": "person", "id": 1, "name": "person", "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"], "skeleton": [[16,14],[14,12],[17,15],[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]] }




參考文獻:https://blog.csdn.net/gqixf/article/details/79280224

https://blog.csdn.net/gqixf/article/details/79280224


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM