This commit is contained in:
2025-11-28 08:31:35 +00:00
parent 310997a8dd
commit 40dc5b3b59
7 changed files with 98 additions and 54 deletions

93
main.py
View File

@ -69,68 +69,71 @@ def main():
fps = 1 / delta if delta > 0 else float('inf')
# print(f"\rDelta: {delta:.4f}s, FPS: {fps:.2f}", end="")
for result in results:
kpts = result.keypoints.data[0] if len(result.keypoints.data) else None
if len(results) == 0:
continue
if kpts is None:
continue
result = results[0]
kpts = result.keypoints.data[0] if len(result.keypoints.data) else None
img = frame
if kpts is None:
continue
normalized = normalize_pose(result.keypoints.xy.cpu().numpy()[0])
img = frame
draw = utils.normalize(result.keypoints.xy.cpu().numpy()[0])
cv2.imshow('you', draw_new(draw * 100 + 100))
normalized = normalize_pose(result.keypoints.xy.cpu().numpy()[0])
if currTimeIndex != 0 and moves.index(find_closest(moves, time.time() - currTimeIndex)) == len(moves) - 1:
mehCount = totalCount - failCount - goodCount
draw = utils.normalize(result.keypoints.xy.cpu().numpy()[0])
cv2.imshow('you', draw_new(draw * 100 + 100))
print(
f"PODSUMOWANIE: FAIL {failCount} MEH: {mehCount} PERFECT: {goodCount} PERCENTAGE: {(goodCount + (0.95 * mehCount)) / totalCount * 100}%")
exit(1)
if currTimeIndex != 0 and moves.index(find_closest(moves, time.time() - currTimeIndex)) == len(moves) - 1:
mehCount = totalCount - failCount - goodCount
if currMove is None:
if compare_poses_boolean(moves[0][1], normalized):
currIndex = 1
currTimeIndex = time.time()
deltaTime = time.time()
currStatus = f"Zaczoles tanczyc {currIndex}"
currMove = moves[0]
print(
f"PODSUMOWANIE: FAIL {failCount} MEH: {mehCount} PERFECT: {goodCount} PERCENTAGE: {(goodCount + (0.95 * mehCount)) / totalCount * 100}%")
exit(1)
# thread = Thread(target=print_animation, args=(moves, False))
# thread.start()
else:
changed = False
if currMove is None:
if compare_poses_boolean(moves[0][1], normalized):
currIndex = 1
currTimeIndex = time.time()
deltaTime = time.time()
currStatus = f"Zaczoles tanczyc {currIndex}"
currMove = moves[0]
closest = find_closest(moves, time.time() - currTimeIndex)
cv2.imshow('Dots', draw_new(closest[2]))
# thread = Thread(target=print_animation, args=(moves, False))
# thread.start()
else:
changed = False
if abs((time.time() - currTimeIndex) - moves[currIndex][0]) > failRate:
currStatus = f"FAIL!"
failCount += 1
closest = find_closest(moves, time.time() - currTimeIndex)
cv2.imshow('Dots', draw_new(closest[2]))
if compare_poses_boolean(closest[1], normalized):
# delays += (time.time() - deltaTime - moves[0][0]) * 1000
# delaysCount += 1
if abs((time.time() - currTimeIndex) - moves[currIndex][0]) > failRate:
currStatus = f"FAIL!"
failCount += 1
currStatus = f"SUPER! {currIndex} Zostalo {len(moves)} Delay {(time.time() - currTimeIndex - closest[0]) / 1000}ms"
deltaTime = time.time()
if compare_poses_boolean(closest[1], normalized):
# delays += (time.time() - deltaTime - moves[0][0]) * 1000
# delaysCount += 1
currIndex = moves.index(closest) + 1
goodCount += 1
changed = True
currStatus = f"SUPER! {currIndex} Zostalo {len(moves)} Delay {(time.time() - currTimeIndex - closest[0]) / 1000}ms"
deltaTime = time.time()
if not changed and compare_poses_boolean(moves[currIndex][1], normalized):
# delays += (time.time() - deltaTime - moves[0][0]) * 1000
# delaysCount += 1
currIndex = moves.index(closest) + 1
goodCount += 1
changed = True
currStatus = f"SUPER! {currIndex} Zostalo {len(moves)} Delay {(time.time() - currTimeIndex - closest[0]) / 1000}ms"
deltaTime = time.time()
if not changed and compare_poses_boolean(moves[currIndex][1], normalized):
# delays += (time.time() - deltaTime - moves[0][0]) * 1000
# delaysCount += 1
changed = True
currStatus = f"SUPER! {currIndex} Zostalo {len(moves)} Delay {(time.time() - currTimeIndex - closest[0]) / 1000}ms"
deltaTime = time.time()
currIndex += 1
goodCount += 1
changed = True
currIndex += 1
goodCount += 1
# if do_pose_shot:
# moves.append((time.time() - startTime, normalize_pose(result.keypoints.xy.cpu().numpy()[0]), result.keypoints.xy.cpu()[0]))