Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
18d4839
new分支:1.添加.gitignore忽略Lib目录 2.修改main.py优化无人机控制逻辑
xiaoshiyuan888 Dec 18, 2025
99c7bf4
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 18, 2025
dd54e83
改进无人机手势控制系统,优化摄像头处理和手势稳定性
xiaoshiyuan888 Dec 18, 2025
09037fe
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 19, 2025
d1726c9
优化手势识别算法,提升系统稳定性和用户体验
xiaoshiyuan888 Dec 19, 2025
0d155c7
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 19, 2025
fd2edd8
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 19, 2025
4b5e52e
优化英文界面,改进手势识别算法,增强单指识别准确率
xiaoshiyuan888 Dec 19, 2025
5aa3395
Merge branch 'new' of https://github.com/xiaoshiyuan888/nn into new
xiaoshiyuan888 Dec 19, 2025
87eeee6
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 19, 2025
f1897a2
持续优化手势识别算法,解决位置敏感问题,增强全屏手势检测能力
xiaoshiyuan888 Dec 19, 2025
75421ae
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 19, 2025
f095776
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 19, 2025
a7cb67e
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 19, 2025
1c7a07d
优化手势标签显示,修复中文字体缺失导致的问号问题
xiaoshiyuan888 Dec 19, 2025
a499a9b
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 19, 2025
81afe79
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 19, 2025
36f5403
新增:语音反馈系统,支持多平台音频播放
xiaoshiyuan888 Dec 19, 2025
d6aaa05
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 20, 2025
fb866db
优化手势平滑处理,扩展语音反馈系统,增加手势状态追踪
xiaoshiyuan888 Dec 20, 2025
dc19f1c
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 20, 2025
d831140
更新我的项目README.md文件
xiaoshiyuan888 Dec 20, 2025
6a4fd48
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 20, 2025
fcd3d57
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 21, 2025
15eb615
新增手势轨迹记录与回放功能,优化语音反馈系统
xiaoshiyuan888 Dec 21, 2025
86bc6a2
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 21, 2025
9b42799
增加性能模式选择功能
xiaoshiyuan888 Dec 21, 2025
d0e6b06
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 21, 2025
40d100c
增加性能模式选择功能
xiaoshiyuan888 Dec 21, 2025
729daf9
增加性能模式选择功能
xiaoshiyuan888 Dec 21, 2025
a78d784
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 21, 2025
a73dbea
新增完整的性能统计与分析系统,实现实时性能监控、详细报告和系统资源管理功能
xiaoshiyuan888 Dec 21, 2025
3e28176
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 21, 2025
0de8fdf
将手势控制无人机系统拆分为模块化架构,保持功能完整性,优化代码维护性
xiaoshiyuan888 Dec 21, 2025
3621c5b
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 21, 2025
fb9744b
更新我的README文件和依赖文件
xiaoshiyuan888 Dec 21, 2025
50929ae
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 21, 2025
4e9e03b
添加高级手势识别功能,支持旋转、抓取、拍照等复杂手势
xiaoshiyuan888 Dec 21, 2025
fb36875
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 22, 2025
7cb4eca
增加高级飞行控制功能 - 自动飞行模式、圆形盘旋、8字形飞行、高度控制
xiaoshiyuan888 Dec 22, 2025
8fb911a
Merge branch 'OpenHUTB:main' into new
xiaoshiyuan888 Dec 22, 2025
e44a045
优化性能监控:增强分析器+新增UI性能图表
xiaoshiyuan888 Dec 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/autonomus_drone_hand_gesture_project/gesture_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
},
"gesture": {
"skin_lower_h": 0,
"skin_upper_h": 180,
"skin_upper_h": 175,
"skin_lower_s": 0,
"skin_upper_s": 165,
"skin_lower_v": 16,
"skin_upper_v": 255,
"skin_upper_s": 87,
"skin_lower_v": 0,
"skin_upper_v": 95,
"min_hand_area": 3000,
"max_hand_area": 30000,
"hand_ratio_threshold": 1.5,
Expand Down Expand Up @@ -111,8 +111,8 @@
"target_fps": 30,
"resize_factor": 1.0,
"enable_multiprocessing": false,
"mode": "balanced",
"current_mode_index": 1,
"mode": "accurate",
"current_mode_index": 2,
"modes": [
"fast",
"balanced",
Expand All @@ -138,7 +138,7 @@
"min_calibration_samples": 50
},
"speech": {
"enabled": true,
"enabled": false,
"volume": 1.0,
"rate": 150,
"announce_gestures": true,
Expand Down
185 changes: 147 additions & 38 deletions src/autonomus_drone_hand_gesture_project/gesture_recognizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,15 @@ def __init__(self, speech_manager=None, config=None):
self.performance_mode_color = self.mode_config['color']
self.performance_mode_name = self.mode_config['name']

# UI渲染器引用(稍后设置)
self.ui_renderer = None

print(f"✓ 增强的手势识别器已初始化 - 性能模式: {self.performance_mode_name}")

def set_ui_renderer(self, ui_renderer):
"""设置UI渲染器"""
self.ui_renderer = ui_renderer

def set_performance_mode(self, mode):
"""设置性能模式"""
self.performance_mode = mode
Expand Down Expand Up @@ -656,43 +663,100 @@ def visualize_detection(self, frame, hand_data, gesture, confidence):
# 显示手势标签
label = f"{gesture}"
if self.config.get('display', 'show_confidence'):
label += f" ({confidence:.0%})"
# 使用UI渲染器绘制文本,避免字体问题
if self.ui_renderer:
# 首先绘制手势名称
gesture_text = f"{gesture}"

# 计算文本位置
(text_width, text_height), baseline = cv2.getTextSize(
gesture_text, cv2.FONT_HERSHEY_SIMPLEX, 0.6, 2
)

# 绘制文本背景
cv2.rectangle(frame,
(x1, y1 - text_height - 10),
(x1 + text_width, y1),
color, -1)

# 使用UI渲染器绘制手势名称
frame = self.ui_renderer.draw_text(frame, gesture_text,
(x1, y1 - 5),
size=16, color=(255, 255, 255))

# 绘制置信度(使用UI渲染器确保正确显示)
confidence_text = f"{confidence:.0%}"
# 计算置信度文本位置
frame = self.ui_renderer.draw_text(frame, confidence_text,
(x1 + text_width + 5, y1 - 5),
size=16, color=(255, 255, 255))
else:
# 备用方案
label += f" ({confidence:.0%})"
(text_width, text_height), baseline = cv2.getTextSize(
label, cv2.FONT_HERSHEY_SIMPLEX, 0.6, 2
)

cv2.rectangle(frame,
(x1, y1 - text_height - 10),
(x1 + text_width, y1),
color, -1)
cv2.putText(frame, label, (x1, y1 - 5),
cv2.FONT_HERSHEY_SIMPLEX, 0.6, (255, 255, 255), 2)
else:
# 不使用置信度显示
(text_width, text_height), baseline = cv2.getTextSize(
label, cv2.FONT_HERSHEY_SIMPLEX, 0.6, 2
)

cv2.rectangle(frame,
(x1, y1 - text_height - 10),
(x1 + text_width, y1),
color, -1)
cv2.putText(frame, label, (x1, y1 - 5),
cv2.FONT_HERSHEY_SIMPLEX, 0.6, (255, 255, 255), 2)

# 显示手势状态
if self.gesture_state != "none":
state_text = {"starting": "开始", "active": "活跃", "ending": "结束"}
label += f" [{state_text.get(self.gesture_state, '')}]"

# 计算文本大小
(text_width, text_height), baseline = cv2.getTextSize(
label, cv2.FONT_HERSHEY_SIMPLEX, 0.6, 2
)

# 绘制文本背景
cv2.rectangle(frame,
(x1, y1 - text_height - 10),
(x1 + text_width, y1),
color, -1)

# 绘制文本
cv2.putText(frame, label, (x1, y1 - 5),
cv2.FONT_HERSHEY_SIMPLEX, 0.6, (255, 255, 255), 2)
state_text = {"starting": "Starting", "active": "Active", "ending": "Ending"}
state_label = f" [{state_text.get(self.gesture_state, '')}]"

# 使用UI渲染器绘制状态文本
if self.ui_renderer:
frame = self.ui_renderer.draw_text(frame, state_label,
(x1, y1 - 30),
size=14, color=color)
else:
cv2.putText(frame, state_label, (x1, y1 - 30),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 1)

# 绘制手掌中心
if show_palm_center and 'palm_center' in hand_data:
cx, cy = hand_data['palm_center']
palm_radius = hand_data.get('palm_radius', 20)
cv2.circle(frame, (cx, cy), 5, (0, 0, 255), -1)
cv2.circle(frame, (cx, cy), palm_radius, (0, 0, 255), 1)
cv2.putText(frame, "Palm", (cx + 10, cy),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 1)
# 使用UI渲染器绘制"Palm"文本
if self.ui_renderer:
frame = self.ui_renderer.draw_text(frame, "Palm",
(cx + 10, cy),
size=14, color=(0, 0, 255))
else:
cv2.putText(frame, "Palm", (cx + 10, cy),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 1)

# 绘制指尖
if show_fingertips and 'fingertips' in hand_data:
for i, point in enumerate(hand_data['fingertips']):
cv2.circle(frame, point, 4, (255, 0, 0), -1)
cv2.putText(frame, f"F{i + 1}", (point[0] + 5, point[1]),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 0, 0), 1)
# 使用UI渲染器绘制指尖编号
if self.ui_renderer:
frame = self.ui_renderer.draw_text(frame, f"F{i+1}",
(point[0] + 5, point[1]),
size=14, color=(255, 0, 0))
else:
cv2.putText(frame, f"F{i+1}", (point[0] + 5, point[1]),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 0, 0), 1)

