diff --git a/assets/aparna_front.jpg b/assets/aparna_front.jpg new file mode 100755 index 0000000..5d79364 Binary files /dev/null and b/assets/aparna_front.jpg differ diff --git a/assets/aparna_side.jpg b/assets/aparna_side.jpg new file mode 100755 index 0000000..b117add Binary files /dev/null and b/assets/aparna_side.jpg differ diff --git a/assets/sonali_front.jpg b/assets/sonali_front.jpg new file mode 100755 index 0000000..1ad63aa Binary files /dev/null and b/assets/sonali_front.jpg differ diff --git a/assets/sonali_side.jpg b/assets/sonali_side.jpg new file mode 100755 index 0000000..82eae59 Binary files /dev/null and b/assets/sonali_side.jpg differ diff --git a/backup.py b/backup.py index be444e7..b0c2dfa 100644 --- a/backup.py +++ b/backup.py @@ -254,7 +254,7 @@ class Landmarker: int(center_point[1] * self.front_image_resized.shape[0]), ) xc, yc = center_point - logging.warning(f"xc: {xc}") + logging.warning("xc: ", xc) logging.warning(f"yc: {yc}") self.circle(self.front_image_keypoints, xc, yc) diff --git a/landmarks.py b/landmarks.py index be444e7..83e14a1 100644 --- a/landmarks.py +++ b/landmarks.py @@ -91,7 +91,7 @@ class Landmarker: ) parser.add_argument( "--pixel_height", - default=255, + # default=216, dest="pixel_height", type=int, help="pixel height of person", @@ -151,6 +151,7 @@ class Landmarker: return real_distance def pixel_to_metric_ratio(self): + self.pixel_height = self.pixel_distance * 2 pixel_to_metric_ratio = self.person_height / self.pixel_height logging.warning("pixel_to_metric_ratio", pixel_to_metric_ratio) return pixel_to_metric_ratio @@ -184,6 +185,8 @@ class Landmarker: print("Distance between center and top point:", self.distance) + print("Height of person:", self.distance * 2) + def calculate_distance_betn_landmarks(self, front_results): if not front_results.pose_landmarks: return @@ -222,11 +225,11 @@ class Landmarker: cv2.imshow("edges", self.edges) cv2.waitKey(0) - def get_center_top_point(self, front_results): - gray_image = cv2.cvtColor(self.front_image_keypoints, + def get_center_top_point(self, side_results): + gray_image = cv2.cvtColor(self.side_image_keypoints, cv2.COLOR_BGR2GRAY) blurred_image = cv2.GaussianBlur(gray_image, (5, 5), 0) - roi = blurred_image[0:int(self.front_image_resized.shape[0] / 2), :] + roi = blurred_image[0:int(self.side_image_resized.shape[0] / 2), :] self.edges = cv2.Canny(roi, 50, 150) contours, _ = cv2.findContours(self.edges, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) @@ -238,11 +241,14 @@ class Landmarker: self.topmost_point = tuple( largest_contour[largest_contour[:, :, 1].argmin()][0]) xt, yt = self.topmost_point - self.circle(self.front_image_keypoints, xt, yt) + self.circle(self.side_image_keypoints, xt, yt) + logging.warning("xt: ", xt) + logging.warning(f"yt: ") xc, yc = None, None - landmarks = front_results.pose_landmarks.landmark - if front_results.pose_landmarks: + landmarks = side_results.pose_landmarks.landmark + + if side_results.pose_landmarks: # type: ignore left_hip = landmarks[pose.PoseLandmark.LEFT_HIP.value] right_hip = landmarks[pose.PoseLandmark.RIGHT_HIP.value] center_point = ( @@ -250,17 +256,17 @@ class Landmarker: (left_hip.y + right_hip.y) / 2, ) center_point = ( - int(center_point[0] * self.front_image_resized.shape[1]), - int(center_point[1] * self.front_image_resized.shape[0]), + int(center_point[0] * self.side_image_resized.shape[1]), + int(center_point[1] * self.side_image_resized.shape[0]), ) xc, yc = center_point - logging.warning(f"xc: {xc}") + logging.warning("xc: ", xc) logging.warning(f"yc: {yc}") - self.circle(self.front_image_keypoints, xc, yc) - - self.distance = self.euclidean_distance( - xc, xt, yc, yt) * self.pixel_to_metric_ratio() + self.circle(self.side_image_keypoints, xc, yc) + self.pixel_distance = self.euclidean_distance(xc, xt, yc, yt) + self.distance = self.euclidean_distance( + xc, xt, yc, yt) * self.pixel_to_metric_ratio() return self.distance