From 481768e305e507afbef9aa52d4949960bc683c5e Mon Sep 17 00:00:00 2001 From: Abdelrahman Abounegm Date: Sun, 7 Mar 2021 00:29:09 +0300 Subject: [PATCH 1/5] Add pipenv's ".venv" folder to gitignore This is useful for whoever prefers to keep the venv in the same folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 294b9d6..8e6a145 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ venv +.venv __pycache__ .idea video_output From 66a76c6f20995cf895d8c1c57c72789f4f2cbad2 Mon Sep 17 00:00:00 2001 From: Abdelrahman Abounegm Date: Sun, 7 Mar 2021 00:30:28 +0300 Subject: [PATCH 2/5] Disable TensorFlow's useless warnings --- vpt/processors/gaze_detector/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vpt/processors/gaze_detector/__init__.py b/vpt/processors/gaze_detector/__init__.py index 7adf2d1..25c72a2 100644 --- a/vpt/processors/gaze_detector/__init__.py +++ b/vpt/processors/gaze_detector/__init__.py @@ -1,5 +1,7 @@ """Human facial landmark detector based on Convolutional Neural Network.""" import math +import os +os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # To disable TF's warnings import cv2 import numpy as np @@ -12,6 +14,8 @@ from vpt.processors.base import ProcessorBase from vpt.sources.base import SourceBase +tf.get_logger().setLevel('ERROR') + class FaceDetector: """Detect human face from image""" From c4a98f09d0b14c8b3125aad42609aa444159325e Mon Sep 17 00:00:00 2001 From: Abdelrahman Abounegm Date: Sun, 7 Mar 2021 00:43:01 +0300 Subject: [PATCH 3/5] Default to recording if no action command given A placeholder is added until the real functionality is implemented --- vpt/__main__.py | 4 ++++ vpt/cli/cli.py | 2 +- vpt/cli/record.py | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/vpt/__main__.py b/vpt/__main__.py index 2a05c40..380abc6 100644 --- a/vpt/__main__.py +++ b/vpt/__main__.py @@ -1,4 +1,5 @@ """Main entry point for the package""" +from vpt.cli.record import record from vpt.cli.check import check from vpt.cli.cli import parse_args from vpt.cli.sources import print_audio_inputs, print_video_inputs, get_default_audio_input_name @@ -12,3 +13,6 @@ print_video_inputs() elif args['cmd'] == 'check': check() +elif args['cmd'] is None: + # If not argument, fall back to recording + record() diff --git a/vpt/cli/cli.py b/vpt/cli/cli.py index e7a3cb0..e55fb6d 100644 --- a/vpt/cli/cli.py +++ b/vpt/cli/cli.py @@ -12,7 +12,7 @@ def create_parser(audio_default=None): "to predict a person's state of work engagement and " "correlate that data with that person's keyboard/mouse " "activity") - subparsers = parser.add_subparsers(dest='cmd', required=True) + subparsers = parser.add_subparsers(dest='cmd') check_parser = subparsers.add_parser('check', description='Make sure your hardware is correctly ' diff --git a/vpt/cli/record.py b/vpt/cli/record.py index e69de29..aaf3ddd 100644 --- a/vpt/cli/record.py +++ b/vpt/cli/record.py @@ -0,0 +1,2 @@ +def record(): + pass From 4d20062888978dea32fd97fd599f888b652eeeda Mon Sep 17 00:00:00 2001 From: Abdelrahman Abounegm Date: Sun, 7 Mar 2021 01:11:09 +0300 Subject: [PATCH 4/5] Add PyInstaller with instructions and shortcuts --- .gitignore | 12 ++++++++++++ Pipfile | 3 +++ README.md | 11 ++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8e6a145..4063df2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,14 @@ +# Virtual environments venv .venv + +# Cache __pycache__ + +# IDEs .idea + +# Test output video_output audio.wav /keyboard_output.txt @@ -9,3 +16,8 @@ audio.wav /vpt-audio.wav /vpt-keyboard.txt /vpt-mouse.txt + +# PyInstaller +*.spec +build +dist diff --git a/Pipfile b/Pipfile index b7053a7..dd2ae14 100644 --- a/Pipfile +++ b/Pipfile @@ -19,9 +19,12 @@ matplotlib = "*" [dev-packages] python-language-server = {extras = ["all"], version = "*"} pylint = "*" +pyinstaller = "*" [requires] python_version = "3.8" [scripts] vpt = "python -m vpt" +bundle-win = "pyinstaller .\vpt\__main__.py --name vpt --distpath .\dist --add-data 'models;models'" +bundle-unix = "pyinstaller ./vpt/__main__.py --name vpt --distpath ./dist --add-data \"models:models\"" diff --git a/README.md b/README.md index 6eaf365..9454c80 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,17 @@ On Arch Linux, use: ## Usage -Run `pipenv run vpt `. For detailed usage information, run `pipenv run vpt -h`. +Run `pipenv run vpt `. For detailed usage information, run `pipenv run vpt -h`. If you are using Linux, you might need to run some commands as root (or with `sudo`) as [mouse recording](https://github.com/boppreh/mouse#:~:text=requires%20sudo) and [keyboard recording](https://github.com/boppreh/keyboard#:~:text=requires%20sudo) require it. + +## Bundling + +To bundle the application as a distributable executable, run `pipenv run bundle-win` on Windows, or `pipenv run bundle-unix` on most unix-based systems. +The resulting program can be found in the "_dist/vpt_" folder, with the exeuctable file itself called `vpt`. + +Note: The Windows version requires that the ["Microsoft C++ Redistributable +for Visual Studio 2015, 2017 and 2019"](https://support.microsoft.com/help/2977003/the-latest-supported-visual-c-downloads) be installed on the system before running. +They are **not** bundled with the program. From bf681f3ec120cc55278b94349445d82ae6ee15f4 Mon Sep 17 00:00:00 2001 From: Abdelrahman Abounegm Date: Sun, 7 Mar 2021 01:31:19 +0300 Subject: [PATCH 5/5] Change Windows script path delimiter to '/' Apparently, pipenv doesn't escape them properly when parsing TOML and it should have been '\\\\' for one '\', which is ridiculous. --- Pipfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pipfile b/Pipfile index dd2ae14..fc09a7a 100644 --- a/Pipfile +++ b/Pipfile @@ -26,5 +26,5 @@ python_version = "3.8" [scripts] vpt = "python -m vpt" -bundle-win = "pyinstaller .\vpt\__main__.py --name vpt --distpath .\dist --add-data 'models;models'" +bundle-win = "pyinstaller ./vpt/__main__.py --name vpt --distpath ./dist --add-data 'models;models'" bundle-unix = "pyinstaller ./vpt/__main__.py --name vpt --distpath ./dist --add-data \"models:models\""