Giter VIP home page Giter VIP logo

sound-delay's Introduction

sound-delay

sound-delay

Background

sound-delay is a tool for estimating the distance of an explosion in a video from the point of view of the observer. Assuming that the light from the flash arrives at the observer almost instantaneously, the distance can be estimated by multiplying the time delay of the boom and flash of the explosion by the speed of sound. The use case is that you can geolocate an explosion with only one geolocated point of view (POV), while normally at least two POVs are required to triangulate the position of an event.

Instructions

Note: the example video in these instructions is contained in the example/ sub-directory.

video.mp4

First, install the required libraries:

pip install -r requirements.txt

Next, download the video you wish to process. If you have the ffmpeg library installed, then the audio can be extracted automatically by the code. If not, you need to manually extract the audio into a separate .wav file. This can be done easily with a free application like Audacity:

sound-delay

Now run the plotting script with the following command:

python plot_delay.py

Enter the path of the video file (and the audio file if manually extracted) into the prompt and press enter. Note, the audio can take a while to process, so it's recommended that you first crop your video to the relevant segment to minimize this processing time.

sound-delay

A time series plot will appear displaying the audio and video signals: sound-delay

Zoom in to the abrupt increase in loudness, associated with the boom of the explosion, and then zoom in to the increase in red intensity, associated with the flash. The vertical grid lines and time-axis tick marks will give an indication of these times. Alternatively, place your mouse cursor on these points, and the time in seconds will appear on the bottom right of the plot as "x=...". Given a typical video frame rate of 25 frames/second, the arrival times need only be estimated to two decimal places. For such a frame rate, it is best to estimate the flash time from the first elevated value of the red intensity, rather than the value just before it, like as follows: sound-delay

In contrast to the flash, due to the relatively high sample rate of most audio, the time of the explosion's boom should be estimated from the value immediately before the elevated loudness as follows: sound-delay

Now run the second script with the following command:

python distance.py

You will be prompted for the times of the flash and sound of the explosion and the local air temperature in degree Celsius. Upon pressing enter, the estimated distance and error bounds will appear in the terminal:

sound-delay

Note: For each second of time delay, a 10 degree Celsius temperature difference yields a 6 meter difference in distance. This may not be significant for many geolocation applications.

Optional Instructions

If the redness signal is noisy, crop the pixels of the video to only include the region of interest containing the explosion. You can use a program like iMovie if you are a Mac user for example.

sound-delay

The error estimate is measured using the frame rate of the video. Its default is 25 frames/second, yielding an error of about 7 meters, which is probably not significant for most geolocation applications. You can change it by opening the distance.py script with a text editor and entering it where the frame_rate variable is assigned. The plot_delay.py script outputs the frame rate to the terminal for later use in the ```distance.py`` script.

Miscellaneous

The concept of this tool is based on the explanation of @Dmojavensis on Twitter who wrote his own custom script (I believe in Matlab?). Give him a follow, he's a very talented geolocator. https://twitter.com/Dmojavensis/status/1696691599781290239

Contact

For questions or suggestions, contact me on Twitter @davidnewschool

sound-delay's People

Contributors

floriankilian avatar davidnewschool avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.