# 绘制手部方向
if show_hand_direction and 'direction' in hand_data and 'center' in hand_data:
Expand All @@ -707,8 +771,14 @@ def visualize_detection(self, frame, hand_data, gesture, confidence):
cv2.arrowedLine(frame, (cx, cy), end_point, (255, 255, 0), 2)

angle_text = f"Dir: {direction:.0f}°"
cv2.putText(frame, angle_text, (cx, cy - 20),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 0), 1)
# 使用UI渲染器绘制方向文本
if self.ui_renderer:
frame = self.ui_renderer.draw_text(frame, angle_text,
(cx, cy - 20),
size=14, color=(255, 255, 0))
else:
cv2.putText(frame, angle_text, (cx, cy - 20),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 0), 1)

# 绘制稳定性指示器
if show_stability_indicator:
Expand Down Expand Up @@ -738,8 +808,13 @@ def visualize_detection(self, frame, hand_data, gesture, confidence):
(indicator_x + 5 + bar_length, indicator_y + 10), bar_color, -1)

# 绘制稳定性文本
cv2.putText(frame, "稳定度", (indicator_x, indicator_y - 5),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)
if self.ui_renderer:
frame = self.ui_renderer.draw_text(frame, "稳定度",
(indicator_x, indicator_y - 5),
size=14, color=(255, 255, 255))
else:
cv2.putText(frame, "稳定度", (indicator_x, indicator_y - 5),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)

