Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
FROM ubuntu:22.04
FROM ubuntu:20.04

WORKDIR /app

ENV DEBIAN_FRONTEND=noninteractive

COPY requirements.txt .

RUN apt-get update && \
apt-get install --no-install-recommends --yes python3-opencv python3-pip python3-psutil python3-ipython ffmpeg && \
apt-get install --no-install-recommends --yes python3-opencv python3-pip python3-psutil python3-ipython ffmpeg build-essential python3-dev && \
pip install -r requirements.txt

ENV PYTHONUNBUFFERED=1

COPY dashcamcleaner .
COPY src .

VOLUME /input
VOLUME /output
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include src/dashcamcleaner/weights/*.pt
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<a href="#getting-started">Getting Started</a>
<ul>
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="installation-via-pypi">Installation via PyPI</a></li>
<li><a href="#installation-example-on-windows-using-conda">Installation example on Windows using Conda</a></li>
</ul>
</li>
Expand Down Expand Up @@ -57,9 +58,13 @@ To get a local copy up and running follow these simple steps.

You need a working Python environment with a Python version of 3.8 or higher that satisfies the listed `requirements.txt`. Depending on your machine, you can leverage GPU acceleration for pytorch - see [here](https://pytorch.org/get-started/locally/) or just use `requirements-gpu.txt`.


Since OpenCV does not care about audio channels, ffmpeg is used to combine the edited video and the audio channel of the input video. The environment variable `FFMPEG_BINARY` needs to be set to the ffmpeg executable for this to work.

### Installation via PyPI

Dashcamcleaner can now be installed via PyPI too. Run `pip install -i https://test.pypi.org/simple/ dashcamcleaner`. If that goes well, you can run the tool with
`python -m dashcamcleaner` from anywhere. If you don't supply any arguments the GUI will be used, otherwise the CLI.

### Installation example on Windows using Conda

1. Clone the repo
Expand Down
Empty file removed dashcamcleaner/__init__.py
Empty file.
Empty file removed dashcamcleaner/src/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[metadata]
description_file=README.md
license_files=LICENSE.txt
48 changes: 48 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import os
from setuptools import setup

readme = os.path.join(os.path.dirname(__file__), "README.md")
with open(readme, "r") as f:
long_description = f.read()

setup(
name='dashcamcleaner',
version='0.2.1',
description='Blur license plates and faces in videos',
url='https://github.com/tfaehse/DashcamCleaner',
author='Thomas Fähse',
author_email='[email protected]',
license='MIT',
long_description=long_description,
long_description_content_type='text/markdown',
packages=['dashcamcleaner'],
package_dir={'': 'src'},
include_package_data=True,
install_requires=[
"opencv-python>=4.5.3.56,<=4.6.0.66",
"pandas>=1.4.3,<=1.5.0",
"imageio==2.22.1",
"imageio-ffmpeg==0.4.7",
"ipython>=8.0.0,<=8.5.0",
"psutil>=5.6.4,<=5.9.2",
"more_itertools>=8.1.0,<=8.14.0",
"Pillow>=8.1.1,<=9.2.0",
"PySide6>=6.3.0,<=6.3.2",
"PyYAML>=6.0",
"requests>=2.28.0",
"scipy>=1.7.3,<=1.9.1",
"seaborn>=0.11.2,<=0.12.0",
"tensorboard==2.10.1",
"torch==1.12.1",
"torchaudio==0.12.1",
"torchvision==0.13.1",
"tqdm"
],

classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
],
)
6 changes: 6 additions & 0 deletions src/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env python3

from dashcamcleaner.main_cli import run_cli

if __name__ == "__main__":
run_cli()
8 changes: 8 additions & 0 deletions src/dashcamcleaner/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""
dashcamcleaner.

Censor faces and license plates in videos.
"""

__version__ = "0.2.1"
__author__ = 'Thomas Fähse'
9 changes: 9 additions & 0 deletions src/dashcamcleaner/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from .main import run_app
from .main_cli import run_cli
import sys

if __name__ == "__main__":
if len(sys.argv) > 1:
run_cli()
else:
run_app()
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import numpy as np
import torch
from more_itertools import chunked
from src.bounds import Bounds
from src.detection import Detection
from .bounds import Bounds
from .detection import Detection
from tqdm import tqdm


Expand All @@ -26,7 +26,7 @@ def __init__(self: 'VideoBlurrer', weights_name: str, parameters: Dict[str, Unio
self.parameters = parameters
self.detections = []
weights_path = os.path.join(
os.path.dirname(os.path.dirname(__file__)),
os.path.dirname(__file__),
"weights",
f"{weights_name}.pt".replace(".pt.pt", ".pt"),
)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.bounds import Bounds
from .bounds import Bounds


class Detection:
Expand Down
12 changes: 8 additions & 4 deletions dashcamcleaner/main.py → src/dashcamcleaner/main.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
import inspect
import os
import sys
Expand All @@ -9,8 +8,9 @@
QApplication, QComboBox, QDoubleSpinBox, QFileDialog, QLineEdit,
QMainWindow, QMessageBox, QRadioButton, QSpinBox
)
from src.qt_wrapper import qtVideoBlurWrapper
from src.ui_mainwindow import Ui_MainWindow
print(sys.path)
from dashcamcleaner.qt_wrapper import qtVideoBlurWrapper
from dashcamcleaner.ui_mainwindow import Ui_MainWindow


class MainWindow(QMainWindow):
Expand All @@ -20,6 +20,7 @@ def __init__(self):
"""
self.receive_attempts = 0
save_path = os.path.join(os.path.dirname(__file__), "gui.ini")
print(save_path)
self.settings = QSettings(save_path, QSettings.IniFormat)
super(MainWindow, self).__init__()
self.ui = Ui_MainWindow()
Expand Down Expand Up @@ -250,7 +251,10 @@ def closeEvent(self, event):
QMainWindow.closeEvent(self, event)


if __name__ == "__main__":
def run_app():
"""
Run the GUI
"""
app = QApplication(sys.argv)

window = MainWindow()
Expand Down
10 changes: 4 additions & 6 deletions dashcamcleaner/cli.py → src/dashcamcleaner/main_cli.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/usr/bin/env python3

import argparse
import signal
import sys
import textwrap
from pathlib import Path
from typing import Dict, List, Union

from src.blurrer import VideoBlurrer
from .blurrer import VideoBlurrer

# makes it possible to interrupt while running in other thread
signal.signal(signal.SIGINT, signal.SIG_DFL)
Expand Down Expand Up @@ -41,8 +39,8 @@ def start_blurring(self):
input_path, output_path = Path(self.opt.input_path), Path(self.opt.output_path)
if input_path.is_dir(): # batch mode
for input_file in input_path.glob('*.*'):
opt.input_path = input_file.absolute()
opt.output_path = (output_path / input_file.name).absolute()
self.opt.input_path = input_file.absolute()
self.opt.output_path = (output_path / input_file.name).absolute()
self.start_blurring_file()
else:
self.start_blurring_file()
Expand Down Expand Up @@ -244,7 +242,7 @@ def _split_lines(self: 'CustomHelpFormatter', text: str, width: int) -> List[str
return parser.parse_args()


if __name__ == "__main__":
def run_cli():
opt = parse_arguments()
cli = CLI(opt)
cli.start_blurring()
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import imageio
from PySide6.QtCore import QThread, Signal
from more_itertools import chunked
from src.blurrer import VideoBlurrer
from .blurrer import VideoBlurrer


class qtVideoBlurWrapper(QThread, VideoBlurrer):
Expand Down
Loading