Skip to content

Instantly share code, notes, and snippets.

@tieubinhco
Last active April 28, 2021 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tieubinhco/34c438ab6fea0389267bfef9f9227879 to your computer and use it in GitHub Desktop.
Save tieubinhco/34c438ab6fea0389267bfef9f9227879 to your computer and use it in GitHub Desktop.
Calculate speed using vision python
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