APose and local
This commit is contained in:
@@ -15,6 +15,9 @@ logger = logging.getLogger("hpe_mp_class_logger")
|
||||
from ModelUE4 import bodyconvert
|
||||
from ModelUE4 import rhandconvert
|
||||
from ModelUE4 import lhandconvert
|
||||
from ModelUE4 import bodyaposeworld
|
||||
from ModelUE4 import bodyaposelocal
|
||||
from ModelUE4 import bodyconvertlocal
|
||||
|
||||
class hpe_mp_class():
|
||||
|
||||
@@ -40,20 +43,12 @@ class hpe_mp_class():
|
||||
self.coef = 1.0
|
||||
|
||||
try:
|
||||
self.hands = mpHands.Hands(hands_static_image_mode,
|
||||
hands_max_num_hands,
|
||||
hands_min_detection_confidence,
|
||||
hands_min_tracking_confidence)
|
||||
self.poses = mpPose.Pose(pose_static_image_mode,
|
||||
pose_upper_body_only,
|
||||
pose_smooth_landmarks,
|
||||
pose_min_detection_confidence,
|
||||
pose_min_tracking_confidence)
|
||||
self.hol = mpHolistic.Holistic(hol_static_image_mode,
|
||||
hol_upper_body_only,
|
||||
hol_smooth_landmarks,
|
||||
hol_min_detection_confidence,
|
||||
hol_min_tracking_confidence)
|
||||
self.hands = mpHands.Hands(min_detection_confidence=hands_min_detection_confidence,
|
||||
min_tracking_confidence=hands_min_tracking_confidence)
|
||||
self.poses = mpPose.Pose(min_detection_confidence=pose_min_detection_confidence,
|
||||
min_tracking_confidence=pose_min_tracking_confidence)
|
||||
self.hol = mpHolistic.Holistic(min_detection_confidence=hol_min_detection_confidence,
|
||||
min_tracking_confidence=hol_min_tracking_confidence)
|
||||
logger.info("Success initialize hpe class")
|
||||
except Exception as err:
|
||||
logger.exception("Error initialize hpe class: " + str(err))
|
||||
@@ -171,33 +166,54 @@ class hpe_mp_class():
|
||||
except Exception as err:
|
||||
logger.exception("Error scaling hpe class: " + str(err))
|
||||
|
||||
def getJSON(self):
|
||||
def getJSON(self, apose=False, world=True):
|
||||
data = {}
|
||||
try:
|
||||
if self.holistic_use:
|
||||
poseslms = {}
|
||||
maxy = 0
|
||||
if self.results_hol.pose_landmarks:
|
||||
for id, lm in enumerate(self.results_hol.pose_landmarks.landmark):
|
||||
poseslms[id] = lm
|
||||
if lm.y > maxy:
|
||||
maxy = lm.y
|
||||
if apose:
|
||||
if world:
|
||||
bodyaposeworld(data)
|
||||
else:
|
||||
bodyaposelocal(data)
|
||||
else:
|
||||
if world:
|
||||
if self.holistic_use:
|
||||
poseslms = {}
|
||||
maxy = 0
|
||||
if self.results_hol.pose_landmarks:
|
||||
for id, lm in enumerate(self.results_hol.pose_landmarks.landmark):
|
||||
poseslms[id] = lm
|
||||
if lm.y > maxy:
|
||||
maxy = lm.y
|
||||
|
||||
bodyconvert(poseslms, data, self.coef, maxy)
|
||||
bodyconvert(poseslms, data, self.coef, maxy)
|
||||
|
||||
rhandlms = {}
|
||||
if self.results_hol.right_hand_landmarks:
|
||||
for id, lm in enumerate(self.results_hol.right_hand_landmarks.landmark):
|
||||
rhandlms[id] = lm
|
||||
rhandlms = {}
|
||||
if self.results_hol.right_hand_landmarks:
|
||||
for id, lm in enumerate(self.results_hol.right_hand_landmarks.landmark):
|
||||
rhandlms[id] = lm
|
||||
|
||||
rhandconvert(rhandlms, data, self.coef)
|
||||
rhandconvert(rhandlms, data, self.coef)
|
||||
|
||||
lhandlms = {}
|
||||
if self.results_hol.left_hand_landmarks:
|
||||
for id, lm in enumerate(self.results_hol.left_hand_landmarks.landmark):
|
||||
lhandlms[id] = lm
|
||||
lhandlms = {}
|
||||
if self.results_hol.left_hand_landmarks:
|
||||
for id, lm in enumerate(self.results_hol.left_hand_landmarks.landmark):
|
||||
lhandlms[id] = lm
|
||||
|
||||
lhandconvert(lhandlms, data, self.coef)
|
||||
lhandconvert(lhandlms, data, self.coef)
|
||||
else:
|
||||
bodyaposelocal(data)
|
||||
if self.holistic_use:
|
||||
poseslms = {}
|
||||
maxy = 0
|
||||
if self.results_hol.pose_landmarks:
|
||||
for id, lm in enumerate(self.results_hol.pose_landmarks.landmark):
|
||||
poseslms[id] = lm
|
||||
if lm.y > maxy:
|
||||
maxy = lm.y
|
||||
|
||||
bodyconvert(poseslms, data, self.coef, maxy)
|
||||
|
||||
bodyconvertlocal(poseslms, data, self.coef, maxy)
|
||||
except Exception as err:
|
||||
logger.exception("Error json converting hpe class: " + str(err))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user