Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(capture): start working on dxcam implementation #227

Draft
wants to merge 22 commits into
base: dev
Choose a base branch
from

Conversation

Lordmau5
Copy link

IMPORTANT: This will not work when D3DShot is also imported for whatever reason, see ra1nty/DXcam#61

Also, it's not properly working with multiple monitors yet. It can crash because of the wrong monitor being selected

Avasam and others added 22 commits November 27, 2021 17:09
…hread

Fixes Toufool#86 Stop uncaught exceptions from silently crashing the app
…on't allow a start image to load if hotkeys are not set.
…-Open'-immediatly

Async check for updates + Save 'check for updates on open' immediately
* First linting pass
Configured VSCode and Markdownlint settings
Added and configured the following linters as strict as I could: pylint, flake8, mypy, bandit, pyright
Partially filled in some type stubs: cv2, imagehash, keyboard, pyautogui, pythonwin, win32helper
[Breaking change] Using interpolation=cv2.INTER_NEAREST everywhere as it is the fastest interlpolation method
Hide generated/compiled files
SelectRegionWidget width and height as functions
Added validate_images_before_parsing() to validate images both before maxFPS and starting autosplitter

* Moved most settings to pyproject.toml and ran autopep8

* Removed mypy and Fixed import-outside-toplevel

* Double quotes and pylint complete linting

* Configured linting workflow

* add pause after start image tip

* Fix crash on LiveSplit open and missing link in error message

* Merge

* Fixed certificate error and random crash on open when compiled

* Using python/typeshed/pull/6492

* PEP8 naming convention

* Added build artifact

* AutoSplitImage Class and simplified code
Simplified and reduced image conversions
Reduced duplicated code, especially in settings
Build Artifact

* Average FPS over all images with all actions

* Added badges

* Fixed "Select Window" not working for windows with negative coordinates
Split screen_region in smaller functions
WIP towards Toufool#94:
No pop-up on loading settings with no capture window
 Don't stop/reset AutoSplit upon loosing capture window
 No pop-up on loosing capture window
 Don't allow selecting desktop.

* Ability to recover window

Fixed regressions:
Fix crash on clising window mid-run
Forgot to migrate split_delay to image.delay
Removed dead load_pyqt_settings code
Fixed dummy groups
Pause time from filename not set correctly
Setting hotkeys on load

* Differentiate "undo/skip split" from "previous/next image"
Skip/udo will now actually call command
This makes grouping option obsolete as user now has finer control anyway
UI is a bit cramped, but that should be resolved with UI revamp
Updated README

* Make Save Settings more intuitive
Don't close if user has cancelled "saving sattings as"
Removed more attributes from AutoSplit class
Don't update last_successfully_loaded_settings_file_path if load was not successful
"Save Settings As" defaults to the last_successfully_loaded_settings_file_path THEN the .exe
When closing app, ue save_settings instead of save_settings_as

* Initial UI update for 2.0.0. Add settings window.

