update factory_for_gt
This commit is contained in:
parent
86438189a7
commit
52f5592889
@ -7,7 +7,7 @@ from openpifpaf import show
|
|||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
def factory_for_gt(image, name=None, path_gt=None):
|
def factory_for_gt(im_size, name=None, path_gt=None):
|
||||||
"""Look for ground-truth annotations file and define calibration matrix based on image size """
|
"""Look for ground-truth annotations file and define calibration matrix based on image size """
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -24,10 +24,10 @@ def factory_for_gt(image, name=None, path_gt=None):
|
|||||||
print("Monoloco: matched ground-truth file!\n" + '-' * 120)
|
print("Monoloco: matched ground-truth file!\n" + '-' * 120)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
dic_gt = None
|
dic_gt = None
|
||||||
x_factor = image.size[0] / 1600
|
x_factor = im_size[0] / 1600
|
||||||
y_factor = image.size[1] / 900
|
y_factor = im_size[1] / 900
|
||||||
pixel_factor = (x_factor + y_factor) / 2
|
pixel_factor = (x_factor + y_factor) / 2
|
||||||
if image.size[0] / image.size[1] > 2.5:
|
if im_size[0] / im_size[1] > 2.5:
|
||||||
kk = [[718.3351, 0., 600.3891], [0., 718.3351, 181.5122], [0., 0., 1.]] # Kitti calibration
|
kk = [[718.3351, 0., 600.3891], [0., 718.3351, 181.5122], [0., 0., 1.]] # Kitti calibration
|
||||||
else:
|
else:
|
||||||
kk = [[1266.4 * pixel_factor, 0., 816.27 * x_factor],
|
kk = [[1266.4 * pixel_factor, 0., 816.27 * x_factor],
|
||||||
@ -46,7 +46,7 @@ def factory_outputs(args, images_outputs, output_path, pifpaf_outputs, monoloco_
|
|||||||
# Save json file
|
# Save json file
|
||||||
if 'pifpaf' in args.networks:
|
if 'pifpaf' in args.networks:
|
||||||
|
|
||||||
keypoint_sets, pifpaf_out, scores = pifpaf_outputs[:]
|
keypoint_sets, scores, pifpaf_out = pifpaf_outputs[:]
|
||||||
|
|
||||||
# Visualizer
|
# Visualizer
|
||||||
keypoint_painter = show.KeypointPainter(show_box=True)
|
keypoint_painter = show.KeypointPainter(show_box=True)
|
||||||
@ -85,7 +85,7 @@ def factory_outputs(args, images_outputs, output_path, pifpaf_outputs, monoloco_
|
|||||||
printer.print()
|
printer.print()
|
||||||
|
|
||||||
if 'json' in args.output_types:
|
if 'json' in args.output_types:
|
||||||
with open(os.path.join(args.output_path + '.monoloco.json'), 'w') as ff:
|
with open(os.path.join(output_path + '.monoloco.json'), 'w') as ff:
|
||||||
json.dump(monoloco_outputs, ff)
|
json.dump(monoloco_outputs, ff)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -146,7 +146,7 @@ def predict(args):
|
|||||||
|
|
||||||
im_name = os.path.basename(image_path)
|
im_name = os.path.basename(image_path)
|
||||||
|
|
||||||
kk, _ = factory_for_gt(image, name=im_name, path_gt=args.path_gt)
|
kk, _ = factory_for_gt(im_size, name=im_name, path_gt=args.path_gt)
|
||||||
|
|
||||||
# Preprocess pifpaf outputs and run monoloco
|
# Preprocess pifpaf outputs and run monoloco
|
||||||
boxes, keypoints = preprocess_pif(pifpaf_out, im_size)
|
boxes, keypoints = preprocess_pif(pifpaf_out, im_size)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user