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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.png eol=auto
*.gif eol=auto
*.ico eol=auto
*.whl eol=auto
# Set linguist-language to support comments syntax highlight
pyrightconfig*.json linguist-language=jsonc
.vscode/*.json linguist-language=jsonc
26 changes: 11 additions & 15 deletions .github/workflows/lint-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ on:
env:
GITHUB_HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}
GITHUB_EXCLUDE_BUILD_NUMBER: ${{ inputs.excludeBuildNumber }}
UV_NO_SYNC: true # Avoid accidentally pulling in dependency-groups with uv run

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -47,14 +48,13 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up uv for Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v5
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: ${{ matrix.python-version }}
activate-environment: true
- run: scripts/install.ps1
shell: pwsh
- run: echo "$PWD/.venv/bin" >> $GITHUB_PATH
- name: Analysing the code with Pyright
uses: jakebailey/pyright-action@v2
with:
Expand All @@ -66,12 +66,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- run: uvx --with uvloop uv-secure
- uses: astral-sh/setup-uv@v6
- run: uvx uv-secure[faster-async]

Build:
runs-on: ${{ matrix.os }}
Expand All @@ -84,17 +80,17 @@ jobs:
steps:
- uses: actions/checkout@v4
# region https://github.com/pyinstaller/pyinstaller/issues/9012
- name: Set up uv for Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
python-version: ${{ !startsWith(matrix.os, 'ubuntu') && matrix.python-version || null }}
- name: Set up Python for PyInstaller tk issue
if: ${{ startsWith(matrix.os, 'ubuntu') }}
uses: actions/setup-python@v5
with:
allow-prereleases: true
python-version: ${{ matrix.python-version }}
- name: Set up uv for Python ${{ matrix.python-version }}
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
python-version: ${{ !startsWith(matrix.os, 'ubuntu') && matrix.python-version || null }}
# endregion
- run: scripts/install.ps1
shell: pwsh
Expand Down
2 changes: 0 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
// GitHub
"bierner.github-markdown-preview",
"github.vscode-github-actions",
// Dotenv
"dotenv.dotenv-vscode",
// Python/TOML
"charliermarsh.ruff",
"ms-python.mypy-type-checker",
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#### Comparison Method

- There are three comparison methods to choose from: L2 Norm, Histograms, and Perceptual Hash (or pHash).
- There are three comparison methods to choose from: L2 Norm, Histograms, and Perceptual Hash (aka pHash).
- L2 Norm: This method should be fine to use for most cases. It finds the difference between each pixel, squares it, sums it over the entire image and takes the square root. This is very fast but is a problem if your image is high frequency. Any translational movement or rotation can cause similarity to be very different.
- Histograms: An explanation on Histograms comparison can be found [here](https://mpatacchiola.github.io/blog/2016/11/12/the-simplest-classifier-histogram-intersection.html). This is a great method to use if you are using several masked images.
> This algorithm is particular reliable when the colour is a strong predictor of the object identity. The histogram intersection [...] is robust to occluding objects in the foreground.
Expand Down
13 changes: 4 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies = [
"Levenshtein >=0.25",
"PyAutoGUI >=0.9.52",
"PyWinCtl >=0.0.42", # py.typed
"keyboard", # [see tool.uv.sources]
"keyboard @ git+https://github.com/boppreh/keyboard.git", # Fix install on macos and linux-ci https://github.com/boppreh/keyboard/pull/568
"numpy >=2.1", # Python 3.13 support
"opencv-python-headless >=4.10", # NumPy 2 support
"packaging >=20.0", # py.typed
Expand All @@ -19,10 +19,10 @@ dependencies = [

#
# Build and compile resources
"pyinstaller >=6.12.0", # Build fix for built-in _tkinter (splash screen)
"pyinstaller >=6.14.0", # Mitigate issues with pkg_resources deprecation warning

#
# https://peps.python.org/pep-0508/#environment-markers
# https://packaging.python.org/en/latest/specifications/dependency-specifiers/#environment-markers
#
# Windows-only dependencies:
"pygrabber >=0.2; sys_platform == 'win32'", # Completed types
Expand All @@ -39,7 +39,6 @@ dependencies = [
#
# Linux-only dependencies
"PyScreeze >=1.0.0; sys_platform == 'linux'",
"dprint-py>=0.50.0.0",
"pillow >=11.0; sys_platform == 'linux'", # Python 3.13 support # Necessary for PyScreeze/ImageGrab.
"python-xlib >=0.33; sys_platform == 'linux'",
]
Expand All @@ -50,12 +49,10 @@ dev = [
"qt6-applications >=6.5.0",
#
# Linters & Formatters
"dprint-py>=0.50.0.0",
"mypy[faster-cache] >=1.16",
"pyright[nodejs] >=1.1.400", # reportPrivateImportUsage behaviour change
"ruff >=0.11.13",
"uv-secure",
"uvloop; sys_platform != 'win32'",
"winloop; sys_platform == 'win32'",
#
# Types
"scipy-stubs >=1.14.1.1",
Expand All @@ -78,8 +75,6 @@ dependency-metadata = [
{ name = "PyAutoGUI", requires-dist = [] },
{ name = "types-PyAutoGUI", requires-dist = [] },
]
[tool.uv.sources]
keyboard = { git = "https://github.com/boppreh/keyboard.git" } # Fix install on macos and linux-ci https://github.com/boppreh/keyboard/pull/568

[tool.uv-secure.maintainability_criteria]
forbid_yanked = true
Expand Down
2 changes: 1 addition & 1 deletion src/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def compare_phash(source: MatLike, capture: MatLike, mask: MatLike | None = None
# Apply the mask to the source and capture before calculating the
# pHash for each of the images. As a result of this, this function
# is not going to be very helpful for large masks as the images
# when shrinked down to 8x8 will mostly be the same.
# when shrunk down to 8x8 will mostly be the same.
if is_valid_image(mask):
source = cv2.bitwise_and(source, source, mask=mask)
capture = cv2.bitwise_and(capture, capture, mask=mask)
Expand Down
Loading