Last active
April 28, 2021 05:01
-
-
Save tieubinhco/34c438ab6fea0389267bfef9f9227879 to your computer and use it in GitHub Desktop.
Calculate speed using vision python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def estimateSpeed(location1, location2): | |
d_pixels = math.sqrt(math.pow(location2[0] - location1[0], 2) + math.pow(location2[1] - location1[1], 2)) | |
# ppm = location2[2] / carWidht | |
ppm = 8.8 | |
d_meters = d_pixels / ppm | |
#print("d_pixels=" + str(d_pixels), "d_meters=" + str(d_meters)) | |
fps = 18 | |
speed = d_meters * fps * 3.6 | |
return speed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment