Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calculate the pixel length in meters #9

Open
MasterMedo opened this issue Aug 31, 2021 · 1 comment · Fixed by #10
Open

calculate the pixel length in meters #9

MasterMedo opened this issue Aug 31, 2021 · 1 comment · Fixed by #10
Assignees

Comments

@MasterMedo
Copy link
Owner

Based on the subject height and body part length ratios, calculate the length of n pixel in meters.

average_height = 1.75  # height in meters

def pixel_meter_ratio(body_part_positions: list[list[float, float, float]], height: float = average_height) -> float

Takes a list of body part positions (17 body parts). The elements are [x coordinate in pixels, y coordinate in pixels, confidence]:

[
    [320, 524, 0.123],
    [320, 524, 0.123],
    [320, 524, 0.123],
    [320, 524, 0.123],
    [320, 524, 0.123],
    [320, 524, 0.123],
    [320, 524, 0.123],
    [320, 524, 0.123],
    [320, 524, 0.123],
    [320, 524, 0.123],
    [320, 524, 0.123],
    [320, 524, 0.123],
    [320, 524, 0.123],
    [320, 524, 0.123],
    [320, 524, 0.123],
    [320, 524, 0.123],
    [320, 524, 0.123],
]

Returns the pixel/meter ratio:

106.13
@MasterMedo MasterMedo changed the title calculate the pixel length in real world calculate the pixel length in the real world Aug 31, 2021
@MasterMedo MasterMedo changed the title calculate the pixel length in the real world calculate the pixel length in meters Aug 31, 2021
@MasterMedo MasterMedo linked a pull request Sep 1, 2021 that will close this issue
@MasterMedo
Copy link
Owner Author

The code we have currently for calculating the ratio of a pixel and a meter works decently when the athlete is facing the camera or is turned away from the camera. It also works great if the camera sees the athlete's profile if the torso or the thighs can be detected.

What currently doesn't work so well is when the athlete's profile waist up is the only thing the camera sees. Then the algorithm concludes falsely that the athlete is facing the camera. It concludes the person is far away from the camera and tiny, which isn't the case. I propose assuming we can see more of the athlete's body the farther the athlete is from the camera. Other suggestions are welcome.

@MasterMedo MasterMedo reopened this Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants