Mediapipe: How is the normalization for the coordinates done?

Created on 9 Oct 2020  路  4Comments  路  Source: google/mediapipe

I have extracted the coordinate of the landmarks and the coordiantes of the bounding boxes of the hands but i have those values in a range of value between [0,1].
I see that the class defined are NormalizedLandmarkList and NormalizedRect so here you do normalization but honestly i don't understand how you do it.
Could you please explain?

Most helpful comment

You can use the following approach to do the conversion from normalized data to pixel coordinates.

x_px = min(math.floor(normalized_x * image_width), image_width - 1)
y_px = min(math.floor(normalized_y * image_height), image_height - 1)

All 4 comments

@mgyong @jiuqiant

You can use the following approach to do the conversion from normalized data to pixel coordinates.

x_px = min(math.floor(normalized_x * image_width), image_width - 1)
y_px = min(math.floor(normalized_y * image_height), image_height - 1)

thank you @jiuqiant this actually works, but for anyone trying it out remember that the hands model flips the image horizontally and so the predicted coordinates are made for the horizontally flipped image.
so before using the coordinates remember to either flip the image or coordinates.

honestly i did it using another way.
I got the coordinates extracted by the function landmark.x() .y() .z() and after multiply these numbers times 1920 for x and 720 for y because my dataset had only 1920x720 images.
I leave an image here, to show how i did
image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Cubbee picture Cubbee  路  5Comments

shraiwi picture shraiwi  路  5Comments

Choons picture Choons  路  4Comments

baocareos picture baocareos  路  5Comments

Devin0202 picture Devin0202  路  5Comments