From 852109a31f7e1cbe680e95cf8a793c9f4ee63f28 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 18:00:45 +0800 Subject: [PATCH 01/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/Unmanned_Aircraft_System/README.md diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md new file mode 100644 index 0000000000..8620aae73b --- /dev/null +++ b/src/Unmanned_Aircraft_System/README.md @@ -0,0 +1 @@ +使用强化学习和模拟器进行无人机/无人驾驶飞机路 径规划 \ No newline at end of file From 6fe47f51daaa1ade9e5dcdab13d7928bccb402e9 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 18:08:41 +0800 Subject: [PATCH 02/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index 8620aae73b..62f5b7cc72 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路 径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file From af14f998a9070884c7cd8c97c1b2aa54b101c45e Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 18:11:18 +0800 Subject: [PATCH 03/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index 62f5b7cc72..bd2f2f59ca 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file From c1ae4acbbef045b93e2c188222df56ebde143228 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 18:14:42 +0800 Subject: [PATCH 04/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index bd2f2f59ca..62f5b7cc72 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file From ddaa9d522d82660b22dda5fd46466d0b009f6ce0 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 18:15:54 +0800 Subject: [PATCH 05/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index 62f5b7cc72..bd2f2f59ca 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file From d66962dc189cb673507c7c23cc5a30cc268b08e0 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 18:20:49 +0800 Subject: [PATCH 06/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index bd2f2f59ca..62f5b7cc72 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file From 9293e17535979018e820d0fb5feb1f4eb775cc8c Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 18:23:15 +0800 Subject: [PATCH 07/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index 62f5b7cc72..bd2f2f59ca 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file From e8fef316bc62a650a2f87294dba71e840670be83 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 18:27:09 +0800 Subject: [PATCH 08/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index bd2f2f59ca..62f5b7cc72 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file From 7a9fab5526fdd74c47be19721805b231891899d7 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 18:50:42 +0800 Subject: [PATCH 09/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index 62f5b7cc72..bd2f2f59ca 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file From 79cc5314e7877fa7f6df8af5500bd0108a121d4e Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 18:51:48 +0800 Subject: [PATCH 10/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index bd2f2f59ca..62f5b7cc72 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file From 29f77705706b6019d217b13d23af6c639bc60b5c Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 19:29:47 +0800 Subject: [PATCH 11/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index 62f5b7cc72..bd2f2f59ca 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file From 4b1aca1e95f41e2141387c92a6487d8a7027ff28 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 19:41:49 +0800 Subject: [PATCH 12/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index bd2f2f59ca..62f5b7cc72 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file From edcd60e09ca3e17b693a474637aae2bbc88eaf5a Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 19:43:49 +0800 Subject: [PATCH 13/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index 62f5b7cc72..bd2f2f59ca 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file From e43731a1b15a6760ba58613b26ce8ee5d348d7f1 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 19:46:43 +0800 Subject: [PATCH 14/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index bd2f2f59ca..62f5b7cc72 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file From 0f8575a199751c6514077f110c7b4825eb5cede0 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 19:50:09 +0800 Subject: [PATCH 15/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index 62f5b7cc72..bd2f2f59ca 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file From 60db4b42c3ffbab3936bc0caff6c3ba3a2f05b7c Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 19:51:38 +0800 Subject: [PATCH 16/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index bd2f2f59ca..62f5b7cc72 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file From d9535bae15e08ac997a25c9e277c9128b2591229 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Thu, 18 Dec 2025 22:43:17 +0800 Subject: [PATCH 17/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index 62f5b7cc72..bd2f2f59ca 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file From 78869806c6590301db64df7a712ce2336412a730 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Fri, 19 Dec 2025 00:11:07 +0800 Subject: [PATCH 18/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=EF=BC=9A=E6=9B=B4=E6=96=B0Unmanned=5FAircraft=5FSystem?= =?UTF-8?q?=E7=9A=84README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index bd2f2f59ca..645fb4d244 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1 +1,2 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 \ No newline at end of file +使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 + From b4985379cce2f25beda21ede15815c56b9b0d9bd Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Fri, 19 Dec 2025 14:28:06 +0800 Subject: [PATCH 19/32] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index 645fb4d244..34b39fbed7 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1,2 +1,2 @@ -使用强化学习和模拟器进行无人机/无人驾驶飞机路径规划 +基于 YOLOv8 的无人机地面简易目标识别(如行人 / 小型车辆) From bc149727947fd991bdbb476179644bc62b823cd0 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Fri, 19 Dec 2025 16:56:24 +0800 Subject: [PATCH 20/32] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md index 34b39fbed7..6f3bf20ddc 100644 --- a/src/Unmanned_Aircraft_System/README.md +++ b/src/Unmanned_Aircraft_System/README.md @@ -1,2 +1,2 @@ -基于 YOLOv8 的无人机地面简易目标识别(如行人 / 小型车辆) +无人机航拍图像的小目标识别算法研究 From c0679cbcd98c710f74249ff454e4e7d9a608577b Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Fri, 19 Dec 2025 17:28:53 +0800 Subject: [PATCH 21/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Unmanned_Aircraft_System/README.md | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 src/Unmanned_Aircraft_System/README.md diff --git a/src/Unmanned_Aircraft_System/README.md b/src/Unmanned_Aircraft_System/README.md deleted file mode 100644 index 6f3bf20ddc..0000000000 --- a/src/Unmanned_Aircraft_System/README.md +++ /dev/null @@ -1,2 +0,0 @@ -无人机航拍图像的小目标识别算法研究 - From 2d1e296235088c7f2036bb31121a8a5b399ed66e Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Fri, 19 Dec 2025 17:37:27 +0800 Subject: [PATCH 22/32] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9=EF=BC=9AUnmanned=5FAircraft=5FSystem=20?= =?UTF-8?q?=E2=86=92=20UAV=5FSmall=5FTarget=5FRecognition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/UAV_Small_Target_Recognition/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/UAV_Small_Target_Recognition/README.md diff --git a/src/UAV_Small_Target_Recognition/README.md b/src/UAV_Small_Target_Recognition/README.md new file mode 100644 index 0000000000..c9ac2e269b --- /dev/null +++ b/src/UAV_Small_Target_Recognition/README.md @@ -0,0 +1,3 @@ +无人机航拍图像的小目标识别算法 + + From d49e121e292de767c0d6312f0c5b3c9b29be7b44 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Fri, 19 Dec 2025 18:01:45 +0800 Subject: [PATCH 23/32] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=89=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/UAV_Small_Target_Recognition/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/UAV_Small_Target_Recognition/README.md b/src/UAV_Small_Target_Recognition/README.md index c9ac2e269b..a05dec4c58 100644 --- a/src/UAV_Small_Target_Recognition/README.md +++ b/src/UAV_Small_Target_Recognition/README.md @@ -1,3 +1 @@ -无人机航拍图像的小目标识别算法 - - +无人机航拍图像的小目标识别算法 \ No newline at end of file From 2c572930f54bab14ac8e011a32afbbf50d45c476 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Fri, 19 Dec 2025 19:41:09 +0800 Subject: [PATCH 24/32] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9=E4=B8=BAGesture=5FControl=5Ffor=5FAirsim=5FU?= =?UTF-8?q?AV=EF=BC=8C=E5=B9=B6=E6=9B=B4=E6=96=B0README.md=E8=A1=A5?= =?UTF-8?q?=E5=85=85=E6=97=A0=E4=BA=BA=E6=9C=BA=E6=89=8B=E5=8A=BF=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Gesture_Control_for_Airsim_UAV/README.md | 2 ++ src/Gesture_Control_for_Airsim_UAV/main.py | 1 + src/UAV_Small_Target_Recognition/README.md | 1 - 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 src/Gesture_Control_for_Airsim_UAV/README.md create mode 100644 src/Gesture_Control_for_Airsim_UAV/main.py delete mode 100644 src/UAV_Small_Target_Recognition/README.md diff --git a/src/Gesture_Control_for_Airsim_UAV/README.md b/src/Gesture_Control_for_Airsim_UAV/README.md new file mode 100644 index 0000000000..4f05828e92 --- /dev/null +++ b/src/Gesture_Control_for_Airsim_UAV/README.md @@ -0,0 +1,2 @@ +允许用户使用手势控制 Airsim 无人机 + diff --git a/src/Gesture_Control_for_Airsim_UAV/main.py b/src/Gesture_Control_for_Airsim_UAV/main.py new file mode 100644 index 0000000000..c6d640eaa5 --- /dev/null +++ b/src/Gesture_Control_for_Airsim_UAV/main.py @@ -0,0 +1 @@ +pressed) \ No newline at end of file diff --git a/src/UAV_Small_Target_Recognition/README.md b/src/UAV_Small_Target_Recognition/README.md deleted file mode 100644 index a05dec4c58..0000000000 --- a/src/UAV_Small_Target_Recognition/README.md +++ /dev/null @@ -1 +0,0 @@ -无人机航拍图像的小目标识别算法 \ No newline at end of file From d5f2c9d16e3500dce621d7ceb7965e2f7c5f0d6f Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Fri, 19 Dec 2025 21:16:23 +0800 Subject: [PATCH 25/32] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9=EF=BC=9AGesture=5FControl=5Ffor=5FAirsim=5FU?= =?UTF-8?q?AV=20=E2=86=92=20Drone=5Fgesture=5Foperation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../README.md | 0 src/Gesture_Control_for_Airsim_UAV/main.py | 1 - 2 files changed, 1 deletion(-) rename src/{Gesture_Control_for_Airsim_UAV => Drone_gesture_operation}/README.md (100%) delete mode 100644 src/Gesture_Control_for_Airsim_UAV/main.py diff --git a/src/Gesture_Control_for_Airsim_UAV/README.md b/src/Drone_gesture_operation/README.md similarity index 100% rename from src/Gesture_Control_for_Airsim_UAV/README.md rename to src/Drone_gesture_operation/README.md diff --git a/src/Gesture_Control_for_Airsim_UAV/main.py b/src/Gesture_Control_for_Airsim_UAV/main.py deleted file mode 100644 index c6d640eaa5..0000000000 --- a/src/Gesture_Control_for_Airsim_UAV/main.py +++ /dev/null @@ -1 +0,0 @@ -pressed) \ No newline at end of file From f1d316714ea393683f4e830c370d226ba183c967 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Fri, 19 Dec 2025 22:01:09 +0800 Subject: [PATCH 26/32] =?UTF-8?q?=E6=9B=B4=E6=96=B0Drone=5Fgesture=5Fopera?= =?UTF-8?q?tion/README.md=EF=BC=9A=E5=9F=BA=E4=BA=8E=E8=BD=BB=E9=87=8F?= =?UTF-8?q?=E7=BA=A7=20CNN=20=E7=9A=84=E6=97=A0=E4=BA=BA=E6=9C=BA=E6=89=8B?= =?UTF-8?q?=E5=8A=BF=E6=93=8D=E6=8E=A7=E6=8C=87=E4=BB=A4=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Drone_gesture_operation/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Drone_gesture_operation/README.md b/src/Drone_gesture_operation/README.md index 4f05828e92..3454d8e7dd 100644 --- a/src/Drone_gesture_operation/README.md +++ b/src/Drone_gesture_operation/README.md @@ -1,2 +1,2 @@ -允许用户使用手势控制 Airsim 无人机 +基于轻量级 CNN 的无人机手势操控指令识别 From 5a5639ca81060ddcba63d4cd8b20d16697f1074e Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Sat, 20 Dec 2025 16:08:12 +0800 Subject: [PATCH 27/32] =?UTF-8?q?=E6=97=A0=E4=BA=BA=E6=9C=BA=E6=89=8B?= =?UTF-8?q?=E5=8A=BF=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Drone_gesture_operation/main.py | 109 ++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 src/Drone_gesture_operation/main.py diff --git a/src/Drone_gesture_operation/main.py b/src/Drone_gesture_operation/main.py new file mode 100644 index 0000000000..ca2ffe128d --- /dev/null +++ b/src/Drone_gesture_operation/main.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import numpy as np +import tensorflow as tf +import os +import warnings +import pathlib + +# 关闭oneDNN提示 +os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' +# 关闭TF Lite警告 +warnings.filterwarnings('ignore', category=UserWarning, module='tensorflow.lite.python.interpreter') + + +class PointHistoryClassifier(object): + def __init__( + self, + model_path='model/point_history_classifier/point_history_classifier.tflite', + score_th=0.5, + invalid_value=0, + num_threads=1, + ): + if not os.path.isfile(model_path): + raise FileNotFoundError(f"模型文件不存在:{model_path}") + if not model_path.endswith('.tflite'): + raise ValueError(f"路径不是.tflite文件:{model_path}") + + with open(model_path, 'rb') as f: + model_data = f.read() + self.interpreter = tf.lite.Interpreter(model_content=model_data, num_threads=num_threads) + self.interpreter.allocate_tensors() + self.input_details = self.interpreter.get_input_details() + self.output_details = self.interpreter.get_output_details() + + self.score_th = score_th + self.invalid_value = invalid_value + print(f"✅ 模型加载成功!") + print(f"输入张量形状:{self.input_details[0]['shape']}") + print(f"输出张量形状:{self.output_details[0]['shape']}") + + def __call__(self, point_history): + if not isinstance(point_history, (list, np.ndarray)): + raise TypeError("输入必须是列表或numpy数组") + + input_data = np.array([point_history], dtype=np.float32) + if input_data.shape != tuple(self.input_details[0]['shape']): + raise ValueError( + f"输入形状不匹配!模型要求:{self.input_details[0]['shape']},实际:{input_data.shape}" + ) + + self.interpreter.set_tensor(self.input_details[0]['index'], input_data) + self.interpreter.invoke() + + result = self.interpreter.get_tensor(self.output_details[0]['index']) + result_squeezed = np.squeeze(result) + result_index = np.argmax(result_squeezed) + + print(f"\n原始预测得分:{result_squeezed}") + print(f"最高得分索引:{result_index},得分值:{result_squeezed[result_index]}") + + if result_squeezed[result_index] < self.score_th: + result_index = self.invalid_value + print(f"⚠️ 得分低于阈值({self.score_th}),返回无效值:{self.invalid_value}") + + return result_index + + +def preprocess_point_history(point_history): + """归一化关键点数据到0~1""" + point_history = np.array(point_history, dtype=np.float32) + min_val = np.min(point_history) + max_val = np.max(point_history) + # 避免除零 + point_history = (point_history - min_val) / (max_val - min_val + 1e-6) + return point_history + + +if __name__ == "__main__": + # 配置 + MODEL_PATH = pathlib.Path( + r"E:\无人机\dronehandgesture2023P1\model\point_history_classifier\point_history_classifier.tflite").resolve() + SCORE_THRESHOLD = 0.5 + # 手势映射(根据实际训练标签调整) + gesture_mapping = {0: "无手势/降落", 1: "起飞/前进"} + + print(f"当前模型路径:{MODEL_PATH}") + try: + # 实例化分类器 + classifier = PointHistoryClassifier( + model_path=str(MODEL_PATH), + score_th=SCORE_THRESHOLD, + num_threads=4 + ) + + # 1. 测试数据(随机生成32维,匹配模型输入) + test_point_history = np.random.rand(32).astype(np.float32) + # 2. 预处理(替换为真实数据时注释掉随机数,启用下面两行) + # real_point_history = [0.1,0.2,...,0.3] # 32个真实关键点数值 + # test_point_history = preprocess_point_history(real_point_history) + + # 分类推理 + result = classifier(test_point_history) + print(f"\n🎯 最终分类结果:{result} → {gesture_mapping.get(result, '未知手势')}") + + except Exception as e: + print(f"\n❌ 错误:{e}") + import traceback + + traceback.print_exc() \ No newline at end of file From 0ecd007042d36d15111f85915c6762860426dc10 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Sat, 20 Dec 2025 16:15:47 +0800 Subject: [PATCH 28/32] =?UTF-8?q?=E6=9B=B4=E6=96=B0Drone=5Fgesture=5Fopera?= =?UTF-8?q?tion=EF=BC=9A=E5=90=8C=E6=AD=A5main.py=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Drone_gesture_operation/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Drone_gesture_operation/README.md b/src/Drone_gesture_operation/README.md index 3454d8e7dd..93d5444e0d 100644 --- a/src/Drone_gesture_operation/README.md +++ b/src/Drone_gesture_operation/README.md @@ -1,2 +1 @@ 基于轻量级 CNN 的无人机手势操控指令识别 - From 786c5984bc6e56f89a7348408257575e783b1934 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Sat, 20 Dec 2025 16:20:07 +0800 Subject: [PATCH 29/32] =?UTF-8?q?=E6=97=A0=E4=BA=BA=E6=9C=BA=E6=89=8B?= =?UTF-8?q?=E5=8A=BF=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Drone_gesture_operation/main.py | 355 ++++++++++++++++++++-------- 1 file changed, 256 insertions(+), 99 deletions(-) diff --git a/src/Drone_gesture_operation/main.py b/src/Drone_gesture_operation/main.py index ca2ffe128d..fbbf1930c2 100644 --- a/src/Drone_gesture_operation/main.py +++ b/src/Drone_gesture_operation/main.py @@ -1,109 +1,266 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +import copy +import argparse +import itertools +from collections import Counter +from collections import deque +import time + +import cv2 as cv import numpy as np -import tensorflow as tf -import os -import warnings -import pathlib - -# 关闭oneDNN提示 -os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' -# 关闭TF Lite警告 -warnings.filterwarnings('ignore', category=UserWarning, module='tensorflow.lite.python.interpreter') - - -class PointHistoryClassifier(object): - def __init__( - self, - model_path='model/point_history_classifier/point_history_classifier.tflite', - score_th=0.5, - invalid_value=0, - num_threads=1, - ): - if not os.path.isfile(model_path): - raise FileNotFoundError(f"模型文件不存在:{model_path}") - if not model_path.endswith('.tflite'): - raise ValueError(f"路径不是.tflite文件:{model_path}") - - with open(model_path, 'rb') as f: - model_data = f.read() - self.interpreter = tf.lite.Interpreter(model_content=model_data, num_threads=num_threads) - self.interpreter.allocate_tensors() - self.input_details = self.interpreter.get_input_details() - self.output_details = self.interpreter.get_output_details() - - self.score_th = score_th - self.invalid_value = invalid_value - print(f"✅ 模型加载成功!") - print(f"输入张量形状:{self.input_details[0]['shape']}") - print(f"输出张量形状:{self.output_details[0]['shape']}") + +# ========== FPS计算 ========== +class CvFpsCalc: + def __init__(self, buffer_len=10): + self.buffer_len = buffer_len + self.times = deque(maxlen=buffer_len) + + def get(self): + self.times.append(time.perf_counter()) + if len(self.times) < 2: + return 0 + return int(len(self.times) / (self.times[-1] - self.times[0])) + + +# ========== 手势分类器(简化版) ========== +class KeyPointClassifier: + def __call__(self, landmark_list): + return 7 # 模拟点手势 + + +class PointHistoryClassifier: def __call__(self, point_history): - if not isinstance(point_history, (list, np.ndarray)): - raise TypeError("输入必须是列表或numpy数组") - - input_data = np.array([point_history], dtype=np.float32) - if input_data.shape != tuple(self.input_details[0]['shape']): - raise ValueError( - f"输入形状不匹配!模型要求:{self.input_details[0]['shape']},实际:{input_data.shape}" - ) - - self.interpreter.set_tensor(self.input_details[0]['index'], input_data) - self.interpreter.invoke() - - result = self.interpreter.get_tensor(self.output_details[0]['index']) - result_squeezed = np.squeeze(result) - result_index = np.argmax(result_squeezed) - - print(f"\n原始预测得分:{result_squeezed}") - print(f"最高得分索引:{result_index},得分值:{result_squeezed[result_index]}") - - if result_squeezed[result_index] < self.score_th: - result_index = self.invalid_value - print(f"⚠️ 得分低于阈值({self.score_th}),返回无效值:{self.invalid_value}") - - return result_index - - -def preprocess_point_history(point_history): - """归一化关键点数据到0~1""" - point_history = np.array(point_history, dtype=np.float32) - min_val = np.min(point_history) - max_val = np.max(point_history) - # 避免除零 - point_history = (point_history - min_val) / (max_val - min_val + 1e-6) - return point_history - - -if __name__ == "__main__": - # 配置 - MODEL_PATH = pathlib.Path( - r"E:\无人机\dronehandgesture2023P1\model\point_history_classifier\point_history_classifier.tflite").resolve() - SCORE_THRESHOLD = 0.5 - # 手势映射(根据实际训练标签调整) - gesture_mapping = {0: "无手势/降落", 1: "起飞/前进"} - - print(f"当前模型路径:{MODEL_PATH}") - try: - # 实例化分类器 - classifier = PointHistoryClassifier( - model_path=str(MODEL_PATH), - score_th=SCORE_THRESHOLD, - num_threads=4 + return 0 + + +# ========== 参数解析 ========== +def get_args(): + parser = argparse.ArgumentParser() + parser.add_argument("--device", type=int, default=0) + parser.add_argument("--width", type=int, default=960) + parser.add_argument("--height", type=int, default=540) + return parser.parse_args() + + +# ========== 辅助函数 ========== +def select_mode(key, mode): + number = -1 + if 48 <= key <= 57: + number = key - 48 + if key == ord('n'): + mode = 0 + if key == ord('k'): + mode = 1 + if key == ord('h'): + mode = 2 + return number, mode + + +def calc_bounding_rect(image): + """模拟手部边界框(屏幕中心)""" + h, w = image.shape[:2] + cx, cy = w // 2, h // 2 + bw, bh = 200, 200 # 边界框大小 + return [cx - bw // 2, cy - bh // 2, cx + bw // 2, cy + bh // 2] + + +def calc_landmark_list(image): + """模拟21个手部关键点(适配原代码逻辑)""" + h, w = image.shape[:2] + cx, cy = w // 2, h // 2 + landmark_list = [] + + # 手掌中心(0号点) + landmark_list.append([cx, cy]) + + # 拇指(1-4号点) + landmark_list.append([cx - 50, cy - 30]) + landmark_list.append([cx - 80, cy - 60]) + landmark_list.append([cx - 100, cy - 90]) + landmark_list.append([cx - 110, cy - 110]) + + # 食指(5-8号点) + landmark_list.append([cx + 50, cy - 30]) + landmark_list.append([cx + 80, cy - 60]) + landmark_list.append([cx + 100, cy - 90]) + landmark_list.append([cx + 110, cy - 110]) # 8号点(点手势关键) + + # 中指(9-12号点) + landmark_list.append([cx + 30, cy - 10]) + landmark_list.append([cx + 50, cy - 40]) + landmark_list.append([cx + 70, cy - 70]) + landmark_list.append([cx + 80, cy - 90]) + + # 无名指(13-16号点) + landmark_list.append([cx + 10, cy + 10]) + landmark_list.append([cx + 20, cy - 20]) + landmark_list.append([cx + 30, cy - 50]) + landmark_list.append([cx + 40, cy - 70]) + + # 小指(17-20号点) + landmark_list.append([cx - 10, cy + 10]) + landmark_list.append([cx - 20, cy - 20]) + landmark_list.append([cx - 30, cy - 50]) + landmark_list.append([cx - 40, cy - 70]) + + return landmark_list + + +def pre_process_landmark(landmark_list): + temp = copy.deepcopy(landmark_list) + if not temp: + return [] + base_x, base_y = temp[0][0], temp[0][1] + for i in range(len(temp)): + temp[i][0] -= base_x + temp[i][1] -= base_y + temp = list(itertools.chain.from_iterable(temp)) + max_val = max(map(abs, temp)) if temp else 1 + return [x / max_val for x in temp] + + +def pre_process_point_history(image, point_history): + temp = copy.deepcopy(point_history) + if not temp: + return [] + base_x, base_y = temp[0][0], temp[0][1] + image_w, image_h = image.shape[1], image.shape[0] + for i in range(len(temp)): + temp[i][0] = (temp[i][0] - base_x) / image_w + temp[i][1] = (temp[i][1] - base_y) / image_h + return list(itertools.chain.from_iterable(temp)) + + +def draw_landmarks(image, landmark_list): + """绘制模拟关键点""" + if len(landmark_list) == 0: + return image + # 绘制手指连线 + links = [(2, 3), (3, 4), (5, 6), (6, 7), (7, 8), (9, 10), (10, 11), (11, 12), + (13, 14), (14, 15), (15, 16), (17, 18), (18, 19), (19, 20), + (0, 1), (1, 2), (2, 5), (5, 9), (9, 13), (13, 17), (17, 0)] + for (p1, p2) in links: + if p1 < len(landmark_list) and p2 < len(landmark_list): + cv.line(image, tuple(landmark_list[p1]), tuple(landmark_list[p2]), (0, 0, 0), 6) + cv.line(image, tuple(landmark_list[p1]), tuple(landmark_list[p2]), (255, 255, 255), 2) + # 绘制关键点 + for i, (x, y) in enumerate(landmark_list): + size = 8 if i in [4, 8, 12, 16, 20] else 5 + cv.circle(image, (x, y), size, (255, 255, 255), -1) + cv.circle(image, (x, y), size, (0, 0, 0), 1) + return image + + +def draw_bounding_rect(image, brect): + cv.rectangle(image, (brect[0], brect[1]), (brect[2], brect[3]), (0, 255, 0), 2) + return image + + +def draw_info_text(image, brect, hand_sign_text, finger_gesture_text): + cv.rectangle(image, (brect[0], brect[1] - 30), (brect[2], brect[1]), (0, 255, 0), -1) + info = f"Hand: {hand_sign_text}" + cv.putText(image, info, (brect[0] + 5, brect[1] - 5), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 2) + if finger_gesture_text: + cv.putText(image, f"Gesture: {finger_gesture_text}", (10, 60), + cv.FONT_HERSHEY_SIMPLEX, 1.0, (0, 0, 255), 3) + return image + + +def draw_point_history(image, point_history): + for i, (x, y) in enumerate(point_history): + if x != 0 and y != 0: + cv.circle(image, (x, y), 2 + i // 2, (0, 255, 0), -1) + return image + + +def draw_info(image, fps, mode, number): + cv.putText(image, f"FPS: {fps}", (10, 30), cv.FONT_HERSHEY_SIMPLEX, 1.0, (0, 0, 255), 3) + mode_text = ["Idle", "Log Keypoint", "Log Point History"][mode] if 0 <= mode <= 2 else "Idle" + cv.putText(image, f"Mode: {mode_text}", (10, 90), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 2) + if 0 <= number <= 9: + cv.putText(image, f"Num: {number}", (10, 120), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 2) + return image + + +# ========== 主函数 ========== +def main(): + args = get_args() + # 初始化摄像头 + cap = cv.VideoCapture(args.device) + cap.set(cv.CAP_PROP_FRAME_WIDTH, args.width) + cap.set(cv.CAP_PROP_FRAME_HEIGHT, args.height) + + # 初始化工具类 + cvFpsCalc = CvFpsCalc(buffer_len=10) + keypoint_classifier = KeyPointClassifier() + point_history_classifier = PointHistoryClassifier() + + # 标签和历史数据 + keypoint_labels = ["None", "Point", "Fist", "OK", "Peace", "ThumbUp", "ThumbDown", "PointGesture"] + point_history_labels = ["None", "MoveUp", "MoveDown", "MoveLeft", "MoveRight"] + history_length = 16 + point_history = deque(maxlen=history_length) + finger_gesture_history = deque(maxlen=history_length) + mode = 0 + + while True: + # FPS计算 + fps = cvFpsCalc.get() + + # 按键处理 + key = cv.waitKey(1) & 0xFF + if key == 27: # ESC退出 + break + number, mode = select_mode(key, mode) + + # 读取摄像头帧 + ret, frame = cap.read() + if not ret: + break + frame = cv.flip(frame, 1) # 镜像显示 + debug_frame = copy.deepcopy(frame) + + # 【核心修改】跳过真实检测,直接模拟手部数据 + brect = calc_bounding_rect(debug_frame) + landmark_list = calc_landmark_list(debug_frame) + + # 预处理 + pre_landmark = pre_process_landmark(landmark_list) + pre_point_history = pre_process_point_history(debug_frame, point_history) + + # 手势分类 + hand_sign_id = keypoint_classifier(pre_landmark) + point_history.append(landmark_list[8] if hand_sign_id == 7 else [0, 0]) + + # 手指手势分类 + finger_gesture_id = 0 + if len(pre_point_history) == history_length * 2: + finger_gesture_id = point_history_classifier(pre_point_history) + finger_gesture_history.append(finger_gesture_id) + most_common = Counter(finger_gesture_history).most_common(1) + + # 绘制UI + debug_frame = draw_bounding_rect(debug_frame, brect) + debug_frame = draw_landmarks(debug_frame, landmark_list) + debug_frame = draw_info_text( + debug_frame, brect, + keypoint_labels[hand_sign_id] if hand_sign_id < len(keypoint_labels) else "Unknown", + point_history_labels[most_common[0][0]] if most_common else "Unknown" ) - # 1. 测试数据(随机生成32维,匹配模型输入) - test_point_history = np.random.rand(32).astype(np.float32) - # 2. 预处理(替换为真实数据时注释掉随机数,启用下面两行) - # real_point_history = [0.1,0.2,...,0.3] # 32个真实关键点数值 - # test_point_history = preprocess_point_history(real_point_history) + # 绘制辅助信息 + debug_frame = draw_point_history(debug_frame, point_history) + debug_frame = draw_info(debug_frame, fps, mode, number) + + # 显示窗口 + cv.imshow('Hand Gesture Recognition (ESC to exit)', debug_frame) - # 分类推理 - result = classifier(test_point_history) - print(f"\n🎯 最终分类结果:{result} → {gesture_mapping.get(result, '未知手势')}") + # 释放资源 + cap.release() + cv.destroyAllWindows() - except Exception as e: - print(f"\n❌ 错误:{e}") - import traceback - traceback.print_exc() \ No newline at end of file +if __name__ == '__main__': + main() \ No newline at end of file From 2bd59549f4678f23489b060527b58dbfaeed6e73 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Sat, 20 Dec 2025 21:02:48 +0800 Subject: [PATCH 30/32] =?UTF-8?q?=E4=BC=98=E5=8C=96Drone=5Fgesture=5Fopera?= =?UTF-8?q?tion/main.py=EF=BC=9A=E7=BB=99=E4=BB=A3=E7=A0=81=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=B3=A8=E9=87=8A=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=8F=AF?= =?UTF-8?q?=E8=AF=BB=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Drone_gesture_operation/main.py | 283 ++++++++++++++++++---------- 1 file changed, 183 insertions(+), 100 deletions(-) diff --git a/src/Drone_gesture_operation/main.py b/src/Drone_gesture_operation/main.py index fbbf1930c2..b5da6dc69d 100644 --- a/src/Drone_gesture_operation/main.py +++ b/src/Drone_gesture_operation/main.py @@ -1,5 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +# 功能:无人机手势识别模拟程序(适配Python3.13+Windows) +# 说明:移除MediaPipe/TensorFlow依赖,通过模拟手部数据实现核心逻辑展示 import copy import argparse import itertools @@ -11,157 +13,219 @@ import numpy as np -# ========== FPS计算 ========== +# ===================== 工具类:FPS计算 ===================== class CvFpsCalc: + """帧率计算类,基于时间队列滑动平均计算FPS""" + def __init__(self, buffer_len=10): - self.buffer_len = buffer_len - self.times = deque(maxlen=buffer_len) + self.buffer_len = buffer_len # 缓存长度(计算最近N帧的平均FPS) + self.times = deque(maxlen=buffer_len) # 时间戳队列 def get(self): - self.times.append(time.perf_counter()) - if len(self.times) < 2: + """获取当前FPS值""" + self.times.append(time.perf_counter()) # 记录当前时间戳 + if len(self.times) < 2: # 至少需要2个时间戳才能计算 return 0 - return int(len(self.times) / (self.times[-1] - self.times[0])) + # 计算平均FPS:帧数 / 总时间 + fps = len(self.times) / (self.times[-1] - self.times[0]) + return int(fps) -# ========== 手势分类器(简化版) ========== +# ===================== 模拟分类器(适配原逻辑) ===================== class KeyPointClassifier: + """关键点分类器(简化版)""" + def __call__(self, landmark_list): - return 7 # 模拟点手势 + # 固定返回7(对应PointGesture点手势,模拟分类结果) + return 7 class PointHistoryClassifier: + """轨迹点分类器(简化版)""" + def __call__(self, point_history): + # 固定返回0(对应None,模拟分类结果) return 0 + # ===================== 参数解析 ===================== + -# ========== 参数解析 ========== def get_args(): - parser = argparse.ArgumentParser() - parser.add_argument("--device", type=int, default=0) - parser.add_argument("--width", type=int, default=960) - parser.add_argument("--height", type=int, default=540) + """解析命令行参数""" + parser = argparse.ArgumentParser(description="手部手势识别模拟程序") + parser.add_argument("--device", type=int, default=0, help="摄像头设备号(默认0)") + parser.add_argument("--width", type=int, default=960, help="摄像头画面宽度") + parser.add_argument("--height", type=int, default=540, help="摄像头画面高度") return parser.parse_args() -# ========== 辅助函数 ========== +# ===================== 核心辅助函数 ===================== def select_mode(key, mode): + """根据按键切换操作模式 + Args: + key: 按键值 + mode: 当前模式(0:空闲 1:记录关键点 2:记录轨迹点) + Returns: + number: 按键数字(0-9),-1表示非数字键 + mode: 更新后的模式 + """ number = -1 - if 48 <= key <= 57: + if 48 <= key <= 57: # 数字键0-9 number = key - 48 - if key == ord('n'): + if key == ord('n'): # n键:切换到空闲模式 mode = 0 - if key == ord('k'): + if key == ord('k'): # k键:切换到记录关键点模式 mode = 1 - if key == ord('h'): + if key == ord('h'): # h键:切换到记录轨迹点模式 mode = 2 return number, mode def calc_bounding_rect(image): - """模拟手部边界框(屏幕中心)""" + """生成模拟手部边界框(屏幕中心固定位置) + Args: + image: 摄像头帧画面 + Returns: + brect: 边界框坐标 [x1, y1, x2, y2] + """ h, w = image.shape[:2] - cx, cy = w // 2, h // 2 - bw, bh = 200, 200 # 边界框大小 + cx, cy = w // 2, h // 2 # 屏幕中心 + bw, bh = 200, 200 # 边界框尺寸 return [cx - bw // 2, cy - bh // 2, cx + bw // 2, cy + bh // 2] def calc_landmark_list(image): - """模拟21个手部关键点(适配原代码逻辑)""" + """生成模拟21个手部关键点(适配原代码21点逻辑) + Args: + image: 摄像头帧画面 + Returns: + landmark_list: 21个关键点坐标列表 [[x1,y1], [x2,y2], ...] + """ h, w = image.shape[:2] - cx, cy = w // 2, h // 2 + cx, cy = w // 2, h // 2 # 屏幕中心(关键点基准位置) landmark_list = [] - # 手掌中心(0号点) + # 0号点:手掌中心 landmark_list.append([cx, cy]) - - # 拇指(1-4号点) - landmark_list.append([cx - 50, cy - 30]) - landmark_list.append([cx - 80, cy - 60]) - landmark_list.append([cx - 100, cy - 90]) - landmark_list.append([cx - 110, cy - 110]) - - # 食指(5-8号点) - landmark_list.append([cx + 50, cy - 30]) - landmark_list.append([cx + 80, cy - 60]) - landmark_list.append([cx + 100, cy - 90]) - landmark_list.append([cx + 110, cy - 110]) # 8号点(点手势关键) - - # 中指(9-12号点) - landmark_list.append([cx + 30, cy - 10]) - landmark_list.append([cx + 50, cy - 40]) - landmark_list.append([cx + 70, cy - 70]) - landmark_list.append([cx + 80, cy - 90]) - - # 无名指(13-16号点) - landmark_list.append([cx + 10, cy + 10]) - landmark_list.append([cx + 20, cy - 20]) - landmark_list.append([cx + 30, cy - 50]) - landmark_list.append([cx + 40, cy - 70]) - - # 小指(17-20号点) - landmark_list.append([cx - 10, cy + 10]) - landmark_list.append([cx - 20, cy - 20]) - landmark_list.append([cx - 30, cy - 50]) - landmark_list.append([cx - 40, cy - 70]) + # 1-4号点:拇指 + landmark_list.extend([[cx - 50, cy - 30], [cx - 80, cy - 60], [cx - 100, cy - 90], [cx - 110, cy - 110]]) + # 5-8号点:食指(8号点为指尖,点手势关键) + landmark_list.extend([[cx + 50, cy - 30], [cx + 80, cy - 60], [cx + 100, cy - 90], [cx + 110, cy - 110]]) + # 9-12号点:中指 + landmark_list.extend([[cx + 30, cy - 10], [cx + 50, cy - 40], [cx + 70, cy - 70], [cx + 80, cy - 90]]) + # 13-16号点:无名指 + landmark_list.extend([[cx + 10, cy + 10], [cx + 20, cy - 20], [cx + 30, cy - 50], [cx + 40, cy - 70]]) + # 17-20号点:小指 + landmark_list.extend([[cx - 10, cy + 10], [cx - 20, cy - 20], [cx - 30, cy - 50], [cx - 40, cy - 70]]) return landmark_list def pre_process_landmark(landmark_list): + """关键点预处理:相对坐标转换+归一化(适配原逻辑) + Args: + landmark_list: 原始关键点列表 + Returns: + 预处理后的一维归一化列表 + """ temp = copy.deepcopy(landmark_list) - if not temp: + if not temp: # 空值保护 return [] + + # 相对坐标:以0号点(手掌中心)为基准 base_x, base_y = temp[0][0], temp[0][1] for i in range(len(temp)): temp[i][0] -= base_x temp[i][1] -= base_y + + # 一维化 + 归一化(消除尺度影响) temp = list(itertools.chain.from_iterable(temp)) - max_val = max(map(abs, temp)) if temp else 1 + max_val = max(map(abs, temp)) if temp else 1 # 除零保护 return [x / max_val for x in temp] def pre_process_point_history(image, point_history): + """轨迹点预处理:相对坐标转换+归一化(适配原逻辑) + Args: + image: 摄像头帧画面 + point_history: 轨迹点历史列表 + Returns: + 预处理后的一维归一化列表 + """ temp = copy.deepcopy(point_history) - if not temp: + if not temp: # 空值保护 return [] + + # 相对坐标:以第一个点为基准 base_x, base_y = temp[0][0], temp[0][1] image_w, image_h = image.shape[1], image.shape[0] for i in range(len(temp)): - temp[i][0] = (temp[i][0] - base_x) / image_w + temp[i][0] = (temp[i][0] - base_x) / image_w # 归一化到[0,1] temp[i][1] = (temp[i][1] - base_y) / image_h + + # 一维化 return list(itertools.chain.from_iterable(temp)) +# ===================== 绘制函数(UI展示) ===================== def draw_landmarks(image, landmark_list): - """绘制模拟关键点""" + """绘制手部关键点和连线 + Args: + image: 待绘制的画面 + landmark_list: 关键点列表 + Returns: + 绘制后的画面 + """ if len(landmark_list) == 0: return image - # 绘制手指连线 + + # 手指连线定义(关键点索引对) links = [(2, 3), (3, 4), (5, 6), (6, 7), (7, 8), (9, 10), (10, 11), (11, 12), (13, 14), (14, 15), (15, 16), (17, 18), (18, 19), (19, 20), (0, 1), (1, 2), (2, 5), (5, 9), (9, 13), (13, 17), (17, 0)] + + # 绘制连线:黑色粗线+白色细线(立体效果) for (p1, p2) in links: - if p1 < len(landmark_list) and p2 < len(landmark_list): + if p1 < len(landmark_list) and p2 < len(landmark_list): # 索引保护 cv.line(image, tuple(landmark_list[p1]), tuple(landmark_list[p2]), (0, 0, 0), 6) cv.line(image, tuple(landmark_list[p1]), tuple(landmark_list[p2]), (255, 255, 255), 2) - # 绘制关键点 + + # 绘制关键点:指尖8号/12号等用大圆点,其余用小圆点 for i, (x, y) in enumerate(landmark_list): size = 8 if i in [4, 8, 12, 16, 20] else 5 - cv.circle(image, (x, y), size, (255, 255, 255), -1) - cv.circle(image, (x, y), size, (0, 0, 0), 1) + cv.circle(image, (x, y), size, (255, 255, 255), -1) # 白色填充 + cv.circle(image, (x, y), size, (0, 0, 0), 1) # 黑色边框 return image def draw_bounding_rect(image, brect): + """绘制手部边界框 + Args: + image: 待绘制的画面 + brect: 边界框坐标 [x1,y1,x2,y2] + Returns: + 绘制后的画面 + """ cv.rectangle(image, (brect[0], brect[1]), (brect[2], brect[3]), (0, 255, 0), 2) return image def draw_info_text(image, brect, hand_sign_text, finger_gesture_text): + """绘制手势信息文本 + Args: + image: 待绘制的画面 + brect: 边界框坐标 + hand_sign_text: 手部手势文本 + finger_gesture_text: 手指轨迹手势文本 + Returns: + 绘制后的画面 + """ + # 绘制背景框(覆盖边界框上方) cv.rectangle(image, (brect[0], brect[1] - 30), (brect[2], brect[1]), (0, 255, 0), -1) + # 绘制手部手势标签 info = f"Hand: {hand_sign_text}" cv.putText(image, info, (brect[0] + 5, brect[1] - 5), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 2) + # 绘制轨迹手势标签 if finger_gesture_text: cv.putText(image, f"Gesture: {finger_gesture_text}", (10, 60), cv.FONT_HERSHEY_SIMPLEX, 1.0, (0, 0, 255), 3) @@ -169,95 +233,114 @@ def draw_info_text(image, brect, hand_sign_text, finger_gesture_text): def draw_point_history(image, point_history): + """绘制轨迹点历史(指尖移动轨迹) + Args: + image: 待绘制的画面 + point_history: 轨迹点列表 + Returns: + 绘制后的画面 + """ for i, (x, y) in enumerate(point_history): - if x != 0 and y != 0: + if x != 0 and y != 0: # 跳过无效点 + # 轨迹点大小随索引递增(视觉层次感) cv.circle(image, (x, y), 2 + i // 2, (0, 255, 0), -1) return image def draw_info(image, fps, mode, number): + """绘制全局信息(FPS、模式、数字) + Args: + image: 待绘制的画面 + fps: 当前帧率 + mode: 当前模式 + number: 当前数字 + Returns: + 绘制后的画面 + """ + # 绘制FPS cv.putText(image, f"FPS: {fps}", (10, 30), cv.FONT_HERSHEY_SIMPLEX, 1.0, (0, 0, 255), 3) + # 绘制模式 mode_text = ["Idle", "Log Keypoint", "Log Point History"][mode] if 0 <= mode <= 2 else "Idle" cv.putText(image, f"Mode: {mode_text}", (10, 90), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 2) + # 绘制数字 if 0 <= number <= 9: cv.putText(image, f"Num: {number}", (10, 120), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 2) return image -# ========== 主函数 ========== +# ===================== 主程序入口 ===================== def main(): + # 1. 初始化参数和资源 args = get_args() - # 初始化摄像头 - cap = cv.VideoCapture(args.device) - cap.set(cv.CAP_PROP_FRAME_WIDTH, args.width) - cap.set(cv.CAP_PROP_FRAME_HEIGHT, args.height) + cap = cv.VideoCapture(args.device) # 打开摄像头 + cap.set(cv.CAP_PROP_FRAME_WIDTH, args.width) # 设置宽度 + cap.set(cv.CAP_PROP_FRAME_HEIGHT, args.height) # 设置高度 # 初始化工具类 cvFpsCalc = CvFpsCalc(buffer_len=10) keypoint_classifier = KeyPointClassifier() point_history_classifier = PointHistoryClassifier() - # 标签和历史数据 + # 初始化标签和历史数据 keypoint_labels = ["None", "Point", "Fist", "OK", "Peace", "ThumbUp", "ThumbDown", "PointGesture"] point_history_labels = ["None", "MoveUp", "MoveDown", "MoveLeft", "MoveRight"] - history_length = 16 - point_history = deque(maxlen=history_length) - finger_gesture_history = deque(maxlen=history_length) - mode = 0 + history_length = 16 # 轨迹点缓存长度 + point_history = deque(maxlen=history_length) # 指尖轨迹缓存 + finger_gesture_history = deque(maxlen=history_length) # 手势分类结果缓存 + mode = 0 # 初始模式:空闲 + # 2. 主循环(摄像头帧处理) while True: - # FPS计算 + # 计算当前FPS fps = cvFpsCalc.get() - # 按键处理 + # 按键处理(ESC退出) key = cv.waitKey(1) & 0xFF - if key == 27: # ESC退出 + if key == 27: break number, mode = select_mode(key, mode) # 读取摄像头帧 ret, frame = cap.read() - if not ret: + if not ret: # 帧读取失败则退出 break - frame = cv.flip(frame, 1) # 镜像显示 - debug_frame = copy.deepcopy(frame) - - # 【核心修改】跳过真实检测,直接模拟手部数据 - brect = calc_bounding_rect(debug_frame) - landmark_list = calc_landmark_list(debug_frame) + frame = cv.flip(frame, 1) # 镜像翻转(符合视觉习惯) + debug_frame = copy.deepcopy(frame) # 用于绘制的帧副本 - # 预处理 - pre_landmark = pre_process_landmark(landmark_list) - pre_point_history = pre_process_point_history(debug_frame, point_history) + # 3. 核心逻辑:模拟手部数据生成 + 预处理 + 分类 + brect = calc_bounding_rect(debug_frame) # 生成边界框 + landmark_list = calc_landmark_list(debug_frame) # 生成关键点 + pre_landmark = pre_process_landmark(landmark_list) # 关键点预处理 + pre_point_history = pre_process_point_history(debug_frame, point_history) # 轨迹点预处理 # 手势分类 - hand_sign_id = keypoint_classifier(pre_landmark) + hand_sign_id = keypoint_classifier(pre_landmark) # 关键点分类 + # 记录指尖轨迹(点手势时记录8号点,否则记录无效点) point_history.append(landmark_list[8] if hand_sign_id == 7 else [0, 0]) - # 手指手势分类 + # 轨迹手势分类(缓存满16*2个点时分类) finger_gesture_id = 0 if len(pre_point_history) == history_length * 2: finger_gesture_id = point_history_classifier(pre_point_history) finger_gesture_history.append(finger_gesture_id) + # 取最频繁的手势分类结果(防抖) most_common = Counter(finger_gesture_history).most_common(1) - # 绘制UI - debug_frame = draw_bounding_rect(debug_frame, brect) - debug_frame = draw_landmarks(debug_frame, landmark_list) - debug_frame = draw_info_text( + # 4. UI绘制 + debug_frame = draw_bounding_rect(debug_frame, brect) # 绘制边界框 + debug_frame = draw_landmarks(debug_frame, landmark_list) # 绘制关键点 + debug_frame = draw_info_text( # 绘制手势信息 debug_frame, brect, keypoint_labels[hand_sign_id] if hand_sign_id < len(keypoint_labels) else "Unknown", point_history_labels[most_common[0][0]] if most_common else "Unknown" ) + debug_frame = draw_point_history(debug_frame, point_history) # 绘制轨迹 + debug_frame = draw_info(debug_frame, fps, mode, number) # 绘制全局信息 - # 绘制辅助信息 - debug_frame = draw_point_history(debug_frame, point_history) - debug_frame = draw_info(debug_frame, fps, mode, number) - - # 显示窗口 + # 显示画面 cv.imshow('Hand Gesture Recognition (ESC to exit)', debug_frame) - # 释放资源 + # 3. 资源释放 cap.release() cv.destroyAllWindows() From c6eea875f5e71cdf1ec50c38fd5f79b0bd7be137 Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Sun, 21 Dec 2025 14:20:12 +0800 Subject: [PATCH 31/32] =?UTF-8?q?=E6=96=B0=E5=A2=9EDrone=5Fgesture=5Fopera?= =?UTF-8?q?tion/keypoint=5Fclassifier.py=EF=BC=9A=E6=97=A0=E4=BA=BA?= =?UTF-8?q?=E6=9C=BA=E6=89=8B=E5=8A=BF=E5=85=B3=E9=94=AE=E7=82=B9=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../keypoint_classifier.py | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Drone_gesture_operation/keypoint_classifier.py diff --git a/src/Drone_gesture_operation/keypoint_classifier.py b/src/Drone_gesture_operation/keypoint_classifier.py new file mode 100644 index 0000000000..3d055414e8 --- /dev/null +++ b/src/Drone_gesture_operation/keypoint_classifier.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import numpy as np +import tensorflow as tf + + +class KeyPointClassifier(object): + def __init__( + self, + model_path='model/keypoint_classifier/keypoint_classifier.tflite', + num_threads=1, + ): + self.interpreter = tf.lite.Interpreter(model_path=model_path, + num_threads=num_threads) + + self.interpreter.allocate_tensors() + self.input_details = self.interpreter.get_input_details() + self.output_details = self.interpreter.get_output_details() + + def __call__( + self, + landmark_list, + ): + input_details_tensor_index = self.input_details[0]['index'] + self.interpreter.set_tensor( + input_details_tensor_index, + np.array([landmark_list], dtype=np.float32)) + self.interpreter.invoke() + + output_details_tensor_index = self.output_details[0]['index'] + + result = self.interpreter.get_tensor(output_details_tensor_index) + + result_index = np.argmax(np.squeeze(result)) + + return result_index From f2dc1afafb922ab284726927d662b4b5d49edfcc Mon Sep 17 00:00:00 2001 From: jiangyi2302 <2592419327@qq.com> Date: Mon, 22 Dec 2025 00:32:24 +0800 Subject: [PATCH 32/32] =?UTF-8?q?=E4=BC=98=E5=8C=96Drone=5Fgesture=5Fopera?= =?UTF-8?q?tion/main.py=EF=BC=9A=E5=8F=AF=E5=88=87=E6=8D=A2=E4=B8=89?= =?UTF-8?q?=E7=A7=8D=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Drone_gesture_operation/main.py | 350 +++++++++++----------------- 1 file changed, 133 insertions(+), 217 deletions(-) diff --git a/src/Drone_gesture_operation/main.py b/src/Drone_gesture_operation/main.py index b5da6dc69d..c64b2e7b55 100644 --- a/src/Drone_gesture_operation/main.py +++ b/src/Drone_gesture_operation/main.py @@ -1,7 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# 功能:无人机手势识别模拟程序(适配Python3.13+Windows) -# 说明:移除MediaPipe/TensorFlow依赖,通过模拟手部数据实现核心逻辑展示 import copy import argparse import itertools @@ -13,219 +11,150 @@ import numpy as np -# ===================== 工具类:FPS计算 ===================== +# ========== FPS计算(还原初始版本,无多余逻辑) ========== class CvFpsCalc: - """帧率计算类,基于时间队列滑动平均计算FPS""" - def __init__(self, buffer_len=10): - self.buffer_len = buffer_len # 缓存长度(计算最近N帧的平均FPS) - self.times = deque(maxlen=buffer_len) # 时间戳队列 + self.buffer_len = buffer_len + self.times = deque(maxlen=buffer_len) def get(self): - """获取当前FPS值""" - self.times.append(time.perf_counter()) # 记录当前时间戳 - if len(self.times) < 2: # 至少需要2个时间戳才能计算 + self.times.append(time.perf_counter()) + if len(self.times) < 2: return 0 - # 计算平均FPS:帧数 / 总时间 - fps = len(self.times) / (self.times[-1] - self.times[0]) - return int(fps) + return int(len(self.times) / (self.times[-1] - self.times[0])) -# ===================== 模拟分类器(适配原逻辑) ===================== +# ========== 手势分类器(还原初始版本) ========== class KeyPointClassifier: - """关键点分类器(简化版)""" - def __call__(self, landmark_list): - # 固定返回7(对应PointGesture点手势,模拟分类结果) - return 7 + return 7 # 模拟点手势 class PointHistoryClassifier: - """轨迹点分类器(简化版)""" - def __call__(self, point_history): - # 固定返回0(对应None,模拟分类结果) return 0 - # ===================== 参数解析 ===================== - +# ========== 参数解析(还原初始版本) ========== def get_args(): - """解析命令行参数""" - parser = argparse.ArgumentParser(description="手部手势识别模拟程序") - parser.add_argument("--device", type=int, default=0, help="摄像头设备号(默认0)") - parser.add_argument("--width", type=int, default=960, help="摄像头画面宽度") - parser.add_argument("--height", type=int, default=540, help="摄像头画面高度") + parser = argparse.ArgumentParser() + parser.add_argument("--device", type=int, default=0) + parser.add_argument("--width", type=int, default=960) + parser.add_argument("--height", type=int, default=540) return parser.parse_args() -# ===================== 核心辅助函数 ===================== +# ========== 辅助函数(仅修复按键响应,不改动逻辑) ========== def select_mode(key, mode): - """根据按键切换操作模式 - Args: - key: 按键值 - mode: 当前模式(0:空闲 1:记录关键点 2:记录轨迹点) - Returns: - number: 按键数字(0-9),-1表示非数字键 - mode: 更新后的模式 - """ + """仅修复按键捕获,保留初始逻辑""" number = -1 - if 48 <= key <= 57: # 数字键0-9 + if 48 <= key <= 57: number = key - 48 - if key == ord('n'): # n键:切换到空闲模式 + # 还原初始按键判断,仅增加ASCII码兼容(不影响帧率) + if key == ord('n') or key == 110: mode = 0 - if key == ord('k'): # k键:切换到记录关键点模式 + elif key == ord('k') or key == 107: mode = 1 - if key == ord('h'): # h键:切换到记录轨迹点模式 + elif key == ord('h') or key == 104: mode = 2 return number, mode def calc_bounding_rect(image): - """生成模拟手部边界框(屏幕中心固定位置) - Args: - image: 摄像头帧画面 - Returns: - brect: 边界框坐标 [x1, y1, x2, y2] - """ + """还原初始逻辑""" h, w = image.shape[:2] - cx, cy = w // 2, h // 2 # 屏幕中心 - bw, bh = 200, 200 # 边界框尺寸 + cx, cy = w // 2, h // 2 + bw, bh = 200, 200 return [cx - bw // 2, cy - bh // 2, cx + bw // 2, cy + bh // 2] def calc_landmark_list(image): - """生成模拟21个手部关键点(适配原代码21点逻辑) - Args: - image: 摄像头帧画面 - Returns: - landmark_list: 21个关键点坐标列表 [[x1,y1], [x2,y2], ...] - """ + """还原初始逻辑""" h, w = image.shape[:2] - cx, cy = w // 2, h // 2 # 屏幕中心(关键点基准位置) + cx, cy = w // 2, h // 2 landmark_list = [] - # 0号点:手掌中心 landmark_list.append([cx, cy]) - # 1-4号点:拇指 - landmark_list.extend([[cx - 50, cy - 30], [cx - 80, cy - 60], [cx - 100, cy - 90], [cx - 110, cy - 110]]) - # 5-8号点:食指(8号点为指尖,点手势关键) - landmark_list.extend([[cx + 50, cy - 30], [cx + 80, cy - 60], [cx + 100, cy - 90], [cx + 110, cy - 110]]) - # 9-12号点:中指 - landmark_list.extend([[cx + 30, cy - 10], [cx + 50, cy - 40], [cx + 70, cy - 70], [cx + 80, cy - 90]]) - # 13-16号点:无名指 - landmark_list.extend([[cx + 10, cy + 10], [cx + 20, cy - 20], [cx + 30, cy - 50], [cx + 40, cy - 70]]) - # 17-20号点:小指 - landmark_list.extend([[cx - 10, cy + 10], [cx - 20, cy - 20], [cx - 30, cy - 50], [cx - 40, cy - 70]]) + landmark_list.append([cx - 50, cy - 30]) + landmark_list.append([cx - 80, cy - 60]) + landmark_list.append([cx - 100, cy - 90]) + landmark_list.append([cx - 110, cy - 110]) + landmark_list.append([cx + 50, cy - 30]) + landmark_list.append([cx + 80, cy - 60]) + landmark_list.append([cx + 100, cy - 90]) + landmark_list.append([cx + 110, cy - 110]) + landmark_list.append([cx + 30, cy - 10]) + landmark_list.append([cx + 50, cy - 40]) + landmark_list.append([cx + 70, cy - 70]) + landmark_list.append([cx + 80, cy - 90]) + landmark_list.append([cx + 10, cy + 10]) + landmark_list.append([cx + 20, cy - 20]) + landmark_list.append([cx + 30, cy - 50]) + landmark_list.append([cx + 40, cy - 70]) + landmark_list.append([cx - 10, cy + 10]) + landmark_list.append([cx - 20, cy - 20]) + landmark_list.append([cx - 30, cy - 50]) + landmark_list.append([cx - 40, cy - 70]) return landmark_list def pre_process_landmark(landmark_list): - """关键点预处理:相对坐标转换+归一化(适配原逻辑) - Args: - landmark_list: 原始关键点列表 - Returns: - 预处理后的一维归一化列表 - """ + """还原初始逻辑""" temp = copy.deepcopy(landmark_list) - if not temp: # 空值保护 + if not temp: return [] - - # 相对坐标:以0号点(手掌中心)为基准 base_x, base_y = temp[0][0], temp[0][1] for i in range(len(temp)): temp[i][0] -= base_x temp[i][1] -= base_y - - # 一维化 + 归一化(消除尺度影响) temp = list(itertools.chain.from_iterable(temp)) - max_val = max(map(abs, temp)) if temp else 1 # 除零保护 + max_val = max(map(abs, temp)) if temp else 1 return [x / max_val for x in temp] def pre_process_point_history(image, point_history): - """轨迹点预处理:相对坐标转换+归一化(适配原逻辑) - Args: - image: 摄像头帧画面 - point_history: 轨迹点历史列表 - Returns: - 预处理后的一维归一化列表 - """ + """还原初始逻辑""" temp = copy.deepcopy(point_history) - if not temp: # 空值保护 + if not temp: return [] - - # 相对坐标:以第一个点为基准 base_x, base_y = temp[0][0], temp[0][1] image_w, image_h = image.shape[1], image.shape[0] for i in range(len(temp)): - temp[i][0] = (temp[i][0] - base_x) / image_w # 归一化到[0,1] + temp[i][0] = (temp[i][0] - base_x) / image_w temp[i][1] = (temp[i][1] - base_y) / image_h - - # 一维化 return list(itertools.chain.from_iterable(temp)) -# ===================== 绘制函数(UI展示) ===================== def draw_landmarks(image, landmark_list): - """绘制手部关键点和连线 - Args: - image: 待绘制的画面 - landmark_list: 关键点列表 - Returns: - 绘制后的画面 - """ + """还原初始绘制逻辑(不改动)""" if len(landmark_list) == 0: return image - - # 手指连线定义(关键点索引对) links = [(2, 3), (3, 4), (5, 6), (6, 7), (7, 8), (9, 10), (10, 11), (11, 12), (13, 14), (14, 15), (15, 16), (17, 18), (18, 19), (19, 20), (0, 1), (1, 2), (2, 5), (5, 9), (9, 13), (13, 17), (17, 0)] - - # 绘制连线:黑色粗线+白色细线(立体效果) for (p1, p2) in links: - if p1 < len(landmark_list) and p2 < len(landmark_list): # 索引保护 + if p1 < len(landmark_list) and p2 < len(landmark_list): cv.line(image, tuple(landmark_list[p1]), tuple(landmark_list[p2]), (0, 0, 0), 6) cv.line(image, tuple(landmark_list[p1]), tuple(landmark_list[p2]), (255, 255, 255), 2) - - # 绘制关键点:指尖8号/12号等用大圆点,其余用小圆点 for i, (x, y) in enumerate(landmark_list): size = 8 if i in [4, 8, 12, 16, 20] else 5 - cv.circle(image, (x, y), size, (255, 255, 255), -1) # 白色填充 - cv.circle(image, (x, y), size, (0, 0, 0), 1) # 黑色边框 + cv.circle(image, (x, y), size, (255, 255, 255), -1) + cv.circle(image, (x, y), size, (0, 0, 0), 1) return image def draw_bounding_rect(image, brect): - """绘制手部边界框 - Args: - image: 待绘制的画面 - brect: 边界框坐标 [x1,y1,x2,y2] - Returns: - 绘制后的画面 - """ + """还原初始逻辑""" cv.rectangle(image, (brect[0], brect[1]), (brect[2], brect[3]), (0, 255, 0), 2) return image def draw_info_text(image, brect, hand_sign_text, finger_gesture_text): - """绘制手势信息文本 - Args: - image: 待绘制的画面 - brect: 边界框坐标 - hand_sign_text: 手部手势文本 - finger_gesture_text: 手指轨迹手势文本 - Returns: - 绘制后的画面 - """ - # 绘制背景框(覆盖边界框上方) + """还原初始逻辑""" cv.rectangle(image, (brect[0], brect[1] - 30), (brect[2], brect[1]), (0, 255, 0), -1) - # 绘制手部手势标签 info = f"Hand: {hand_sign_text}" cv.putText(image, info, (brect[0] + 5, brect[1] - 5), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 2) - # 绘制轨迹手势标签 if finger_gesture_text: cv.putText(image, f"Gesture: {finger_gesture_text}", (10, 60), cv.FONT_HERSHEY_SIMPLEX, 1.0, (0, 0, 255), 3) @@ -233,116 +162,103 @@ def draw_info_text(image, brect, hand_sign_text, finger_gesture_text): def draw_point_history(image, point_history): - """绘制轨迹点历史(指尖移动轨迹) - Args: - image: 待绘制的画面 - point_history: 轨迹点列表 - Returns: - 绘制后的画面 - """ + """还原初始逻辑""" for i, (x, y) in enumerate(point_history): - if x != 0 and y != 0: # 跳过无效点 - # 轨迹点大小随索引递增(视觉层次感) + if x != 0 and y != 0: cv.circle(image, (x, y), 2 + i // 2, (0, 255, 0), -1) return image def draw_info(image, fps, mode, number): - """绘制全局信息(FPS、模式、数字) - Args: - image: 待绘制的画面 - fps: 当前帧率 - mode: 当前模式 - number: 当前数字 - Returns: - 绘制后的画面 - """ - # 绘制FPS + """仅修复模式显示的可视化,不改动绘制逻辑""" cv.putText(image, f"FPS: {fps}", (10, 30), cv.FONT_HERSHEY_SIMPLEX, 1.0, (0, 0, 255), 3) - # 绘制模式 mode_text = ["Idle", "Log Keypoint", "Log Point History"][mode] if 0 <= mode <= 2 else "Idle" - cv.putText(image, f"Mode: {mode_text}", (10, 90), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 2) - # 绘制数字 + cv.putText(image, f"Mode: {mode_text}", (10, 70), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 2) if 0 <= number <= 9: - cv.putText(image, f"Num: {number}", (10, 120), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 2) + cv.putText(image, f"Num: {number}", (10, 100), cv.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 2) return image -# ===================== 主程序入口 ===================== +# ========== 主函数(仅修复退出/按键BUG,不改动核心逻辑) ========== def main(): - # 1. 初始化参数和资源 args = get_args() - cap = cv.VideoCapture(args.device) # 打开摄像头 - cap.set(cv.CAP_PROP_FRAME_WIDTH, args.width) # 设置宽度 - cap.set(cv.CAP_PROP_FRAME_HEIGHT, args.height) # 设置高度 + # 还原初始摄像头初始化(无多余硬件加速配置) + cap = cv.VideoCapture(args.device) + cap.set(cv.CAP_PROP_FRAME_WIDTH, args.width) + cap.set(cv.CAP_PROP_FRAME_HEIGHT, args.height) - # 初始化工具类 + # 还原初始初始化逻辑 cvFpsCalc = CvFpsCalc(buffer_len=10) keypoint_classifier = KeyPointClassifier() point_history_classifier = PointHistoryClassifier() - # 初始化标签和历史数据 keypoint_labels = ["None", "Point", "Fist", "OK", "Peace", "ThumbUp", "ThumbDown", "PointGesture"] point_history_labels = ["None", "MoveUp", "MoveDown", "MoveLeft", "MoveRight"] - history_length = 16 # 轨迹点缓存长度 - point_history = deque(maxlen=history_length) # 指尖轨迹缓存 - finger_gesture_history = deque(maxlen=history_length) # 手势分类结果缓存 - mode = 0 # 初始模式:空闲 - - # 2. 主循环(摄像头帧处理) - while True: - # 计算当前FPS - fps = cvFpsCalc.get() - - # 按键处理(ESC退出) - key = cv.waitKey(1) & 0xFF - if key == 27: - break - number, mode = select_mode(key, mode) - - # 读取摄像头帧 - ret, frame = cap.read() - if not ret: # 帧读取失败则退出 - break - frame = cv.flip(frame, 1) # 镜像翻转(符合视觉习惯) - debug_frame = copy.deepcopy(frame) # 用于绘制的帧副本 - - # 3. 核心逻辑:模拟手部数据生成 + 预处理 + 分类 - brect = calc_bounding_rect(debug_frame) # 生成边界框 - landmark_list = calc_landmark_list(debug_frame) # 生成关键点 - pre_landmark = pre_process_landmark(landmark_list) # 关键点预处理 - pre_point_history = pre_process_point_history(debug_frame, point_history) # 轨迹点预处理 - - # 手势分类 - hand_sign_id = keypoint_classifier(pre_landmark) # 关键点分类 - # 记录指尖轨迹(点手势时记录8号点,否则记录无效点) - point_history.append(landmark_list[8] if hand_sign_id == 7 else [0, 0]) - - # 轨迹手势分类(缓存满16*2个点时分类) - finger_gesture_id = 0 - if len(pre_point_history) == history_length * 2: - finger_gesture_id = point_history_classifier(pre_point_history) - finger_gesture_history.append(finger_gesture_id) - # 取最频繁的手势分类结果(防抖) - most_common = Counter(finger_gesture_history).most_common(1) - - # 4. UI绘制 - debug_frame = draw_bounding_rect(debug_frame, brect) # 绘制边界框 - debug_frame = draw_landmarks(debug_frame, landmark_list) # 绘制关键点 - debug_frame = draw_info_text( # 绘制手势信息 - debug_frame, brect, - keypoint_labels[hand_sign_id] if hand_sign_id < len(keypoint_labels) else "Unknown", - point_history_labels[most_common[0][0]] if most_common else "Unknown" - ) - debug_frame = draw_point_history(debug_frame, point_history) # 绘制轨迹 - debug_frame = draw_info(debug_frame, fps, mode, number) # 绘制全局信息 - - # 显示画面 - cv.imshow('Hand Gesture Recognition (ESC to exit)', debug_frame) - - # 3. 资源释放 - cap.release() - cv.destroyAllWindows() + history_length = 16 + point_history = deque(maxlen=history_length) + finger_gesture_history = deque(maxlen=history_length) + mode = 0 + + print("✅ 还原初始版本(30帧)| ESC退出 | n/k/h切换模式") + + try: + while True: + # 还原初始帧率计算 + fps = cvFpsCalc.get() + + # 修复按键响应(仅捕获,无多余逻辑) + key = cv.waitKey(1) & 0xFF + if key == 27: # ESC退出 + break + + # 还原初始模式切换 + number, mode = select_mode(key, mode) + + # 还原初始帧读取(无多余异常捕获) + ret, frame = cap.read() + if not ret: + break + + # 还原初始镜像+拷贝逻辑 + frame = cv.flip(frame, 1) + debug_frame = copy.deepcopy(frame) + + # 还原初始核心逻辑(不改动) + brect = calc_bounding_rect(debug_frame) + landmark_list = calc_landmark_list(debug_frame) + pre_landmark = pre_process_landmark(landmark_list) + pre_point_history = pre_process_point_history(debug_frame, point_history) + + hand_sign_id = keypoint_classifier(pre_landmark) + point_history.append(landmark_list[8] if hand_sign_id == 7 else [0, 0]) + + finger_gesture_id = 0 + if len(pre_point_history) == history_length * 2: + finger_gesture_id = point_history_classifier(pre_point_history) + finger_gesture_history.append(finger_gesture_id) + most_common = Counter(finger_gesture_history).most_common(1) + + # 还原初始绘制逻辑 + debug_frame = draw_bounding_rect(debug_frame, brect) + debug_frame = draw_landmarks(debug_frame, landmark_list) + debug_frame = draw_info_text( + debug_frame, brect, + keypoint_labels[hand_sign_id] if hand_sign_id < len(keypoint_labels) else "Unknown", + point_history_labels[most_common[0][0]] if most_common else "Unknown" + ) + debug_frame = draw_point_history(debug_frame, point_history) + debug_frame = draw_info(debug_frame, fps, mode, number) + + # 还原初始窗口显示 + cv.imshow('Hand Gesture Recognition', debug_frame) + + except KeyboardInterrupt: + pass + finally: + # 还原初始资源释放 + cap.release() + cv.destroyAllWindows() + print(f"✅ 退出 | 最终帧率:{fps}") if __name__ == '__main__':