Given a video, use the visual cues to detect the bumpiness of the road along with anomalies.
The project uses dense-trajectory features (THOTH) for extracting visual features.
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
The following will provide step by step instructions to collect features and running the bumpiness code.
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
- 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
- Aggregating the bumpiness across the videos (for both X and Y).
$python aggregateBumpiness.py --featureFile=MBHyFeatures.npy --outputFile=MBHyAggFeatures.npy --environ=dep
- 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
- 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
- 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
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.
-
Prerequisites: PyLint
-
Run the following command:
$pylint filename.py (eg. bumpiness.py)
- Place the video in the working directory.
- 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
- 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
- To clean up after the code is used:
$python script.py clean