/Video_Analytics

Developing sensor using Computer Vision to monitor movement and produce vibration trace of critical bridge elements.

Primary LanguageJupyter Notebook

Video_Analytics

Overview & real-life application

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

How it works:

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, … , 𝑦𝑐𝑛

User-Guide

(video taken for demo purposes)

1. Start by selecting a target and running the video

image

demo_readme.mp4

2. Scaling

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.

image

image

3. Compensating for Camera Movement/Shake

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.

image

We get the target's real displacement by subtracting the two displacements:

[𝑋]πΆπ‘œπ‘šπ‘π‘’π‘›π‘ π‘Žπ‘‘π‘’π‘‘ = [𝑋]π‘‡π‘Žπ‘Ÿπ‘”π‘’π‘‘ βˆ’ [𝑋]𝐹𝑖π‘₯𝑒𝑑 [π‘Œ]πΆπ‘œπ‘šπ‘π‘’π‘›π‘ π‘Žπ‘‘π‘’π‘‘ = [π‘Œ]π‘‡π‘Žπ‘Ÿπ‘”π‘’π‘‘ βˆ’ [π‘Œ]𝐹𝑖π‘₯𝑒𝑑

image

4. Signal Processing and filtering

To clean higher unwanted frequencies (noise), a low-pass filter is applied:

image