Utilizing the ORB (Oriented FAST and Rotated BRIEF) algorithm, distinct keypoints in both images were pinpointed. These keypoints, representative of unique image features, were then matched between the two images using a Brute-Force Matcher. This step was pivotal in determining corresponding points in the two images, illustrating the car's movement.
The average displacement of the car between the two images is approximately:
Δx≈−10.44 pixels (in the horizontal direction)
y≈−23.62 pixels (in the vertical direction)
The negative sign indicates the direction of movement. For instance, a negative Δx suggests that the car moved to the left, and a negative Δy implies an upward movement.
Motion Estimation:
With the matched keypoints, we calculated the average displacement, signifying the car's movement in the image domain.
A vital step was identifying a consistent reference object in both images - a white pipe cap on the road. This object's diameter in the image was gauged, and with its known real-world diameter (assumed 15 cm), we derived a pixel-to-real-world ratio. This conversion metric was essential to translate the car's pixel-based movement into an actual physical distance.
The corrected detection of the white pipe cap (south of the car) is highlighted with a green contour in the displayed region of interest. Based on our refined detection, the diameter of the pipe cap is approximately 19 pixels.
Given that the actual diameter of the pipe cap is assumed to be 0.15 meters (or 1515 cm), we can compute the new pixel-to-real-world ratio.
Pixel-to-Real-World Ratio = (0.15 meters / 0.19 pixels)
Using this updated ratio, we can convert the car's movement from pixels to meters.
Δx≈−0.0825 meters (or -8.25 cm) in the horizontal direction.
Δy≈−0.1865 meters (or -18.65 cm) in the vertical direction.
Speed Estimation:
Let's assume an average shot-to-shot time of 1 second. If you know the exact time or have a specific iPhone model in mind, please let me know, and I can adjust accordingly.
Given this interval, we can compute the speed of the car in both the x and y directions using the formula:
Speed= Distance/Time
# Time interval between the two frames (in seconds)
time_interval =1.0# Assuming 1 second for shot-to-shot time
# Compute the speed of the car in both x and y directions
speed_x = dx_meters_corrected / time_interval
speed_y = dy_meters_corrected / time_interval
# Compute the overall speed (magnitude) of the car