This Python sample may be slow depending on the event rate of the scene and the configuration of the algorithm. We provide it to allow quick prototyping. For better performance, look at the corresponding C++ sample.
Vibration Estimation using Python
The Python bindings of Metavision Analytics API can be used to estimate the frequency of vibrating objects.
metavision_vibration_estimation.py shows how to use the python bindings of Metavision Analytics SDK to compute:
a frequency map, that is a per-pixel estimation of the frequency of the received events
the dominant frequency among all pixels, that is the most common frequency.
This sample also allows computing the dominant frequency in ROIs and checking the frequency at specific locations (i.e. pixel by pixel) in the frequency map.
The source code of this sample can be found in
when installing Metavision SDK from installer or packages. For other deployment methods, check the page
Path of Samples.
Metavision Vibration Estimation sample visualizes the frequency map (i.e. frequency estimated per pixel), the dominant frequency in the camera’s FOV, and selected ROI(s) with their frequency(ies):
The sample allows the following interactions:
selecting an ROI (with mouse click and drag) for which the dominant frequency will be shown next to the ROI
moving a mouse pointer over vibrating pixels to see frequency pixel by pixel
How to start
To start the sample based on the live stream from your camera, run:
To start the sample based on recorded data, provide the full path to a RAW file (here, we use a file from our Sample Recordings):
python3 metavision_vibration_estimation.py -i monitoring_40_50hz.raw
python metavision_vibration_estimation.py -i monitoring_40_50hz.raw
To check for additional options:
python3 metavision_vibration_estimation.py -h
python metavision_vibration_estimation.py -h
Metavision Vibration Estimation sample implements the following pipeline:
Frequency Map Async Algorithm
metavision_sdk_analytics.FrequencyMapAsyncAlgorithm is used to generate a frequency map of the vibrating
objects from the CD events. The
metavision_sdk_analytics.FrequencyMapAsyncAlgorithm is asynchronous in the sense that a
frequency map is not produced for each input buffer of events but rather at a fixed refresh rate in the camera’s clock.
So for each input buffer of events, 0, 1 or N frequency map(s) might be produced.
To retrieve the frequency map, we subscribe to the output callback of the
This class is in charge of displaying the frequency map in a way that makes it easy for you to visualize the vibrating objects in the camera’s FOV.
Each input frequency map is converted to an RGB frame using the
and a given color map. In addition, the dominant frequency of the scene is computed using the
metavision_sdk_analytics.DominantValueMapAlgorithm and printed in the RGB frame.
Furthermore, the GUI allows you to define ROIs in the frequency map by clicking and dragging. The dominant frequency inside that ROI is then automatically computed.
Finally, you can check the frequency pixel by pixel by pointing the mouse cursor at a specific location in the frequency map.
All the previously described processing is done synchronously, meaning that for each input frequency map, an RGB frame is displayed and all the user interactions are handled.
The following image shows an example of a frequency map displayed in the GUI and in which an ROI has been defined: