Skip to content
This repository was archived by the owner on Apr 26, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1e261f2
temporarily disable auto reset
Avasam Jul 3, 2022
20650c3
Merge branch '2.0.0' of https://github.com/Avasam/Auto-Split into tem…
Avasam Jul 3, 2022
10c74d9
.
Avasam Jul 3, 2022
c006826
Updated Scripts to OS agnostic powershell
Avasam Jul 12, 2022
e555479
Abstracted all capture methods to its own module
Avasam Jul 13, 2022
3d72389
Optimized VideoCaptureDevice by threading it
Avasam Jul 13, 2022
b0a1c39
CI: Install wheel
Avasam Jul 13, 2022
96d707a
Some UI fixes
Avasam Jul 14, 2022
38930a4
Show a warning if AutoSplit is already open
Avasam Jul 14, 2022
9fe46c4
Fixed linting
Avasam Jul 14, 2022
d6f394f
Add version number
Avasam Jul 14, 2022
159c95d
Merge branch 'abstract-capture-method' of https://github.com/Avasam/A…
Avasam Jul 15, 2022
92a9541
Generate hotkey attributes in AutoSplit
Avasam Jul 15, 2022
cc76c91
Added hotkey for disable auto reset image
Avasam Jul 15, 2022
57a9c80
Updated doc for per-image comparison method
Avasam Jul 15, 2022
723bdda
Added workflow_dispatch for manual triggers
Avasam Jul 16, 2022
c2b1324
update comparison_method_from_filename symbol
Avasam Jul 22, 2022
3894896
Extract hwnd validation
Avasam Jul 16, 2022
6a1349a
Fixed window recovery from loading profile and WGC
Avasam Jul 22, 2022
7410a9f
Updated build scripts
Avasam Jul 23, 2022
0aed849
Fixed crashes when opening from LiveSplit
Avasam Jul 23, 2022
09b5c81
Completed cv2 error type stubs
Avasam Jul 23, 2022
8581fcb
Fixed error from trying to capture occupied capture device
Avasam Jul 24, 2022
4ce5a73
Updated some settigns and linters
Avasam Jul 24, 2022
0d26e58
Completed fire_and_forget implementation
Avasam Jul 24, 2022
7eed444
Fixed a few focus and tabstop issues
Avasam Jul 25, 2022
3683954
Fix numpy typing
Avasam Jul 25, 2022
fe05988
Merge branch 'abstract-capture-method' of https://github.com/Avasam/A…
Avasam Jul 25, 2022
1881019
Prefer asyncio over threads
Avasam Jul 25, 2022
9967c69
Wrap async functions for errors
Avasam Jul 26, 2022
ea48b52
Proper toggle autoreset iamge location and setting
Avasam Jul 26, 2022
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
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ ignore-names=closeEvent,paintEvent,keyPressEvent,mousePressEvent,mouseMoveEvent,
; McCabe max-complexity is also taken care of by Pylint and doesn't fail the build there
; So this is the hard limit
max-complexity=32
inline-quotes="
inline-quotes=double
59 changes: 31 additions & 28 deletions .github/workflows/lint-and-build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
name: Lint and build
on:
workflow_dispatch: # Allows manual builds
push:
branches:
- main
Expand Down Expand Up @@ -37,13 +38,9 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'scripts/requirements-dev.txt'
- name: Install dependencies
run: |
pip install -r "scripts/requirements-dev.txt"
npm install -g pyright
npm list -g pyright
- run: scripts/compile_resources.bat
cache-dependency-path: 'scripts/requirements*.txt'
- run: scripts/install.ps1
shell: pwsh
- name: Analysing the code with Pyright
run: pyright --warnings
Pylint:
Expand All @@ -60,10 +57,9 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'scripts/requirements-dev.txt'
- name: Install dependencies
run: pip install -r "scripts/requirements-dev.txt"
- run: scripts/compile_resources.bat
cache-dependency-path: 'scripts/requirements*.txt'
- run: scripts/install.ps1
shell: pwsh
- name: Analysing the code with Pylint
run: pylint --reports=y --output-format=colorized src/
Flake8:
Expand All @@ -80,38 +76,34 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'scripts/requirements-dev.txt'
- name: Install dependencies
run: pip install -r "scripts/requirements-dev.txt"
- run: scripts/compile_resources.bat
cache-dependency-path: 'scripts/requirements*.txt'
- run: scripts/install.ps1
shell: pwsh
- name: Analysing the code with Flake8
run: flake8
Bandit:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: "3.10"
cache: 'pip'
cache-dependency-path: 'scripts/requirements-dev.txt'
- name: Install dependencies
run: pip install -r "scripts/requirements-dev.txt"
- run: scripts/compile_resources.bat
cache-dependency-path: 'scripts/requirements*.txt'
- run: scripts/install.ps1
shell: pwsh
- name: Analysing the code with Bandit
run: bandit -n 1 --severity-level medium --recursive src
Build:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10"]
python-version: ["3.10"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v3
Expand All @@ -120,11 +112,22 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: pip install -r "scripts/requirements.txt"
- run: scripts/build.bat
- run: scripts/install.ps1
shell: pwsh
- run: scripts/build.ps1
shell: pwsh
- name: Upload Build Artifact
uses: actions/upload-artifact@v3
with:
name: AutoSplit (Python ${{ matrix.python-version }})
path: dist/AutoSplit.exe
path: dist/AutoSplit*
if-no-files-found: error
- name: Upload Build logs
uses: actions/upload-artifact@v3
with:
name: Build logs (Python ${{ matrix.python-version }})
path: |
build/AutoSplit/*.toc
build/AutoSplit/*.txt
build/AutoSplit/*.html
if-no-files-found: error
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Caches
.cache/

# Byte-compiled / optimized / DLL files
__pycache__/

Expand Down
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,22 @@
"name": "Python: AutoSplit",
"type": "python",
"request": "launch",
"preLaunchTask": "Compile resources",
"program": "src/AutoSplit.py",
"console": "integratedTerminal",
"justMyCode": true
},
{
"name": "Python: AutoSplit --auto-controlled",
"type": "python",
"request": "launch",
"preLaunchTask": "Compile resources",
"program": "src/AutoSplit.py",
"args": [
"--auto-controlled"
],
"console": "integratedTerminal",
"justMyCode": true
}
]
}
13 changes: 12 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@
// 88, // Black default
99, // PEP8-17 acceptable max
120, // Our hard rule
]
],
"editor.codeActionsOnSave": {
// This removes "unused" imports. https://github.com/microsoft/pylance-release/issues/3091
"source.fixAll": false,
},
},
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
Expand All @@ -77,4 +81,11 @@
// Just another wrapper, use Flake8 OR this
"python.linting.pylamaEnabled": false,
"python.linting.banditEnabled": true,
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline",
"powershell.codeFormatting.autoCorrectAliases": true,
"powershell.codeFormatting.trimWhitespaceAroundPipe": true,
"powershell.codeFormatting.useConstantStrings": true,
"powershell.codeFormatting.useCorrectCasing": true,
"powershell.codeFormatting.whitespaceBetweenParameters": true,
"powershell.integratedConsole.showOnStartup": false,
}
9 changes: 7 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Compile resources",
"type": "shell",
"command": "scripts/compile_resources.ps1"
},
{
"label": "Build AutoSplit",
"type": "shell",
"command": "scripts/build.bat",
"command": "scripts/build.ps1",
"group": {
"kind": "build",
"isDefault": true
}
}
],
]
}
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=Avasam_Auto-Split&metric=security_rating)](https://sonarcloud.io/dashboard?id=Avasam_Auto-Split)
[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=Avasam_Auto-Split&metric=code_smells)](https://sonarcloud.io/summary/new_code?id=Avasam_Auto-Split)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Avasam_Auto-Split&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Avasam_Auto-Split)
[![SemVer](https://badgen.net/badge/SemVer/SemVer/grey?label)](https://semver.org/)
[![SemVer](https://badgen.net/badge/_/SemVer%20compliant/grey?label)](https://semver.org/)

Easy to use image comparison based auto splitter for speedrunning on console or PC.

Expand All @@ -32,10 +32,10 @@ This program can be used to automatically start, split, and reset your preferred
- Microsoft Visual C++ 14.0 or greater may be required to build the executable. Get it with [Microsoft C++ Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools/).
- Node is optional, but required for complete linting (using Pyright).
- Read [requirements.txt](/scripts/requirements.txt) for more information on how to install, run and build the python code.
- Run `.\scripts\install.bat` to install all dependencies.
- Run the app directly with `.\scripts\start.bat [--auto-controlled]`.
- Run `.\scripts\build.bat` to build an executable.
- Recompile resources after modifications by running `.\scripts\compile_resources.bat`.
- Run `./scripts/install.ps1` to install all dependencies.
- Run the app directly with `./scripts/start.ps1 [--auto-controlled]`.
- Run `./scripts/build.ps1` to build an executable.
- Recompile resources after modifications by running `./scripts/compile_resources.ps1`.
- All configured for VSCode, including Run (F5) and Build (Ctrl+Shift+B) commands.

## OPTIONS
Expand Down Expand Up @@ -69,7 +69,7 @@ This program can be used to automatically start, split, and reset your preferred
#### Comparison Method

- There are three comparison methods to choose from: L2 Norm, Histograms, and Perceptual Hash (or 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.
- 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.
- Perceptual Hash: An explanation on pHash comparison can be found [here](http://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html). It is highly recommended to NOT use pHash if you use masked images. It is very inaccurate.

Expand All @@ -92,7 +92,7 @@ This program can be used to automatically start, split, and reset your preferred
- **Force Full Content Rendering** (very slow, can affect rendering pipeline)
Uses BitBlt behind the scene, but passes a special flag to PrintWindow to force rendering the entire desktop.
About 10-15x slower than BitBlt based on original window size and can mess up some applications' rendering pipelines.
- **Video Capture Device** (very slow, see below)
- **Video Capture Device**
Uses a Video Capture Device, like a webcam, virtual cam, or capture card.
There are currently performance issues, but it might be more convenient.
If you want to use this with OBS' Virtual Camera, use the [Virtualcam plugin](https://obsproject.com/forum/resources/obs-virtualcam.949/) instead.
Expand Down Expand Up @@ -157,11 +157,15 @@ If this option is disabled, when the reset hotkey is hit, the reset button is pr
- Custom thresholds are place between parenthesis `()` in the filename. This value will override the default threshold.
- Custom pause times are placed between square brackets `[]` in the filename. This value will override the default pause time.
- Custom delay times are placed between hash signs `##` in the filename. Note that these are in milliseconds. For example, a 10 second split delay would be `#10000#`. You cannot skip or undo splits during split delays.
- A different comparison method can be specified with their 0-base index between carets `^^`:
- `^0^`: L2 Norm
- `^1^`: Histogram
- `^2^`: Perceptual Hash
- Image loop amounts are placed between at symbols `@@` in the filename. For example, a specific image that you want to split 5 times in a row would be `@5@`. The current loop # is conveniently located beneath the current split image.
- Flags are placed between curly brackets `{}` in the filename. Multiple flags are placed in the same set of curly brackets. Current available flags:
- {d} dummy split image. When matched, it moves to the next image without hitting your split hotkey.
- {b} split when similarity goes below the threshold rather than above. When a split image filename has this flag, the split image similarity will go above the threshold, do nothing, and then split the next time the similarity goes below the threshold.
- {p} pause flag. When a split image filename has this flag, it will hit your pause hotkey rather than your split hokey.
- `{d}` dummy split image. When matched, it moves to the next image without hitting your split hotkey.
- `{b}` split when similarity goes below the threshold rather than above. When a split image filename has this flag, the split image similarity will go above the threshold, do nothing, and then split the next time the similarity goes below the threshold.
- `{p}` pause flag. When a split image filename has this flag, it will hit your pause hotkey rather than your split hokey.
- Filename examples:
- `001_SplitName_(0.9)_[10].png` is a split image with a threshold of 0.9 and a pause time of 10 seconds.
- `002_SplitName_(0.9)_[10]_{d}.png` is the second split image with a threshold of 0.9, pause time of 10, and is a dummy split.
Expand Down
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,21 @@ disable = [
"unused-import",
# Similar lines in 2 files, doesn't really work
"R0801",
# Doesn't work with local imports
"import-error",
# False positives with PyQt .connect
"no-value-for-parameter",
# Not as long as we support Python 3.9
"consider-alternative-union-syntax",
]

[tool.pylint.TYPECHECK]
generated-members = "cv2"
generated-members = [
# https://github.com/PyCQA/pylint/issues/4987
"cv2",
# https://github.com/mhammond/pywin32/issues/1913
"pywintypes.error",
]

[tool.isort]
line_length = 120
Expand Down
14 changes: 10 additions & 4 deletions res/about.ui
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<rect>
<x>10</x>
<y>44</y>
<width>161</width>
<width>171</width>
<height>32</height>
</rect>
</property>
Expand Down Expand Up @@ -112,10 +112,10 @@ consider donating. Thank you!</string>
<widget class="QLabel" name="icon_label">
<property name="geometry">
<rect>
<x>190</x>
<x>181</x>
<y>17</y>
<width>62</width>
<height>71</height>
<width>64</width>
<height>64</height>
</rect>
</property>
<property name="text">
Expand All @@ -124,7 +124,13 @@ consider donating. Thank you!</string>
<property name="pixmap">
<pixmap resource="resources.qrc">:/resources/icon.ico</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<zorder>icon_label</zorder>
<zorder>version_label</zorder>
<zorder>created_by_label</zorder>
</widget>
<resources>
<include location="resources.qrc"/>
Expand Down
10 changes: 2 additions & 8 deletions res/design.ui
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@
<iconset resource="resources.qrc">
<normaloff>:/resources/icon.ico</normaloff>:/resources/icon.ico</iconset>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<widget class="QWidget" name="central_widget">
<widget class="QLabel" name="x_label">
<property name="geometry">
Expand Down Expand Up @@ -816,7 +810,7 @@
<rect>
<x>449</x>
<y>344</y>
<width>98</width>
<width>101</width>
<height>16</height>
</rect>
</property>
Expand All @@ -827,7 +821,7 @@
<widget class="QLabel" name="start_image_status_value_label">
<property name="geometry">
<rect>
<x>550</x>
<x>560</x>
<y>344</y>
<width>98</width>
<height>16</height>
Expand Down
Loading