From c48b63903a54546f2e816a827b63b2f27fa35026 Mon Sep 17 00:00:00 2001 From: Liar <1780993390@qq.com> Date: Wed, 8 Jun 2022 18:27:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E6=97=8B=E8=BD=AC90?= =?UTF-8?q?=C2=B0=E4=BC=9A=E9=97=AA=E9=80=80=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/demo.py b/demo.py index 5f30242..286259a 100644 --- a/demo.py +++ b/demo.py @@ -110,17 +110,21 @@ class HandDetector: return self.lmList, bbox_info def revolve(self, img, draw=True): - """ - 旋转手势识别点 - :param img: 要查找的主图像 - :param draw: 在图像上绘制输出的标志。(默认绘制矩形框) - :return: 像素格式的手部关节位置列表 - """ + # print(self.lmList) point_x = self.lmList[0][0] point_y = self.lmList[0][1] - theta = math.atan((self.lmList[13][0] - point_x) / (self.lmList[13][1] - point_y)) - if self.lmList[13][1] - point_y > 0: - theta = theta + math.pi + delta_x = self.lmList[13][0] - point_x + delta_y = self.lmList[13][1] - point_y + if delta_y == 0: + if delta_x < 0: + theta = math.pi / 2 + else: + theta = -math.pi / 2 + else: + theta = math.atan(delta_x / delta_y) + if delta_y > 0: + theta = theta + math.pi + # print(theta*180/math.pi) for i in self.lmList: px, py = Rotate(theta, i[0], i[1], point_x, point_y) px = int(px)