update code
This commit is contained in:
parent
4518cc7e12
commit
7ffdaaca26
BIN
assets/aparna_front.jpg
Executable file
BIN
assets/aparna_front.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 3.2 MiB |
BIN
assets/aparna_side.jpg
Executable file
BIN
assets/aparna_side.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 3.2 MiB |
BIN
assets/sonali_front.jpg
Executable file
BIN
assets/sonali_front.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 3.1 MiB |
BIN
assets/sonali_side.jpg
Executable file
BIN
assets/sonali_side.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 3.0 MiB |
@ -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)
|
||||
|
||||
|
30
landmarks.py
30
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.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
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user