Files
JustTwirk/moves_dump.py
2025-12-08 20:25:20 +01:00

63 lines
1.5 KiB
Python

import json
import pickle
import time
import cv2
import numpy as np
import utils
from draw import draw_new
# moves = {}
better_moves = {}
with open('replay_tpose.pkl', 'rb') as f: # 'rb' = read binary
moves = pickle.load(f)
movesCopy = {}
for move in moves:
# listx = moves[move].tolist()
# print(type(listx))
# if type(listx) != list:
# listx = listx.tolist()
movesCopy[move.replace(".jpg", "")] = moves[move].tolist()
with open("plikv10.json", "w", encoding="utf-8") as f:
json.dump(movesCopy, f)
exit(1)
startValue = moves[0][0]
totalCount = len(moves)
for i, move in enumerate(moves):
moves[i] = (move[0] - startValue, move[1], move[2])
# left_hip = move[2][11] # Left Hip
# right_hip = move[2][12] # Right Hip
# center = (left_hip + right_hip) / 2
#
# # Normalizacja względem środka ciała
# normalized_keypoints = move[2] - center
#
# better_moves[round((move[0] - startValue) * 1000)] = normalized_keypoints.tolist()
#
# # scale = utils.distance(move[2][11], move[2][12])
# # print(scale)
# draw = normalized_keypoints + 200
# Do rysowania (np. przesunięcie na ekran)
draw = utils.normalize(move[2])
better_moves[round((move[0] - startValue) * 1000)] = draw.tolist()
# cv2.imshow('you', draw_new(draw))
# cv2.waitKey(1)
# time.sleep(0.1)
with open("plik-234.json", "w", encoding="utf-8") as f:
json.dump(better_moves, f)