monoloco/monoloco/utils/misc.py
Lorenzo Bertoni 9eafb1414e
Stereo Baselines (#11)
* skeleton stereo_baselines

* skeleton stereo_baselines (2)

* combine stereo evaluation

* fix stereo bugs

* refactor for multiple baselines

* temp

* temp

* fix disparity bug

* fix bug on avg_disparity

* cleaning

* cleaning

* cleaning (2)

* methods_stereo variable

* refactor evaluation

* cleaning

* create general mode to save txt files

* temp

* fix bug in compare errors

* fix dicionary of iou

* unify parser

* skeleton pose baseline

* update visualization names

* refactor for modularity

* multiple baselines running

* update printing information

* add evaluation files filter

* refactor skeleton

* refactor skeleton(2)

* cleaning

* working refactor without reid

* add features and keypoints distinction

* working reid representation

* refactor to matricial form

* while version

* new for version

* correct bug in updated for version

* fix bugs in while version and reformat

* add new counting

* fix bug on counting

* fix bug on evaluation

* pylint cleaning

* build new version

* change test setting to allow flexibility on different platforms

* pylint clening(2)
2019-08-23 14:07:09 +02:00

48 lines
1.4 KiB
Python

import json
def append_cluster(dic_jo, phase, xx, dd, kps):
"""Append the annotation based on its distance"""
if dd <= 10:
dic_jo[phase]['clst']['10']['kps'].append(kps)
dic_jo[phase]['clst']['10']['X'].append(xx)
dic_jo[phase]['clst']['10']['Y'].append([dd])
elif dd <= 20:
dic_jo[phase]['clst']['20']['kps'].append(kps)
dic_jo[phase]['clst']['20']['X'].append(xx)
dic_jo[phase]['clst']['20']['Y'].append([dd])
elif dd <= 30:
dic_jo[phase]['clst']['30']['kps'].append(kps)
dic_jo[phase]['clst']['30']['X'].append(xx)
dic_jo[phase]['clst']['30']['Y'].append([dd])
else:
dic_jo[phase]['clst']['>30']['kps'].append(kps)
dic_jo[phase]['clst']['>30']['X'].append(xx)
dic_jo[phase]['clst']['>30']['Y'].append([dd])
def get_task_error(dd):
"""Get target error not knowing the gender, modeled through a Gaussian Mixure model"""
mm = 0.046
return dd * mm
def get_pixel_error(dd_gt, zz_gt):
"""calculate error in stereo distance due to 1 pixel mismatch (function of depth)"""
disp = 0.54 * 721 / zz_gt
delta_z = zz_gt - 0.54 * 721 / (disp - 1)
return dd_gt + delta_z
def open_annotations(path_ann):
try:
with open(path_ann, 'r') as f:
annotations = json.load(f)
except FileNotFoundError:
annotations = []
return annotations