Comments and readme update

This commit is contained in:
2022-02-08 20:02:14 +07:00
parent c6c2334d05
commit f73685fa55
6 changed files with 141 additions and 110 deletions

View File

@@ -51,50 +51,54 @@ mp_cl = hpe_mp_class()
while True:
# Reading frame
success, img = cap.read()
if success:
# Image preprocessing
if crop != 1.0:
img = cv2.resize(img, (frame_width, frame_height))
# Image preprocessing
if crop != 1.0:
img = cv2.resize(img, (frame_width, frame_height))
# # Mediapipe
mp_cl.process(img, scale_pose=scale_pose)
mp_cl.show(img)
# Mediapipe
mp_cl.process(img, scale_pose=scale_pose)
mp_cl.show(img)
# FPS
cTime = time.time()
fps = 1. / (cTime - pTime)
pTime = cTime
# FPS
cTime = time.time()
fps = 1. / (cTime - pTime)
pTime = cTime
# Showing
if show_image:
if mirror_image:
img = cv2.flip(img, 1) # mirror
cv2.putText(img, str(int(fps)), (22, 32), cv2.FONT_HERSHEY_COMPLEX, 1, (0, 0, 0), 2)
cv2.putText(img, str(int(fps)), (20, 30), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
cv2.imshow("Main", img)
# Showing
if show_image:
if mirror_image:
img = cv2.flip(img, 1) # mirror
cv2.putText(img, str(int(fps)), (22, 32), cv2.FONT_HERSHEY_COMPLEX, 1, (0, 0, 0), 2)
cv2.putText(img, str(int(fps)), (20, 30), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
cv2.imshow("Main", img)
# Output
if output_method == 'file':
# JSON
res = mp_cl.getJSON(apose=apose, world=world, old_world=old_world)
with open('hierarchy_data.json', 'w', encoding='utf-8') as f:
json.dump(res, f, ensure_ascii=False, indent=4)
# Output
if output_method == 'file':
# JSON
res = mp_cl.getJSON(apose=apose, world=world, old_world=old_world)
with open('hierarchy_data.json', 'w', encoding='utf-8') as f:
json.dump(res, f, ensure_ascii=False, indent=4)
else:
# OSC
res = mp_cl.getJSON(apose=apose, world=world, old_world=old_world) # convering model
res_list = []
# for values parsing on UE4
for val in res.keys():
stroka = str(val)
for val2 in res[val]:
if val2 == 'visible':
stroka += " " + str(val2) + " " + str(res[val][val2])
# res_list.append(str(val) + " " + str(val2) + " " + str(res[val][val2]))
else:
for val3 in res[val][val2]:
stroka += " " + str(val2) + "_" + str(val3) + " " + str(res[val][val2][val3])
# res_list.append(str(val) + " " + str(val2) + " " + str(val3) + " " + str(res[val][val2][val3]))
res_list.append(stroka)
# message sending
client.send_message(osc_message_address, res_list)
else:
# OSC
res = mp_cl.getJSON(apose=apose, world=world, old_world=old_world)
res_list = []
for val in res.keys():
stroka = str(val)
for val2 in res[val]:
if val2 == 'visible':
stroka += " " + str(val2) + " " + str(res[val][val2])
# res_list.append(str(val) + " " + str(val2) + " " + str(res[val][val2]))
else:
for val3 in res[val][val2]:
stroka += " " + str(val2) + "_" + str(val3) + " " + str(res[val][val2][val3])
# res_list.append(str(val) + " " + str(val2) + " " + str(val3) + " " + str(res[val][val2][val3]))
res_list.append(stroka)
client.send_message(osc_message_address, res_list)
print("Frame not success read")
# Interface
key = cv2.waitKey(1)