Converting float to avoid error, refer to code:
..
import json
face_dict = {'x1': 240.54083251953125, 'y1': 470.02429199218744, 'x2': 479.535400390625, 'y2': 655.3250732421875, 'LeyeX': 382.76947021484375, 'LeyeY': 538.7545166015624, 'ReyeX': 383.48541259765625, 'ReyeY': 621.1448364257811, 'NoseX': 332.7269287109375, 'NoseY': 590.6889648437499, 'LlipsX': 300.84881591796875, 'LlipsY': 542.9485473632811, 'RlipsX': 301.3223876953125, 'RlipsY': 615.5052490234374, 'conf': 0.9999992}
data_convert = {k:float(v) for k,v in face_dict.items()}
with open('./data_convert.json', 'w') as fp:
json.dump(data_convert, fp, indent=5)
..
Another solution is:
..
with open('./data_convert.json', 'w') as fp:
json.dump(str(face_dict), fp, indent=5)
..
But in this case, json is saved as string.
Thank you.
www.marearts.com
No comments:
Post a Comment