Skip to content

This project is designed to measure the distances between cars in a platooning on a circuit via image processing.

Notifications You must be signed in to change notification settings

Zimrahin/zTracking

Repository files navigation

zTracking

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

image


Instructions

Installation

Install Virtualenv

pip install virtualenv

Create environment in repository folder

virtualenv zTracking

Activate environment

zTracking\Scripts\Activate

Install requirements

pip install -r requirements.txt

Cropping

  • Download Kdenlive (open source software).
  • Drag video into Kdenlive and switch profile to 1080i (if videos are interlaced)

image

after

  • 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.

image

  • Cut clip at the star of a lap start
  • Cut clip at the end of a lap end

Write CSV

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. image

Select a box at the centre of the track for a pixel to centimetres conversion and press Enter image

Select a trackable area from the frontalmost car. Press Enter. Once processing is over, close the window image


Read CSV

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 coordinates
  • outputName is a CSV file containing the distances between cars taken from the input video
  • nCars is the number of cars in the platooning
  • writeVideo 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. image

A window with a plot of the track will appear. Close it. image

Select a trackable area from each car, from left to right. Press Enter each time a car is selected image


Write Video

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.

About

This project is designed to measure the distances between cars in a platooning on a circuit via image processing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages