Demo scripts to use for OpenCV projects.
record_video.py
: record videos using terminal and save to desired location in local systemdownsize_video.py
: downsample a video with fps, for eg. recorded at 24 fps but downsample at 4 fpstest_output.py
: view the tentative output window for testingprocess_output.py
: post-process input video stream and get live predictionstrain_model.py
: train a model on mnist dataset and save it to use with test_output.pyaugment_dataset.py
: script to process all raw videos and create an augmented data-set from the selected data augmentation methods
flip_video.py
: horizontally flip recorded videosconvert_to_gray.py
: convert colored videos to grayscaleinvert_color.py
: invert image colors instead of converting to grayscaleblur_video.py
: add gaussian/averaging blur to videos
- create the model to train using PyTorch
- finalize data-set to use
- add padding for shorter videos, or clip frames for longer videos, to train on in case number of input frames is fixed
- create a new script to train and test model outputs
- create a new output window for live testing
- complete report by November 19th
- May 2021 - Tentative outline
- Aug 2021 - Progress and updated outline
- Nov 2021 - Final Report
- May 2021 - Tentative outline
- 13 May 2021 - Introductory presentation
- 22 Jun 2021 - Progress and updates
- 22 Jul 2021 - Progress and updates
- 10 Sep 2021 - Updated outline and progress
- 08 Oct 2021 - Progress Updates
- 29 Oct 2021 - Progress Updates
- 19 Nov 2021 - Final Presentation
The following steps are confirmed to work on Windows 10 and macOS.
The first step is to clone this repository into a desired local directory, and switch to the project:
git clone https://github.com/manikd31/opencv-scripts.git
cd opencv-scripts
Once cloned, install the dependencies specified in the file requirements.txt
within a virtual environment, preferably using miniconda. To create the virtual environment, use the command:
conda create -y -n opencv-scripts
conda activate opencv-scripts
And then, install the dependencies using:
pip install -r requirements.txt
The first step to using any of the scripts is to populate/update the constants.py
file with the relevant default values used across the project. The most relevant ones will be:
TEST_PATH_IN = r"C:/Users/user/Desktop"
TEST_PATH_OUT = r"C:/Users/user/Desktop"
TEST_FILE_NAME = "video_name.mp4"
To begin using the scripts, follow the commands mentioned below:
Use this script to record several videos in your desired directory just with the help of a few key presses.
-
Run the script using the command:
python record_video.py
-
When prompted about the video resolution, select the one you wish to use (select 480p for low-res 640x480 videos)
Select the video resolution: > 480p 720p 1080p
-
Next, specify the path to save the recorded videos to (if the directory doesn't exist, the program will create one)
Enter the path to save the videos to: C:/Users/user/Desktop
-
And finally, enter the name of the video (with or without the extension .MP4)
Enter the video name: video_name.mp4
When recording, the videos will be saved with a number at the end, for example, the first 2 videos with the name video_name.mp4
will become video_name_0.mp4
and video_name_1.mp4
to avoid overwriting files with same names.
To manipulate the video recording mechanism, there are key shortcuts on the screen. The display also shows if a video is being recorded or not, and how long the video has been recorded so far. These keypresses are as follows:
- Press
R
to start recording a video if not currently recording. - Press
E
to end the current video recording and save it to the directory. - Press
Q
to terminate the script and get back to the terminal.
Use these data augmentation methods on raw videos to create a variety of different styles of videos to enhance the dataset.