Skip to content

Commit af09c0a

Browse files
committed
added neck offset to inference gui
1 parent 422fd6e commit af09c0a

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

bin/inference_gui.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ def __init__(self, root, params, *args, **kwargs):
8484
frame5.pack()
8585
self.change_image_rotation_frame(frame5)
8686

87+
# neck offset
88+
89+
frame6 = tk.Frame(self.root)
90+
frame6.pack()
91+
self.change_neck_offset_frame(frame6)
92+
93+
#frametime log
8794
self.log_frametime_var = tk.BooleanVar(value=self.params.log_frametime)
8895
log_frametime_check = tk.Checkbutton(self.root, text="Log frametimes to console", variable=self.log_frametime_var, command=self.change_log_frametime)
8996
log_frametime_check.pack()
@@ -93,7 +100,23 @@ def __init__(self, root, params, *args, **kwargs):
93100

94101
#self.root.after(0, self.set_rot_y_var)
95102
#self.root.after(0, self.set_rot_x_var)
103+
104+
def change_neck_offset_frame(self,frame):
105+
tk.Label(frame, text="HMD to neck offset:", width = 20).pack(side='left')
106+
107+
text1 = tk.Entry(frame, width = 5)
108+
text1.pack(side='left')
109+
text1.insert(0, self.params.hmd_to_neck_offset[0])
110+
111+
text2 = tk.Entry(frame, width = 5)
112+
text2.pack(side='left')
113+
text2.insert(0, self.params.hmd_to_neck_offset[1])
114+
115+
text3 = tk.Entry(frame, width = 5)
116+
text3.pack(side='left')
117+
text3.insert(0, self.params.hmd_to_neck_offset[2])
96118

119+
tk.Button(frame, text='Update', command=lambda *args: self.params.change_neck_offset(float(text1.get()),float(text2.get()),float(text3.get()))).pack(side='left')
97120

98121
def change_log_frametime(self):
99122
self.params.log_frametime = self.log_frametime_var.get()

bin/init_gui.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ def getparams():
8383
maximgsize.pack()
8484
maximgsize.insert(0,param["imgsize"])
8585

86-
tk.Label(text="Offset of HMD to neck:", width = 50).pack()
87-
hmdoffsettext = tk.Entry(width = 50)
88-
hmdoffsettext.pack()
89-
hmdoffsettext.insert(0," ".join(map(str,param["neckoffset"])))
86+
if False:
87+
88+
tk.Label(text="Offset of HMD to neck:", width = 50).pack()
89+
hmdoffsettext = tk.Entry(width = 50)
90+
hmdoffsettext.pack()
91+
hmdoffsettext.insert(0," ".join(map(str,param["neckoffset"])))
9092

9193
if False:
9294
tk.Label(text="Smoothing:", width = 50).pack()
@@ -169,7 +171,7 @@ def getparams():
169171

170172
cameraid = camid.get()
171173
maximgsize = int(maximgsize.get())
172-
hmd_to_neck_offset = [float(val) for val in hmdoffsettext.get().split(" ")]
174+
#hmd_to_neck_offset = [float(val) for val in hmdoffsettext.get().split(" ")]
173175
preview_skeleton = bool(varskel.get())
174176
dont_wait_hmd = False #bool(varhmdwait.get())
175177

@@ -189,7 +191,7 @@ def getparams():
189191
param = {}
190192
param["camid"] = cameraid
191193
param["imgsize"] = maximgsize
192-
param["neckoffset"] = hmd_to_neck_offset
194+
#param["neckoffset"] = hmd_to_neck_offset
193195
param["prevskel"] = preview_skeleton
194196
param["waithmd"] = dont_wait_hmd
195197

bin/mediapipepose.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ def camera_thread_fun():
135135
model_complexity=params.model,
136136
min_detection_confidence=0.5,
137137
min_tracking_confidence=params.min_tracking_confidence,
138-
smooth_landmarks=params.smooth_landmarks)
138+
smooth_landmarks=params.smooth_landmarks,
139+
static_image_mode=False)
139140

140141

141142
def shutdown():

bin/parameters.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self) -> None:
1616
self.maximgsize = param["imgsize"] #to prevent working with huge images, images that have one axis larger than this value will be downscaled.
1717
self.cameraid = param["camid"] #to use with an usb or virtual webcam. If 0 doesnt work/opens wrong camera, try numbers 1-5 or so
1818
#cameraid = "http://192.168.1.102:8080/video" #to use ip webcam, uncomment this line and change to your ip
19-
self.hmd_to_neck_offset = param["neckoffset"] #offset of your hmd to the base of your neck, to ensure the tracking is stable even if you look around. Default is 20cm down, 10cm back.
19+
self.hmd_to_neck_offset = [0,-0.2,0.1] #offset of your hmd to the base of your neck, to ensure the tracking is stable even if you look around. Default is 20cm down, 10cm back.
2020
self.preview_skeleton = param["prevskel"] #if True, whole skeleton will appear in vr 2 meters in front of you. Good to visualize if everything is working
2121
self.dont_wait_hmd = param["waithmd"] #dont wait for movement from hmd, start inference immediately.
2222
self.rotate_image = 0 # cv2.ROTATE_90_CLOCKWISE # cv2.ROTATE_90_COUTERCLOCKWISE # cv2.ROTATE_180 # None # if you want, rotate the camera
@@ -116,6 +116,9 @@ def change_camera_latency(self, val):
116116
print(f"Changed camera latency to {val}")
117117
self.camera_latency = val
118118

119+
def change_neck_offset(self,x,y,z):
120+
print(f"Hmd to neck offset changed to: [{x},{y},{z}]")
121+
self.hmd_to_neck_offset = [x,y,z]
119122

120123
def ready2exit(self):
121124
self.exit_ready = True
@@ -143,6 +146,8 @@ def save_params(self):
143146

144147
param["flip"] = self.flip
145148

149+
param["hmd_to_neck_offset"] = self.hmd_to_neck_offset
150+
146151
print(param["roty"])
147152

148153
with open("saved_params.json", "w") as f:
@@ -172,6 +177,8 @@ def load_params(self):
172177
self.calib_tilt = param["calibtilt"]
173178
self.calib_scale = param["calibscale"]
174179

180+
self.hmd_to_neck_offset = param["hmd_to_neck_offset"]
181+
175182
self.flip = param["flip"]
176183
except:
177184
print("Save file not found, will be created after you exit the program.")

0 commit comments

Comments
 (0)