[skeleton] use numpy whereever possible ;)

This commit is contained in:
Jan Grewe 2025-02-07 09:11:33 +01:00
parent 509405033a
commit 66aa79e47a

View File

@ -41,13 +41,8 @@ class Skeleton(QGraphicsRectItem):
@property
def length(self):
dist = 0.0
for i in range(1, len(self.bodyaxis)):
si = self.bodyaxis[i-1]
ei = self.bodyaxis[i]
sk = self._keypoints[si, :]
ek = self._keypoints[ei, :]
dist += np.sqrt((ek[0] - sk[0])**2 + (ek[1] - sk[1])**2)
bodykps = self._keypoints[self.bodyaxis, :]
dist = np.sum(np.sqrt(np.sum(np.diff(bodykps, axis=0)**2, axis=1)), axis=0)
return dist
# def mousePressEvent(self, event):