* Hooked new settings window to actual values (Toufool#151)

* Initial UI update for 2.0.0. Add settings window.

* hooked new settings window to actual values

* Better "seconds remaining" text

* Undo split goes to the end of the group

Co-authored-by: Austin <[email protected]>

* Image comparison method and default delay time (Toufool#135)

* hooked new settings window to actual values

* Implemented image specific comparison method and default delay time.
Closes Toufool#26

* Initial UI update for 2.0.0. Add settings window.

* hooked new settings window to actual values

* Better "seconds remaining" text

* Undo split goes to the end of the group

* Fixed images comparison method defaulting to 0 rather than none

Co-authored-by: Austin <[email protected]>

* Support hotkeys with modifiers (Toufool#136)

* hooked new settings window to actual values

* Better "seconds remaining" text

* Support modifiers the same way LiveSplit does. Closes Toufool#34

* Initial UI update for 2.0.0. Add settings window.

* hooked new settings window to actual values

* Better "seconds remaining" text

* Undo split goes to the end of the group

Co-authored-by: Austin <[email protected]>

* Linted pyi files (Toufool#137)

* hooked new settings window to actual values

* Linted pyi files

* Initial UI update for 2.0.0. Add settings window.

* hooked new settings window to actual values

* Better "seconds remaining" text

* Undo split goes to the end of the group

* Turn off pyright(reportFunctionMemberAccess) in favor of pylint(no-member)

* Massively sped up Flake tests
Removed 400+kb of type stubs

* Centralized qWait typing fix

* Autosort imports

* Resynced settings

Co-authored-by: Austin <[email protected]>

* Toml profiles + Python 3.10 (Toufool#140)

* Typings update

* Full setup and configuration update

* User Profile, Revamped settings, Start image fixes & __auto_splitter method refactor

* Added new Capture Method system for more capture options + utils (Toufool#141)

* Add D3DShot types
from python/typeshed#8652

* New Capture Method system

* Warning if AutoSplit is already open + Build number + Splash Screen + Doc update + Fixes (Toufool#161)

* Doc + Setup update

* typings update

* Warning if AutoSplit is already open + Build number + Splash Screen

* Target the right repository/fork

* Fix Toufool#155

* Actions shortcut and prevent double open window
Closes Toufool#154

* ImageHash hotfix

* Toggle autoreset image + ui adjustments (Toufool#164)

* merge master into 2.0.0 (Toufool#165)

* update credits

* oops

* Toggle autoreset image (Toufool#162)

* Fix Toufool#52 Comparisons with empty masks

* Save 'Check For Updates On Open' immediatly

* showErrorSignal to show error message box from another thread

* Fixes Toufool#86 Stop uncaught exceptions from silently crashing the app

* Fixes Toufool#86 Stop uncaught exceptions from silently crashing the app

* Fix Toufool#114, try to load Start Image on browse & load settings, don't allow a start image to load if hotkeys are not set.

* First linting pass
Configured VSCode and Markdownlint settings
Added and configured the following linters as strict as I could: pylint, flake8, mypy, bandit, pyright
Partially filled in some type stubs: cv2, imagehash, keyboard, pyautogui, pythonwin, win32helper
[Breaking change] Using interpolation=cv2.INTER_NEAREST everywhere as it is the fastest interlpolation method
Hide generated/compiled files
SelectRegionWidget width and height as functions
Added validate_images_before_parsing() to validate images both before maxFPS and starting autosplitter

* Moved most settings to pyproject.toml and ran autopep8

* Removed mypy and Fixed import-outside-toplevel

* Double quotes and pylint complete linting

* Configured linting workflow

* Async check for updates

* Fix crash on LiveSplit open and missing link in error message

* Merge

* Fixed certificate error and random crash on open when compiled

* Using python/typeshed/pull/6492

* PEP8 naming convention

* Added build artifact

* AutoSplitImage Class and simplified code
Simplified and reduced image conversions
Reduced duplicated code, especially in settings
Build Artifact

* Average FPS over all images with all actions

* Added badges

* Fixed "Select Window" not working for windows with negative coordinates
Split screen_region in smaller functions
WIP towards Toufool#94:
No pop-up on loading settings with no capture window
 Don't stop/reset AutoSplit upon loosing capture window
 No pop-up on loosing capture window
 Don't allow selecting desktop.

* Ability to recover window

Fixed regressions:
Fix crash on clising window mid-run
Forgot to migrate split_delay to image.delay
Removed dead load_pyqt_settings code
Fixed dummy groups
Pause time from filename not set correctly
Setting hotkeys on load

* Differentiate "undo/skip split" from "previous/next image"
Skip/udo will now actually call command
This makes grouping option obsolete as user now has finer control anyway
UI is a bit cramped, but that should be resolved with UI revamp
Updated README

* Make Save Settings more intuitive
Don't close if user has cancelled "saving sattings as"
Removed more attributes from AutoSplit class
Don't update last_successfully_loaded_settings_file_path if load was not successful
"Save Settings As" defaults to the last_successfully_loaded_settings_file_path THEN the .exe
When closing app, ue save_settings instead of save_settings_as

* Initial UI update for 2.0.0. Add settings window.

* Hooked new settings window to actual values (Toufool#151)

* Initial UI update for 2.0.0. Add settings window.

* hooked new settings window to actual values

* Better "seconds remaining" text

* Undo split goes to the end of the group

Co-authored-by: Austin <[email protected]>

* Image comparison method and default delay time (Toufool#135)

* hooked new settings window to actual values

* Implemented image specific comparison method and default delay time.
Closes Toufool#26

* Initial UI update for 2.0.0. Add settings window.

* hooked new settings window to actual values

* Better "seconds remaining" text

* Undo split goes to the end of the group

* Fixed images comparison method defaulting to 0 rather than none

Co-authored-by: Austin <[email protected]>

* Support hotkeys with modifiers (Toufool#136)

* hooked new settings window to actual values

* Better "seconds remaining" text

* Support modifiers the same way LiveSplit does. Closes Toufool#34

* Initial UI update for 2.0.0. Add settings window.

* hooked new settings window to actual values

* Better "seconds remaining" text

* Undo split goes to the end of the group

Co-authored-by: Austin <[email protected]>

* Linted pyi files (Toufool#137)

* hooked new settings window to actual values

* Linted pyi files

* Initial UI update for 2.0.0. Add settings window.

* hooked new settings window to actual values

* Better "seconds remaining" text

* Undo split goes to the end of the group

* Turn off pyright(reportFunctionMemberAccess) in favor of pylint(no-member)

* Massively sped up Flake tests
Removed 400+kb of type stubs

* Centralized qWait typing fix

* Autosort imports

* Resynced settings

Co-authored-by: Austin <[email protected]>

* Toml profiles + Python 3.10 (Toufool#140)

* Typings update

* Full setup and configuration update

* User Profile, Revamped settings, Start image fixes & __auto_splitter method refactor

* Added new Capture Method system for more capture options + utils (Toufool#141)

* Add D3DShot types
from python/typeshed#8652

* New Capture Method system

* Warning if AutoSplit is already open + Build number + Splash Screen + Doc update + Fixes (Toufool#161)

* Doc + Setup update

* typings update

* Warning if AutoSplit is already open + Build number + Splash Screen

* Target the right repository/fork

* Fix Toufool#155

* Actions shortcut and prevent double open window
Closes Toufool#154

* ImageHash hotfix

* Toggle autoreset image + ui adjustments

Co-authored-by: Austin <[email protected]>

* Revert "Toggle autoreset image (Toufool#162)" (Toufool#163)

This reverts commit 9e48c51.

Co-authored-by: Samuel T <[email protected]>

* test building without --windowed

* First round of QA testing fixes (Toufool#171)

* Added sonarcloud.properties

* Remove duplicate DeleteDC & allow errors to show
May fix Toufool#167

* Rename CaptureMethodInterface to CaptureMethodBase

* Added autofix script and faster linting

* Disable device probing for now. Fixes Toufool#169

* Updated settings widget text
and workaround to fix Toufool#170

* Bump AUTOSPLIT_VERSION

* Next Image even if it's not possible to split
Fixes Toufool#168

* Fix build

* First round of QA testing fixes + build fixes (Toufool#172)

* back to windowed

* Fix Toufool#47, updated some configs and types from typeshed (Toufool#173)

* Updated configs

* Updated typings

* Updated some code

* Fix Toufool#47

* Revert mypy stuff

* More consistent formatting (Toufool#174)

* More consistent formatting and types
- Added autofixes to the lint script.
- Added a quotes autofixer using `unify`
- Added a trailing comma checker and autofixer
- Applied trailing commas
- Ordered requirements alphabetically
- Ensure the last version of D3DShot is used (0.1.5, not 0.1.3)
- Remove configuration for unused linters (black/prettier/sonarlint)
- Updated types from typeshed

* Updated virtual camera link

* Update types and pylint

* Batch fixes (Toufool#176)

* pyright update

* lint-and-build cover more files

* Get IDirect3dDevice from LearningModelDevice
Closes Toufool#175

Co-authored-by: Algomancer <[email protected]>

* Ensure we're using the right camera size
And not OpenCV's default 640x480

* Fix rounding error in displayed decimal

* Revert "back to windowed"

This reverts commit 9553271.

* Fix highest similarity for start image

* Fix split below treshold when image is not valid

* Detect gray frames from OBS-Camera

Co-authored-by: Algomancer <[email protected]>

* Adaptive resizing for masked images (Toufool#177)

Especially in the case of 1080p or higher, if the non-transparent area of the mask image used for the split is small, resizing the entire image to 320x240 will lose the information inside the mask. One idea to prevent this is to adaptively determine the target size according to the number of nonzero elements in the alpha channel of the split image. At least for the L2 norm and histogram, such a change would not affect performance since they only use information about the mask's interior. Masks are not recommended with pHash anyway.

Co-authored-by: zalgo3 <[email protected]>

* Bump opencv-python to 4.6 (Toufool#178)

* Point python_grabber to andreaschiavinato (Toufool#179)

* Batch of updates and fixes for 2.0.0 (Toufool#188)

* Point python_grabber to andreaschiavinato

* Added summary of histogram

* Backport changes from linux branch

* Improved pyright and formatters usage

* Config updates

* Fix links

* Disable next/previous while delaying

* proper `is_running` variable

* Fix loading and clearing of start image

* Rename "already_running" to "already_open"

* Fix delay intervals

* Add support for start image pause time

* Default to MediaCapture's d3d

* Re-enable buttons after delay

* Beta 1 (feature-freeze, bugfixes only)

* Updated configs to use Python 3.11 (Toufool#180)

* Option to build without build number + Adaptive mask fix (Toufool#189)

* Option to build without build number

* Fix repo url from workflow build

* Resize mask with image

* Pin more dependencies, Speed-up installs and update comments

* Add mypy config for optional support.

* pin requests and allow pyright warnings (Toufool#193)

* Fix B028 (Toufool#194)

* Fixed run_start_time with start image pause loop (Toufool#197)

Also fixed run_start_time not accounting for the delay in parsing images

* Disable Capture device: dropdown when Capture method: is not Video Capture Device (Toufool#198)

Fix issue with programatically setting capture_device_combobox index

* Fix start issue after finishing splits  (Toufool#199)

* Fix start issue after finishing splits
- `self.is_running = False` at the end of `__auto_splitter`
- Revert moving initialization of some values
- Move `self.run_start_time = time()` before parsing images

* Update hardcoded references to repo name

* Change default capture method to WGA (Toufool#200)

* Delete example1.6.0.gif

* 2.0.0 gif

* update gif to 2.0.0

* Update some docs and fix lint issue (Toufool#202)

* Update docs, comments and typings
Add link to dev builds
bump beta version
Update flake8 checks
"fix" typing issue caused by PyQt6 incorrect callable

* Slight build improvement

* Fix D3DDD issue on hybrid GPU laptops (Toufool#205)

* Fix D3DDD issue on hybrid gpu laptops

1. Some Desktop Duplication setup was done in advance, even if that method won't be used
2. Hybrid GPU laptops can have issues with D3D Desktop Duplication. The issue and a workaround is now documented

* Fixed some blocking typing and linting issues

* Fix obs-camera image freezing for a sec when it gives a blank frame (Toufool#206)

---------

Co-authored-by: Austin <[email protected]>
Co-authored-by: Algomancer <[email protected]>
Co-authored-by: zalgo3 <[email protected]>
https://beta.ruff.rs/docs/
https://github.com/charliermarsh/ruff

Massively simplify configurations and speedup linting thanks to Ruff. Adds more autofixes too.
Using `pathlib` instead of `os.path` is the modern way to go. However fixing this could introduce a bug if not careful. So I'm leaving it for later.

Existing related Ruff requests (nothing here is a blocker, just future improvements):
- astral-sh/ruff#1256
- astral-sh/ruff#3011
- astral-sh/ruff#3072
- astral-sh/ruff#3910
- astral-sh/ruff#2419
- astral-sh/ruff#3115
- astral-sh/ruff#1904
We already have to install PySide for its tooling anyway. With this we would use the official bindings with a public bug tracker. The size of the bundle is also reduced by ~10MB.

I was also able to remove a hack for the shortcutContext breaking the UI generation tool
Unblocks Toufool#209
- Comments updates
- Scripts updates
- Use PyWinCtl
- No longer build releases on 3.10
- Change default formatter in VSCode to autopep8
- `xml.format.preserveSpace` for `<string>`
- UI more spaced out (support Win11 high-DPI and Linux)
- Scope Capture Methods descriptions to classes by using ClassVars
Ignore line endings
Closes Toufool#209

It even changes live without having to reboot autosplit. I can also remove a UI hack for Windows 11.
The red and orange outlines are because I set my accent color to red and orange in Windows 10 and 11 respectively.

Windows 10 fusion light
![image](https://user-images.githubusercontent.com/1350584/233756850-30a24bab-a4a9-48be-8f21-5cba2fe719ec.png)

Windows 10 fusion dark
![image](https://user-images.githubusercontent.com/1350584/233756893-d665f778-6526-42a9-83a0-3f94884b74aa.png)

Windows 11 fusion light
![f5312fc2-a522-441a-b86a-8fb339fdbd86](https://user-images.githubusercontent.com/1350584/233757216-c96325f9-0f03-49a8-adae-707010142c70.jpg)

Windows 11 fusion dark
![34ad4a33-f077-42b8-986f-3d33c6b761af](https://user-images.githubusercontent.com/1350584/233757219-7562c879-8704-4cb8-be35-a6c2ae18a270.jpg)
IMPORTANT: This will not work when D3DShot is also imported for whatever reason, see ra1nty/DXcam#61

Also, it's not properly working with multiple monitors yet. It can crash because of the wrong monitor being selected
@Avasam Avasam force-pushed the dev branch 2 times, most recently from 97aa56c to 7613656 Compare May 25, 2023 22:16
@Avasam Avasam force-pushed the dev branch 2 times, most recently from ec4bff1 to 7109246 Compare June 6, 2023 00:59
@Avasam Avasam deleted the branch Toufool:dev June 6, 2023 01:16
@Avasam Avasam closed this Jun 6, 2023
@Avasam Avasam reopened this Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants