This project introduces a vision-based sensor that was implemented on multiple long-span bridges in NYC using live traffic camera feed. Methods for noise filters, camera motion compensation and target detection are introduced to to evaluate a bridge's global and localized behavior in real-time. To see an example of how the code was applied when the Verrazano-Narrows was shaking earlier this year, and how movement was calculated just from a youtube video, check the paper in the repo!
New.York.s.Verrazano.Bridge.Groans.and.Shifts.in.High.Winds.-.YouTube.-.Google.Chrome.2020-12-08.11-51-01.mp4
The code defines a function that uses Computer Vision trackers in Python's OpenCV library to extract coordinates of the centroid of a user-defined bounding box.
In each frame i, the bounding box is defined as:
(π₯ππ; π¦ππ; ππ₯ππ; ππ¦ππ)
The boxβs centroid coordinates in each frame are:
(π₯ππ; π¦ππ) = (π₯ππ + ππ₯ππ/2; π¦ππ +ππ¦ππ/2)
The code produces a movemeent trace by assigning coordinates in each frame to a list across n frames:
[π]ππππππ‘ = [π₯ππ, π₯ππ+1, β¦ , π₯ππ]
[π]ππππππ‘ = [π¦ππ, π¦ππ+1, β¦ , π¦ππ
(video taken for demo purposes)
demo_readme.mp4
To get a better sense of the movement measured, we can manually define a bounding box on the first frame of the video to determine the size of the object in pixels f and convert the axis to inches or feet.
In this example, f = 50 pixels the real dimension is 3" (measured), so the scaling factor is: ππΉ = π/π in/pixel.
As the video is recorded, the camera might not be 100% stable, which would introduce noise to the signal. To remove camera shake, repeat step 1 but choose a real-life stationary target like the book sitting on the shelf for example.
We get the target's real displacement by subtracting the two displacements:
[π]πΆππππππ ππ‘ππ = [π]ππππππ‘ β [π]πΉππ₯ππ [π]πΆππππππ ππ‘ππ = [π]ππππππ‘ β [π]πΉππ₯ππ
To clean higher unwanted frequencies (noise), a low-pass filter is applied: