Auto detection of stop / start in driving videos. This application is designed to help users process dashcam footage where the speedometer is visible and automatically detect "boring parts" of the video—those where the car is stationary, such as at stoplights.
By leveraging Optical Character Recognition (OCR) and frame processing, the application identifies when the car stops and moves, logs these events, and can export clips of only the moving segments for easier review.
fsd-detector-small.1.mp4
- Detect and log stop/start events: Automatically identify when a vehicle is stationary and moving based on the visible speedometer.
- Generate logs: Create a detailed log with timecodes showing when the vehicle starts and stops.
- Create an annotated video: Optionally overlay the detected speed and vehicle status (Stopped/Moving) on the video.
- Export clips of moving segments: Automatically cut out and export only the parts of the video when the car is moving.
- Customizable: Offers multiple configuration options, including the ability to disable video generation or specify the output directory for clips.
http://aiblocks.ai/users/bdekraker/fsd-detect/
To use this application, you will need to install a few dependencies:
-
Python 3.x: Ensure you have Python 3 installed.
-
Tesseract OCR: Required for reading the speedometer in the dashcam footage.
-
FFmpeg: Required for frame extraction, video processing, and merging.
This version expects a digital speedometer to be visible in the video, in order to properly detect when the vehicle is stopped or moving.
The following Python libraries are required and can be installed using pip
:
opencv-python
pytesseract
matplotlib
Pillow
numpy
You can install the dependencies all at once by using the requirements.txt
file included in this repository. To install the dependencies with pip, run the following command:
pip install -r requirements.txt
This will automatically install all the necessary Python packages.
Make sure you have Python 3.x installed on your machine. You can download it from python.org.
- Download Tesseract from the official GitHub repo: Tesseract OCR for Windows.
- Install it.
- After installation, make sure to add the path to Tesseract to your system's environment variables. For example:
C:\Program Files\Tesseract-OCR\tesseract.exe
You can install Tesseract using your package manager:
sudo apt update
sudo apt install tesseract-ocr
-
Install Homebrew if you haven't already. Homebrew is a package manager for macOS and is the easiest way to install Tesseract. To install Homebrew, open your terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
After Homebrew is installed, install Tesseract by running the following command in your terminal:
brew install tesseract
-
Verify that Tesseract was installed correctly by running:
tesseract --version
-
You should see version information about Tesseract, which confirms it is installed and available in your system's PATH.
-
If you installed Tesseract using Homebrew, the default location for Tesseract on macOS is
/usr/local/bin/tesseract
. The application should automatically detect it, but if needed, you can specify the path manually in your code:pytesseract.pytesseract.tesseract_cmd = '/usr/local/bin/tesseract'
- Download the FFmpeg executable from ffmpeg.org.
- Follow the instructions for adding FFmpeg to your PATH.
Install FFmpeg using your package manager:
sudo apt update
sudo apt install ffmpeg
-
Similar to Tesseract, the easiest way to install FFmpeg on macOS is using Homebrew. If you haven't installed Homebrew, follow the instructions in the macOS section under "Install Tesseract OCR."
-
To install FFmpeg with Homebrew, run the following command in your terminal:
brew install ffmpeg
-
Verify the installation by running:
ffmpeg -version
-
You should see version information about FFmpeg, which confirms it is installed and available in your system's PATH.
Once Python is installed, you can install the required dependencies by running the following command:
pip install opencv-python pytesseract matplotlib Pillow numpy
Alternatively, you can install all the required Python libraries from the requirements.txt
file using the following command:
pip install -r requirements.txt
You can run the application by executing the Python script:
python speed.py
This will open a file dialog where you can select your dashcam video file (formats like .mp4
, .avi
, .mov
, .mkv
are supported).
bounding2.mp4
The application will display the first frame of the video. Draw a bounding box around the area of the speedometer. Once you have done this, press Enter
to confirm.
- Dwell log: A log file
dwell_log.txt
will be generated, recording the timestamps of when the car starts and stops moving. - Annotated video (optional): The script can generate a new video file (
output_video.mp4
) with the speed and status (Moving/Stopped) overlaid on the frames.
You can control various aspects of the application using command-line flags.
Specify an FPS for processing of the video. This affects both reading the speed and outputting an annotated (speed overlayed) video. Default FPS is 3. Higher FPS takes longer to process.
By default, the script generates an annotated output video. You can disable this feature by using the --no-video
flag, which will only generate the log file:
python speed.py --no-video
This option enables the automatic exporting of moving segments from the video, so you only retain the parts where the car is moving. The moving segments are saved as separate video clips.
python speed.py --export-clips
You can specify a custom folder for saving the clips generated by the --export-clips
flag:
python speed.py --export-clips --clip-folder path/to/clip_folder
If no folder is specified, clips will be saved in a default folder named clips
.
-
Basic Run: Run the script, generate both the log and the annotated video.
python speed.py
-
Generate Logs Only (no video output):
python speed.py --no-video
-
Export Moving Segments: Split the video into multiple clips, with each clip containing only the time when the car is moving.
python speed.py --export-clips
-
Export Moving Segments to a Custom Folder:
python speed.py --export-clips --clip-folder path/to/clip_folder
After processing is completed, temporary frames that were extracted from the video will be cleaned up automatically to save disk space.
If the script fails with a message saying "Tesseract not found", ensure that:
- Tesseract is installed.
- You have added the path to
tesseract.exe
(on Windows) to your system’s PATH environment variable.
If FFmpeg is not found, install it and ensure it is added to your system’s PATH variable. You can check if FFmpeg is installed correctly by running the following in your terminal:
ffmpeg -version
This project is licensed under the MIT License - see the LICENSE file for details.
If you'd like to contribute to this project, feel free to submit issues and pull requests. Be sure to follow best practices and make sure all features are tested before submission.
- Tesseract OCR for text extraction.
- FFmpeg for video processing.
- The OpenCV and Matplotlib communities for their invaluable Python libraries.