Skip to content

Commit

Permalink
Fix bug in Edge Duo mode when using the same image when inferring the…
Browse files Browse the repository at this point in the history
… landmarks of the 2 hands

(the same image wasn't used when it should)
  • Loading branch information
geaxgx committed May 15, 2022
1 parent c803ad3 commit 87111c1
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion HandTracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,4 +658,4 @@ def exit(self):
if self.use_lm and self.nb_lm_inferences:
print(f"Hand landmark round trip : {self.glob_lm_rtrip_time/self.nb_lm_inferences*1000:.1f} ms")
if self.xyz:
print(f"Spatial location requests round trip : {self.glob_spatial_rtrip_time/self.nb_anchors*1000:.1f} ms")
print(f"Spatial location requests round trip : {self.glob_spatial_rtrip_time/self.nb_spatial_requests*1000:.1f} ms")
2 changes: 1 addition & 1 deletion HandTrackerBpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,4 +844,4 @@ def exit(self):
if self.use_lm and self.nb_lm_inferences:
print(f"Hand landmark round trip : {self.glob_lm_rtrip_time/self.nb_frames_lm_inference*1000:.1f} ms")
if self.xyz:
print(f"Spatial location requests round trip : {self.glob_spatial_rtrip_time/self.nb_anchors*1000:.1f} ms")
print(f"Spatial location requests round trip : {self.glob_spatial_rtrip_time/self.nb_spatial_requests*1000:.1f} ms")
8 changes: 5 additions & 3 deletions template_manager_script_bpf_duo.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ def normalize_radians(angle):

nb_hands_in_previous_frame = 0
detected_hands = []
reuse_prev_image = False

while True:

Expand Down Expand Up @@ -479,11 +480,13 @@ def normalize_radians(angle):
cfg.setCropRotatedRect(rr, True)
cfg.setResize(lm_input_size, lm_input_size)
${_IF_USE_SAME_IMAGE}
cfg.setReusePreviousImage(False if i == last_hand else True)
reuse_prev_image = True if len(detected_hands) > 1 and i == last_hand else False
cfg.setReusePreviousImage(reuse_prev_image)
${_IF_USE_SAME_IMAGE}
node.io['pre_lm_manip_cfg'].send(cfg)
nb_lm_inf += 1
${_TRACE2} ("Manager sent config to pre_lm manip")
${_TRACE2} (f"Manager sent config to pre_lm manip (reuse previous frame = {reuse_prev_image})")


hand_landmarks = dict([("lm_score", []), ("handedness", []), ("rotation", []),
("rect_center_x", []), ("rect_center_y", []), ("rect_size", []), ("rrn_lms", []), ('sqn_lms', []),
Expand Down Expand Up @@ -519,7 +522,6 @@ def normalize_radians(angle):
xyz_zone = 0
# Query xyz
${_IF_XYZ}
cfg = SpatialLocationCalculatorConfig()
conf_data = SpatialLocationCalculatorConfigData()
conf_data.depthThresholds.lowerThreshold = 100
conf_data.depthThresholds.upperThreshold = 10000
Expand Down
1 change: 0 additions & 1 deletion template_manager_script_bpf_solo.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ def normalize_radians(angle):
xyz_zone = 0
# Query xyz
${_IF_XYZ}
cfg = SpatialLocationCalculatorConfig()
conf_data = SpatialLocationCalculatorConfigData()
conf_data.depthThresholds.lowerThreshold = 100
conf_data.depthThresholds.upperThreshold = 10000
Expand Down
7 changes: 4 additions & 3 deletions template_manager_script_duo.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def normalize_radians(angle):

detected_hands = []

reuse_prev_image = False


while True:
Expand Down Expand Up @@ -165,11 +166,12 @@ def normalize_radians(angle):
cfg.setCropRotatedRect(rr, True)
cfg.setResize(lm_input_size, lm_input_size)
${_IF_USE_SAME_IMAGE}
cfg.setReusePreviousImage(False if i == last_hand else True)
reuse_prev_image = True if len(detected_hands) > 1 and i == last_hand else False
cfg.setReusePreviousImage(reuse_prev_image)
${_IF_USE_SAME_IMAGE}
node.io['pre_lm_manip_cfg'].send(cfg)
nb_lm_inf += 1
${_TRACE2} ("Manager sent config to pre_lm manip")
${_TRACE2} (f"Manager sent config to pre_lm manip (reuse previous frame = {reuse_prev_image})")

hand_landmarks = dict([("lm_score", []), ("handedness", []), ("rotation", []),
("rect_center_x", []), ("rect_center_y", []), ("rect_size", []), ("rrn_lms", []), ('sqn_lms', []),
Expand Down Expand Up @@ -207,7 +209,6 @@ def normalize_radians(angle):
xyz_zone = 0
# Query xyz
${_IF_XYZ}
cfg = SpatialLocationCalculatorConfig()
conf_data = SpatialLocationCalculatorConfigData()
conf_data.depthThresholds.lowerThreshold = 100
conf_data.depthThresholds.upperThreshold = 10000
Expand Down
1 change: 0 additions & 1 deletion template_manager_script_solo.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ def normalize_radians(angle):
xyz_zone = 0
# Query xyz
${_IF_XYZ}
cfg = SpatialLocationCalculatorConfig()
conf_data = SpatialLocationCalculatorConfigData()
conf_data.depthThresholds.lowerThreshold = 100
conf_data.depthThresholds.upperThreshold = 10000
Expand Down

0 comments on commit 87111c1

Please sign in to comment.