In [1]:
# import general classes
%matplotlib inline
import matplotlib.pyplot as plt

# CO_LSP API class
from CO_LSP.CO_LSP import CO_LSP

In [2]:
# path variables
## DATASET_PATH: path to the dataset with the annotations
DATASET_PATH = '../inputs/CO_LSP_train2016.json'
## IMAGES_PATH: path of the actual images of LSP
IMAGES_PATH = '/home/mronchi/Datasets/lsp/lsp_dataset/images/'

In [3]:
# create CO_LSP instance and print properties of dataset
colsp = CO_LSP(DATASET_PATH, IMAGES_PATH)

print "Annotated Keypoints:"
keypoints = colsp.get_keypoints()
for k,kpt in enumerate(keypoints):
    print "%d) %s"%(k,kpt)
    
print "\nSkeleton Structure:"
skeleton = colsp.get_skeleton()
for s,bone in enumerate(skeleton):
    print "%d) %s[%s-%s]"%(s,skeleton[s],keypoints[bone[0]],keypoints[bone[1]])
print "\n"

colsp.get_info()


Annotated Keypoints:
0) head
1) neck
2) left_shoulder
3) right_shoulder
4) left_elbow
5) right_elbow
6) left_wrist
7) right_wrist
8) left_hip
9) right_hip
10) left_knee
11) right_knee
12) left_ankle
13) right_ankle

Skeleton Structure:
0) [0, 1][head-neck]
1) [1, 2][neck-left_shoulder]
2) [1, 3][neck-right_shoulder]
3) [2, 4][left_shoulder-left_elbow]
4) [3, 5][right_shoulder-right_elbow]
5) [4, 6][left_elbow-left_wrist]
6) [5, 7][right_elbow-right_wrist]
7) [2, 8][left_shoulder-left_hip]
8) [3, 9][right_shoulder-right_hip]
9) [8, 10][left_hip-left_knee]
10) [9, 11][right_hip-right_knee]
11) [10, 12][left_knee-left_ankle]
12) [11, 13][right_knee-right_ankle]


description : This is the data release associated with the paper `A Rotation Invariant Latent Factor Model for Moveme Discovery from Static Poses`, published at ICDM 2016.
url : http://www.vision.caltech.edu/~mronchi/projects/RotationInvariantMovemes/
version : 1.0
year : 2016
contributor : Matteo Ruggero Ronchi, Joon Sik Kim and Yisong Yue
date_created : 2016-11-28 22:01:59.549435

In [4]:
# visualize CO_LSP dataset annotations
# note that annotation and image id have a 1:1 correspondence

# by quering a list of annotation ids
ann_ids = [0,1]
print "Loading [%d] annotations..."%len(ann_ids)
anns = colsp.get_anns(ann_ids)
print "Showing loaded annotations..."
colsp.show_anns(anns)

# by quering a set of properties of the images:
# - image name
img_names = ['im0003.jpg','im0004.jpg']
print "Loading annotation ids..."
ann_ids = colsp.get_ann_ids(imgs=img_names)
print "Loading [%d] annotations..."%len(ann_ids)
anns = colsp.get_anns(ann_ids)
print "Showing loaded annotations..."
colsp.show_anns(anns)

# - activity
activity_list=['baseball','soccer']
print "Loading annotation ids..."
ann_ids = colsp.get_ann_ids(activity_list=activity_list)
print "Loading [%d] annotations..."%len(ann_ids)
anns = colsp.get_anns(ann_ids)
print "Showing loaded annotations..."
colsp.show_anns(anns[135:137])

# - angle of view
a_min = 175
a_max = 210
angle_lims=[a_min,a_max]
print "Loading annotation ids..."
ann_ids = colsp.get_ann_ids(angle_lims=angle_lims)
print "Loading [%d] annotations..."%len(ann_ids)
anns = colsp.get_anns(ann_ids)
print "Showing loaded annotations..."
colsp.show_anns(anns[0:2])

# - any combination of the above
img_names = ['im0057.jpg','im0062.jpg']
activity_list=['baseball','soccer']
a_min = 175
a_max = 210
angle_lims=[a_min,a_max]
print "Loading annotation ids..."
ann_ids = colsp.get_ann_ids(imgs=img_names,activity_list=activity_list,angle_lims=angle_lims)
print "Loading [%d] annotations..."%len(ann_ids)
anns = colsp.get_anns(ann_ids)
print "Showing loaded annotations..."
colsp.show_anns(anns)


Loading [2] annotations...
Showing loaded annotations...
Loading annotation ids...
Loading [2] annotations...
Showing loaded annotations...
Loading annotation ids...
Loading [712] annotations...
Showing loaded annotations...
Loading annotation ids...
Loading [177] annotations...
Showing loaded annotations...
Loading annotation ids...
Loading [2] annotations...
Showing loaded annotations...

In [ ]: