This commit is contained in:
Tulis
2025-09-10 19:51:05 +02:00
parent 5560f6b2e6
commit 5ab222aee3
4 changed files with 154 additions and 208 deletions

2
.idea/vcs.xml generated
View File

@ -2,7 +2,5 @@
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/mmdetection" vcs="Git" />
<mapping directory="$PROJECT_DIR$/mmpose" vcs="Git" />
</component> </component>
</project> </project>

112
.idea/workspace.xml generated
View File

@ -4,29 +4,11 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="441a4e7b-d6ce-44cb-92c5-2f22f1b1874f" name="Changes" comment="initial commit"> <list default="true" id="441a4e7b-d6ce-44cb-92c5-2f22f1b1874f" name="Changes" comment="working">
<change afterPath="$PROJECT_DIR$/.gitattributes" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/calculate.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/draw.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/filter.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/ploting.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/receive_images.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/receiver.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/sender.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/utils.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/video_methods.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/JustTwerk.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/JustTwerk.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/02_whole_body_from_image.py" beforeDir="false" /> <change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/body3d.py" beforeDir="false" /> <change beforePath="$PROJECT_DIR$/utils.py" beforeDir="false" afterPath="$PROJECT_DIR$/utils.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/hrnet_w48_coco_256x192-b9e0b3ab_20200708.pth" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/humanPoseDetection.ipynb" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/rtmdet_m_8xb32-100e_coco-obj365-person-235e8209.pth" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/rtmpose-m_simcc-body7_pt-body7_420e-256x192-e48f03d0_20230504.pth" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/test.py" beforeDir="false" afterPath="$PROJECT_DIR$/test.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/videopose_h36m_243frames_fullconv_supervised_cpn_ft-88f5abbb_20210527.pth" beforeDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -52,45 +34,46 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"ModuleVcsDetector.initialDetectionPerformed": "true", &quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
"Python.02_whole_body_from_image.executor": "Run", &quot;Python.02_whole_body_from_image.executor&quot;: &quot;Run&quot;,
"Python.3d.executor": "Run", &quot;Python.3d.executor&quot;: &quot;Run&quot;,
"Python.body3d.executor": "Run", &quot;Python.body3d.executor&quot;: &quot;Run&quot;,
"Python.body3d_pose_lifter_demo.executor": "Run", &quot;Python.body3d_pose_lifter_demo.executor&quot;: &quot;Run&quot;,
"Python.calculate.executor": "Run", &quot;Python.calculate.executor&quot;: &quot;Run&quot;,
"Python.checkpoint.executor": "Run", &quot;Python.checkpoint.executor&quot;: &quot;Run&quot;,
"Python.draw.executor": "Run", &quot;Python.draw.executor&quot;: &quot;Run&quot;,
"Python.filter.executor": "Run", &quot;Python.filter.executor&quot;: &quot;Run&quot;,
"Python.is_torch.executor": "Run", &quot;Python.is_torch.executor&quot;: &quot;Run&quot;,
"Python.local_visualizer_3d.executor": "Run", &quot;Python.local_visualizer_3d.executor&quot;: &quot;Run&quot;,
"Python.openpose.executor": "Run", &quot;Python.main.executor&quot;: &quot;Run&quot;,
"Python.receive_images.executor": "Run", &quot;Python.openpose.executor&quot;: &quot;Run&quot;,
"Python.receiver.executor": "Run", &quot;Python.receive_images.executor&quot;: &quot;Run&quot;,
"Python.sender.executor": "Run", &quot;Python.receiver.executor&quot;: &quot;Run&quot;,
"Python.test.executor": "Run", &quot;Python.sender.executor&quot;: &quot;Run&quot;,
"Python.ultralytics-test.executor": "Run", &quot;Python.test.executor&quot;: &quot;Run&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;Python.ultralytics-test.executor&quot;: &quot;Run&quot;,
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"RunOnceActivity.git.unshallow": "true", &quot;RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252&quot;: &quot;true&quot;,
"git-widget-placeholder": "main", &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
"last_opened_file_path": "C:/Users/Kajetan/PycharmProjects/JustTwerk", &quot;git-widget-placeholder&quot;: &quot;main&quot;,
"node.js.detected.package.eslint": "true", &quot;last_opened_file_path&quot;: &quot;C:/Users/Kajetan/PycharmProjects/JustTwerk&quot;,
"node.js.detected.package.tslint": "true", &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
"node.js.selected.package.eslint": "(autodetect)", &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
"node.js.selected.package.tslint": "(autodetect)", &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
"nodejs_package_manager_path": "npm", &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
"settings.editor.selected.configurable": "configurable.group.editor", &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
"vue.rearranger.settings.migration": "true" &quot;settings.editor.selected.configurable&quot;: &quot;configurable.group.editor&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
} }
}]]></component> }</component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\Kajetan\PycharmProjects\JustTwerk" /> <recent name="C:\Users\Kajetan\PycharmProjects\JustTwerk" />
</key> </key>
</component> </component>
<component name="RunManager"> <component name="RunManager" selected="Python.draw">
<configuration name="draw" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="draw" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="JustTwerk" /> <module name="JustTwerk" />
<option name="ENV_FILES" value="" /> <option name="ENV_FILES" value="" />
@ -166,7 +149,10 @@
<workItem from="1755891319108" duration="33842000" /> <workItem from="1755891319108" duration="33842000" />
<workItem from="1755974689137" duration="258000" /> <workItem from="1755974689137" duration="258000" />
<workItem from="1755974961407" duration="19035000" /> <workItem from="1755974961407" duration="19035000" />
<workItem from="1756053672258" duration="10010000" /> <workItem from="1756053672258" duration="16821000" />
<workItem from="1756216787734" duration="969000" />
<workItem from="1756632365037" duration="26000" />
<workItem from="1757522631129" duration="1771000" />
</task> </task>
<task id="LOCAL-00001" summary="initial commit"> <task id="LOCAL-00001" summary="initial commit">
<option name="closed" value="true" /> <option name="closed" value="true" />
@ -176,7 +162,15 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1755963464017</updated> <updated>1755963464017</updated>
</task> </task>
<option name="localTasksCounter" value="2" /> <task id="LOCAL-00002" summary="working">
<option name="closed" value="true" />
<created>1756143470328</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1756143470328</updated>
</task>
<option name="localTasksCounter" value="3" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -184,9 +178,11 @@
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value="initial commit" /> <MESSAGE value="initial commit" />
<option name="LAST_COMMIT_MESSAGE" value="initial commit" /> <MESSAGE value="working" />
<option name="LAST_COMMIT_MESSAGE" value="working" />
</component> </component>
<component name="com.intellij.coverage.CoverageDataManagerImpl"> <component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/JustTwerk$main.coverage" NAME="main Coverage Results" MODIFIED="1756143599014" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/JustTwerk$receiver.coverage" NAME="receiver Coverage Results" MODIFIED="1756142451233" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" /> <SUITE FILE_PATH="coverage/JustTwerk$receiver.coverage" NAME="receiver Coverage Results" MODIFIED="1756142451233" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/JustTwerk$filter.coverage" NAME="filter Coverage Results" MODIFIED="1755972211046" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" /> <SUITE FILE_PATH="coverage/JustTwerk$filter.coverage" NAME="filter Coverage Results" MODIFIED="1755972211046" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/JustTwerk$body3d_pose_lifter_demo.coverage" NAME="body3d_pose_lifter_demo Coverage Results" MODIFIED="1755937235510" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/mmpose/demo" /> <SUITE FILE_PATH="coverage/JustTwerk$body3d_pose_lifter_demo.coverage" NAME="body3d_pose_lifter_demo Coverage Results" MODIFIED="1755937235510" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/mmpose/demo" />

244
main.py
View File

@ -1,52 +1,23 @@
import pickle import pickle
import sys import sys
import regex as re
import numpy as np
from ultralytics import YOLO from ultralytics import YOLO
import cv2 import cv2
import time import time
from calculate import normalize_pose, compare_poses_boolean from calculate import normalize_pose, compare_poses_boolean
from draw import draw_new from draw import draw_new
from video_methods import initialize_method
model = YOLO("yolo11x-pose.pt") model = YOLO("yolo11x-pose.pt")
if len(sys.argv) == 1: if len(sys.argv) == 2:
method = sys.argv[1] method_type = sys.argv[1]
else: else:
print("Podaj argument 'cam', albo 'network'.") print("Podaj argument 'cam', albo 'net'.")
exit(1) exit(1)
cap = cv2.VideoCapture(0) method = initialize_method(method_type)
if not cap.isOpened():
print("Nie można otworzyć kamerki")
exit(1)
last_time = time.time()
startTime = time.time()
stage = 0
pose = normalize_pose(np.array([[ 353.17, 107.28],
[ 363.3, 96.435],
[ 347.1, 98.647],
[ 390.12, 99.096],
[ 346.09, 103.63],
[ 425.77, 149.95],
[ 327.92, 153.12],
[ 495.16, 169.82],
[ 260.86, 166.3],
[ 565.53, 182.68],
[ 192.34, 170.58],
[ 393.83, 316.99],
[ 337.05, 316.41],
[ 388.36, 433.37],
[ 333.88, 431.89],
[ 383.58, 479.16],
[ 330.89, 480]]))
do_pose_shot = False do_pose_shot = False
@ -56,149 +27,126 @@ def click_event(event, x, y, flags, param):
if event == cv2.EVENT_LBUTTONDOWN: # lewy przycisk myszy if event == cv2.EVENT_LBUTTONDOWN: # lewy przycisk myszy
do_pose_shot = not do_pose_shot do_pose_shot = not do_pose_shot
currTimeIndex = 0 def main():
currIndex = None last_time = time.time()
currMove = None
currStatus = "Zacznij tanczyc"
mehCount = 0 currTimeIndex = 0
goodCount = 0 currIndex = None
failCount = 0 currMove = None
failRate = 2 currStatus = "Zacznij tanczyc"
def wczytaj_dane_z_txt(sciezka): mehCount = 0
wynik = [] goodCount = 0
with open(sciezka, "r") as f: failCount = 0
zawartosc = f.read() failRate = 2
# Znajdź wszystkie krotki w formacie (float, array([...])) moves = []
pattern = re.compile(r"\(([^,]+),\s*array\((\[.*?\]),\s*dtype=float32\)\)")
matches = pattern.findall(zawartosc)
for m in matches: with open('moves.pkl', 'rb') as f: # 'rb' = read binary
liczba = float(m[0]) moves = pickle.load(f)
tablica = np.array(eval(m[1]), dtype=np.float32)
wynik.append((liczba, tablica))
return wynik startValue = moves[0][0]
totalCount = len(moves)
moves = [] for i, move in enumerate(moves):
moves[i] = (move[0] - startValue, move[1], move[2])
with open('moves.pkl', 'rb') as f: # 'rb' = read binary while True:
moves = pickle.load(f) frame = method.receive_frame()
startValue = moves[0][0] frame = cv2.flip(frame, 1)
totalCount = len(moves)
for i, move in enumerate(moves): results = model(frame, verbose=False)
moves[i] = (move[0] - startValue, move[1], move[2])
def find_closest(target): current_time = time.time()
global moves delta = current_time - last_time
return min(moves, key=lambda t: abs(t[0] - target)) last_time = current_time
while True: fps = 1 / delta if delta > 0 else float('inf')
ret, frame = cap.read() # print(f"\rDelta: {delta:.4f}s, FPS: {fps:.2f}", end="")
frame = cv2.flip(frame, 1)
results = model(frame, verbose=False) for result in results:
kpts = result.keypoints.data[0] if len(result.keypoints.data) else None
current_time = time.time() if kpts is None:
delta = current_time - last_time continue
last_time = current_time
fps = 1 / delta if delta > 0 else float('inf') img = frame
# print(f"\rDelta: {delta:.4f}s, FPS: {fps:.2f}", end="")
for result in results: normalized = normalize_pose(result.keypoints.xy.cpu().numpy()[0])
kpts = result.keypoints.data[0] if len(result.keypoints.data) else None cv2.imshow('you', draw_new(result.keypoints.xy.cpu()[0]))
if kpts is None: if currTimeIndex != 0 and moves.index(find_closest(time.time() - currTimeIndex)) == len(moves) - 1:
continue mehCount = totalCount - failCount - goodCount
img = frame print(
f"PODSUMOWANIE: FAIL {failCount} MEH: {mehCount} PERFECT: {goodCount} PERCENTAGE: {(goodCount + (0.95 * mehCount)) / totalCount * 100}%")
exit(1)
normalized = normalize_pose(result.keypoints.xy.cpu().numpy()[0]) if currMove is None:
cv2.imshow('you', draw_new(result.keypoints.xy.cpu()[0])) if compare_poses_boolean(moves[0][1], normalized):
currIndex = 1
currTimeIndex = time.time()
deltaTime = time.time()
currStatus = f"Zaczoles tanczyc {currIndex}"
currMove = moves[0]
if currTimeIndex != 0 and moves.index(find_closest(time.time() - currTimeIndex)) == len(moves) - 1: # thread = Thread(target=print_animation, args=(moves, False))
mehCount = totalCount - failCount - goodCount # thread.start()
else:
changed = False
print(f"PODSUMOWANIE: FAIL {failCount} MEH: {mehCount} PERFECT: {goodCount} PERCENTAGE: {(goodCount + (0.95 * mehCount)) / totalCount * 100}%") closest = find_closest(time.time() - currTimeIndex)
exit(1) cv2.imshow('Dots', draw_new(closest[2]))
if currMove is None: if abs((time.time() - currTimeIndex) - moves[currIndex][0]) > failRate:
if compare_poses_boolean(moves[0][1], normalized): currStatus = f"FAIL!"
currIndex = 1 failCount += 1
currTimeIndex = time.time()
deltaTime = time.time()
currStatus = f"Zaczoles tanczyc {currIndex}"
currMove = moves[0]
# thread = Thread(target=print_animation, args=(moves, False)) if compare_poses_boolean(closest[1], normalized):
# thread.start() # delays += (time.time() - deltaTime - moves[0][0]) * 1000
else: # delaysCount += 1
changed = False
closest = find_closest(time.time() - currTimeIndex) currStatus = f"SUPER! {currIndex} Zostalo {len(moves)} Delay {(time.time() - currTimeIndex - closest[0]) / 1000}ms"
cv2.imshow('Dots', draw_new(closest[2])) deltaTime = time.time()
if abs((time.time() - currTimeIndex) - moves[currIndex][0]) > failRate: currIndex = moves.index(closest) + 1
currStatus = f"FAIL!" goodCount += 1
failCount += 1 changed = True
if compare_poses_boolean(closest[1], normalized): if not changed and compare_poses_boolean(moves[currIndex][1], normalized):
# delays += (time.time() - deltaTime - moves[0][0]) * 1000 # delays += (time.time() - deltaTime - moves[0][0]) * 1000
# delaysCount += 1 # delaysCount += 1
currStatus = f"SUPER! {currIndex} Zostalo {len(moves)} Delay {(time.time() - currTimeIndex - closest[0]) / 1000}ms" currStatus = f"SUPER! {currIndex} Zostalo {len(moves)} Delay {(time.time() - currTimeIndex - closest[0]) / 1000}ms"
deltaTime = time.time() deltaTime = time.time()
currIndex = moves.index(closest) + 1 changed = True
goodCount += 1
changed = True
if not changed and compare_poses_boolean(moves[currIndex][1], normalized): currIndex += 1
# delays += (time.time() - deltaTime - moves[0][0]) * 1000 goodCount += 1
# delaysCount += 1
currStatus = f"SUPER! {currIndex} Zostalo {len(moves)} Delay {(time.time() - currTimeIndex - closest[0]) / 1000}ms" # if do_pose_shot:
deltaTime = time.time() # moves.append((time.time() - startTime, normalize_pose(result.keypoints.xy.cpu().numpy()[0]), result.keypoints.xy.cpu()[0]))
# elif len(moves) != 0:
# with open('moves.pkl', 'wb') as f: # 'wb' = write binary
# pickle.dump(moves, f)
#
# exit(1)
changed = True cv2.putText(
img, # obraz
currStatus, # tekst
(50, 100), # pozycja (x, y) lewego dolnego rogu tekstu
cv2.FONT_HERSHEY_SIMPLEX, # czcionka
1, # rozmiar (skalowanie)
(0, 0, 255), # kolor (BGR) - tutaj czerwony
2, # grubość linii
cv2.LINE_AA # typ antyaliasingu
)
currIndex += 1 cv2.imshow('Klatka z kamerki', img)
goodCount += 1 cv2.setMouseCallback('Klatka z kamerki', click_event)
cv2.waitKey(1) # Czekaj na naciśnięcie klawisza
# if do_pose_shot: main()
# moves.append((time.time() - startTime, normalize_pose(result.keypoints.xy.cpu().numpy()[0]), result.keypoints.xy.cpu()[0]))
# elif len(moves) != 0:
# with open('moves.pkl', 'wb') as f: # 'wb' = write binary
# pickle.dump(moves, f)
#
# exit(1)
cv2.putText(
img, # obraz
currStatus, # tekst
(50, 100), # pozycja (x, y) lewego dolnego rogu tekstu
cv2.FONT_HERSHEY_SIMPLEX, # czcionka
1, # rozmiar (skalowanie)
(0, 0, 255), # kolor (BGR) - tutaj czerwony
2, # grubość linii
cv2.LINE_AA # typ antyaliasingu
)
cv2.imshow('Klatka z kamerki', img)
cv2.setMouseCallback('Klatka z kamerki', click_event)
cv2.waitKey(1) # Czekaj na naciśnięcie klawisza
# Access the results
for result in results:
annotated_frame = result.plot() # zwraca obraz z naniesionymi keypoints
# Wyświetlenie obrazu przy użyciu OpenCV
cv2.imshow("Pose", annotated_frame)
cv2.waitKey(0)
cv2.destroyAllWindows()

View File

@ -10,6 +10,10 @@ def recvall(sock, n):
data += packet data += packet
return data return data
def find_closest(target):
global moves
return min(moves, key=lambda t: abs(t[0] - target))
def resize_with_padding(image, target_size=(640, 640)): def resize_with_padding(image, target_size=(640, 640)):
h, w = image.shape[:2] h, w = image.shape[:2]
target_w, target_h = target_size target_w, target_h = target_size