# 绘制手势历史
if show_gesture_history and len(self.gesture_history) > 0:
Expand All @@ -748,35 +823,69 @@ def visualize_detection(self, frame, hand_data, gesture, confidence):

# 绘制历史背景
cv2.rectangle(frame, (10, history_y - 20), (200, history_y + 10), (0, 0, 0), -1)
cv2.putText(frame, "手势历史:", (15, history_y),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)

# 使用UI渲染器绘制历史标题
if self.ui_renderer:
frame = self.ui_renderer.draw_text(frame, "手势历史:",
(15, history_y),
size=14, color=(255, 255, 255))
else:
cv2.putText(frame, "手势历史:", (15, history_y),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)

# 显示最近几个手势
recent_gestures = list(self.gesture_history)[-5:] if len(self.gesture_history) >= 5 else list(
self.gesture_history)
for i, gest in enumerate(recent_gestures):
color = self.gesture_colors.get(gest, (255, 255, 255))
cv2.putText(frame, gest[0], (85 + i * 20, history_y),
cv2.FONT_HERSHEY_SIMPLEX, 0.6, color, 2)
# 使用UI渲染器绘制手势历史
if self.ui_renderer:
frame = self.ui_renderer.draw_text(frame, gest[0],
(85 + i * 20, history_y),
size=16, color=color)
else:
cv2.putText(frame, gest[0], (85 + i * 20, history_y),
cv2.FONT_HERSHEY_SIMPLEX, 0.6, color, 2)

