Skip to content
Merged
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
47 changes: 24 additions & 23 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ jobs:
runs-on: ubuntu-latest
name: Do the tests pass?
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Install dependencies and run tests
run: |
pip install -r requirements.txt
pip install pytest pytest-cov
pytest tests/ --cov=src --cov-report=xml
uv venv
uv pip install -r requirements.txt
uv pip install pytest pytest-cov
uv run pytest tests/ --cov=src --cov-report=xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
Expand All @@ -36,28 +39,24 @@ jobs:
runs-on: ubuntu-latest
name: Do the code respects Python standards?
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install dependencies and run linters
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Run pre-commit (Ruff and hooks)
run: |
pip install -r requirements_lint.txt
pip install -r requirements.txt
black . --line-length=120 --check --verbose
flake8
pip install --upgrade wrapt
pylint src/ tests/ --rcfile=setup.cfg --fail-under=9 --generated-members=cv2.*
mypy -p src -p tests --ignore-missing-imports --disallow-incomplete-defs
uvx pre-commit run --all-files --show-diff-on-failure
continue-on-error: true

release:
needs: [ test, good-practices ]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Bump version and push tag
Expand All @@ -71,14 +70,16 @@ jobs:
MINOR_STRING_TOKEN: 'feat:'
PATCH_STRING_TOKEN: 'fix:'
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.11.5'
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
pip install setuptools wheel twine
python setup.py sdist bdist_wheel
twine upload dist/*
uv pip install build twine
uv run python -m build
uv run twine upload dist/*
41 changes: 13 additions & 28 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,22 @@
default_language_version:
python: python3.12

exclude: ^env/

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.6.0
hooks:
- id: check-added-large-files
args: ['--maxkb=1550']
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
args: [--line-length=120, --verbose]

- repo: https://github.com/pycqa/flake8
rev: 4.0.0
hooks:
- id: flake8

- repo: https://github.com/pylint-dev/pylint
rev: v3.1.0
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
args: ['src/', 'tests/', '--rcfile=setup.cfg', '--fail-under=8', '--generated-members=cv2.*']
types: [python]
exclude: '^setup\.py$'

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.0
hooks:
- id: mypy
args: [--ignore-missing-imports, --disallow-incomplete-defs]
files: ^src/|^tests/
- id: ruff-check
args:
- --fix
- id: ruff-format
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Circular Barcode | Horizontal Barcode

![PyPI - Version](https://img.shields.io/pypi/v/movie-barcodes)
![PyPI - License](https://img.shields.io/pypi/l/movie-barcodes)
![Python](https://img.shields.io/badge/python-3.11-blue)
![Python](https://img.shields.io/badge/python-3.12-blue)
![Status](https://img.shields.io/pypi/status/movie-barcodes.svg)
![Codecov](https://codecov.io/gh/Wazzabeee/movie-barcodes/branch/main/graph/badge.svg)
![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)
Expand Down Expand Up @@ -79,20 +79,22 @@ $ git clone https://github.com/Wazzabeee/movie-barcodes
# Go into the repository
$ cd movie-barcodes

# Install requirements
$ pip install -r requirements.txt
$ pip install -r requirements_lint.txt
# (Recommended) Use uv for environment and tools
$ curl -LsSf https://astral.sh/uv/install.sh | sh # or see uv docs for your OS

# Install precommit
$ pip install pre-commit
$ pre-commit install
# Create a virtual environment and install dependencies
$ uv venv
$ uv pip install -r requirements.txt

# Install pre-commit hooks
$ uvx pre-commit install

# Run tests
$ pip install pytest
$ pytest tests/
$ uv pip install pytest pytest-cov
$ uv run pytest tests/

# Run package locally
$ python -m src.main -i "path_to_video.mp4"
$ uv run python -m src.main -i "path_to_video.mp4"
```

# Todo
Expand Down Expand Up @@ -146,5 +148,3 @@ movie-barcodes -i "royal_tenenbaums.mp4" --width 1920 --height 1080 -t "horizont
Circular Barcode | Horizontal Barcode
:-------------------------:|:-------------------------:
![](https://raw.githubusercontent.com/Wazzabeee/movie_color_barcode/main/examples/royal_tenenbaum_smoothed_circular.png) | ![](https://raw.githubusercontent.com/Wazzabeee/movie_color_barcode/main/examples/royaltenenbaums_smoothed_horizontal.png)


64 changes: 64 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[build-system]
requires = ["setuptools>=68", "wheel", "setuptools-scm>=8"]
build-backend = "setuptools.build_meta"

[project]
name = "movie-barcodes"
description = "Compress every frame of a movie in a single color barcode. Transform entire movies into stunning single-barcode visualizations. Capture the essence of cinematic storytelling through dominant color extraction from each frame."
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.12"
license = { file = "LICENSE" }
authors = [
{ name = "Clément Delteil", email = "clement45.delteil45@gmail.com" }
]
keywords = [
"visualization", "python", "opencv", "color extraction", "data science",
"machine learning", "movies", "computer vision", "multiprocessing",
"parallel computing", "barcode", "image processing", "multithreading",
"data visualization", "video processing", "color barcode"
]
classifiers = [
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"colorama==0.4.6",
"joblib==1.3.2",
"numpy==1.26.0",
"opencv-python==4.8.1.78",
"Pillow==10.3.0",
"scikit-learn==1.5.0",
"scipy==1.11.2",
"threadpoolctl==3.2.0",
"tqdm==4.66.3",
]

dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/Wazzabeee/movie-barcodes"
Repository = "https://github.com/Wazzabeee/movie-barcodes"

[project.scripts]
movie-barcodes = "src.main:main"

[tool.setuptools_scm]
version_scheme = "guess-next-dev"
local_scheme = "node-and-date"

[tool.ruff]
line-length = 120
# Match repo's default Python for linting/formatting
target-version = "py312"
exclude = [
"env/",
]

[tool.ruff.lint]
# Keep compatibility with Black-style slicing
extend-ignore = ["E203"]
Binary file modified requirements.txt
Binary file not shown.
8 changes: 0 additions & 8 deletions requirements_lint.txt

This file was deleted.

22 changes: 0 additions & 22 deletions setup.cfg

This file was deleted.

78 changes: 0 additions & 78 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_video_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def grab_side_effect():
mock_video_instance.read.side_effect = read_side_effect
mock_video_instance.grab.side_effect = grab_side_effect

expected_colors = [f"frame_data_{i*10}" for i in range(self.target_frames)]
expected_colors = [f"frame_data_{i * 10}" for i in range(self.target_frames)]

actual_colors = video_processing.extract_colors(
self.video_path,
Expand Down