/Bumpiness_Detector

Given a video, use the visual cues to detect the bumpiness & anomalies.

Primary LanguagePythonMIT LicenseMIT

Bumpiness Detector

Given a video, use the visual cues to detect the bumpiness of the road along with anomalies.

Getting Started

The project uses dense-trajectory features (THOTH) for extracting visual features.

Prerequisites

For Dense trajectory features:

OpenCV-2.4.2 (python)
ffmpeg-0.11.1

For Bumpiness-Detector:

sklit-learn-0.18.1 (python)
matplotlib (1.3.1 +)
SciPy
Numpy v1.12

Running the code

The following will provide step by step instructions to collect features and running the bumpiness code.

Dense Trajectory features

Assuming you have the THOTH software installed, go to the directory:

$ cd dense_trajectory_release_v1.2

Run the following code to collect features:

./release/DenseTrack ./path_to_video > /path_to_output_directory/out.features

The Bumpiness Detector

  1. Getting the bumpiness values (use this code twice, to get both the MBHx (feature == 0) and MBHy (feature == 1) :
$python bumpiness.py --videoName=movie0-10.mp4 --featureFile=0-10.features --featureOutputFile==MBHyFeatures.npy --feature=0 --environ=dep
  1. Aggregating the bumpiness across the videos (for both X and Y).
$python aggregateBumpiness.py --featureFile=MBHyFeatures.npy --outputFile=MBHyAggFeatures.npy --environ=dep
  1. Getting the labels of the video through K-means clustering:
$python clusterBumpiness.py --MBHx=MBHxAggFeatures.npy --MBHy=MBHyAggFeatures.npy --labelFile=labels.npy --clusterOutfile=clusters.npy --environ=dep
  1. Plotting the graph and labels on the video:
$python videoGraphs.py --movieName=Movie1.mp4 --MBHx=MBHxAggregateFeatures.npy --MBHy=MBHyAggregateFeatures.npy --labelFile=labels.npy --outputDirectory=outputVideo --environ=dep
  1. Go to the output Directory of step 4 and run the following command to get the video named "test.mp4":
ffmpeg -r 29 -f image2 -s 1920x1080 -i image%04d.jpeg -vcodec libx264 -crf 25  -pix_fmt yuv420p test.mp4

Running the tests

The tests for this project are written in the directory unitTests. To run them use the following command:

$python test.py

Where test is the name of the test in the given directory.

And coding style tests

  1. Prerequisites: PyLint

  2. Run the following command:

$pylint filename.py (eg. bumpiness.py)

Deployment

Initialization

  1. Place the video in the working directory.
  2. Place the video sentences in a subdirectory. Each video sentence should follow the following naming convention:
movieStartTime_EndTime.mp4

Examples:

movie0-10.mp4
movie5-14.mp4

...
movie50-60.mp4

Running the script

  1. To run the entire script do:
$python script.py make videoSentence_directory video

Your video should be in the directory outputVideo with the name test.mp4

  1. To clean up after the code is used:
$python script.py clean

Authors

  1. Akhita Mittel (cs13b1040@iith.ac.in)

  2. Naveen Chedeti (cs13b1010@iith.ac.in)

  3. Prashanth Dewangan (cs13b1025@iith.ac.in)

  4. Anudeepthi Koppula (cs13b1019@iith.ac.in)