# 显示调试信息
if show_debug_info:
finger_count = len(hand_data.get('fingers', []))
finger_text = f"Fingers: {finger_count}"
cv2.putText(frame, finger_text, (10, frame.shape[0] - 30),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)
# 使用UI渲染器绘制调试信息
if self.ui_renderer:
frame = self.ui_renderer.draw_text(frame, finger_text,
(10, frame.shape[0] - 30),
size=14, color=(255, 255, 255))
else:
cv2.putText(frame, finger_text, (10, frame.shape[0] - 30),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)

pos_text = f"Pos: ({hand_data['position'][0]:.2f}, {hand_data['position'][1]:.2f})"
cv2.putText(frame, pos_text, (10, frame.shape[0] - 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)
if self.ui_renderer:
frame = self.ui_renderer.draw_text(frame, pos_text,
(10, frame.shape[0] - 10),
size=14, color=(255, 255, 255))
else:
cv2.putText(frame, pos_text, (10, frame.shape[0] - 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)

state_text = f"State: {self.gesture_state}"
cv2.putText(frame, state_text, (150, frame.shape[0] - 30),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)
if self.ui_renderer:
frame = self.ui_renderer.draw_text(frame, state_text,
(150, frame.shape[0] - 30),
size=14, color=(255, 255, 255))
else:
cv2.putText(frame, state_text, (150, frame.shape[0] - 30),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)

stability_text = f"Stability: {self.gesture_stability_counter}"
cv2.putText(frame, stability_text, (150, frame.shape[0] - 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)
if self.ui_renderer:
frame = self.ui_renderer.draw_text(frame, stability_text,
(150, frame.shape[0] - 10),
size=14, color=(255, 255, 255))
else:
cv2.putText(frame, stability_text, (150, frame.shape[0] - 10),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)

return frame

Expand Down
5 changes: 5 additions & 0 deletions src/autonomus_drone_hand_gesture_project/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ def main():
drone_controller = SimpleDroneController(libs['airsim'], speech_manager, config)
ui_renderer = ChineseUIRenderer(speech_manager, config)

# 设置手势识别器的UI渲染器引用
gesture_recognizer.set_ui_renderer(ui_renderer)

# 初始化性能分析器
print("初始化性能分析器...")
performance_analyzer = PerformanceAnalyzer(speech_manager, libs.get('psutil'), config)
Expand Down Expand Up @@ -449,6 +452,8 @@ def main():
# 重置手势识别
print("重置手势识别...")
gesture_recognizer = EnhancedGestureRecognizer(speech_manager, config)
# 重新设置UI渲染器引用
gesture_recognizer.set_ui_renderer(ui_renderer)
print("✓ 手势识别已重置")

# 语音提示
Expand Down
Loading
Loading