This project is designed to measure, via image processing, the distances between cars in a platooning on a circuit.
Instructions for its use are separated into five sections:
- Installation
- Cropping
- Write CSV
- Read CSV and results
- Write video
pip install virtualenv
virtualenv zTracking
zTracking\Scripts\Activate
pip install -r requirements.txt
- Download Kdenlive (open source software).
- Drag video into Kdenlive and switch profile to 1080i (if videos are interlaced)
- Right click -> Cut Clip to cut the video at the start and end of a lap once the cars are moving. This is done to create a coordinate map of the track.
writeTrack.py
is used to create a coordinate map of the track from a cropped video of one lap.
python writeTrack.py --fileName "crop.mp4" --outputName "trackPoints.csv"
fileName
is the cropped video containing one lap.outputName
is the name of the output CSV file which contains the track coordinates
Once the script is running, a window with the first frame of the video will appear. Select four points that make a rectangle in order to make a perspective transform.
Select a box at the centre of the track for a pixel to centimetres conversion and press Enter
Select a trackable area from the frontalmost car. Press Enter. Once processing is over, close the window
readTrack.py
is used to read a coordinate map of a track and a video
python readTrack.py --fileName "prueba_1.mp4" --trackName "trackPoints.csv" --outputName "results.csv" --nCars 5 --writeVideo
fileName
is the video containing an experiment.trackName
is the name of the input CSV file which contains the track coordinatesoutputName
is a CSV file containing the distances between cars taken from the input videonCars
is the number of cars in the platooningwriteVideo
is a flag that determines whether frames are saved. A folder named frames must be created beforehand within the project folder in order for this to work.
Once the script is running, select a box at the centre of the track for a pixel to centimetres conversion. Press Enter.
A window with a plot of the track will appear. Close it.
Select a trackable area from each car, from left to right. Press Enter each time a car is selected
writeVideo.py
is used to write a video from images stored in frames folder
python writeVideo.py --outputName output
outputName
is the name of the output file.