Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/Toufool/AutoSplit into Remov…
Browse files Browse the repository at this point in the history
…e-WGC-technical-limitation
  • Loading branch information
Avasam committed Oct 20, 2024
2 parents 989fe45 + bd6cf54 commit a083f91
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: pretty-format-json
exclude: ".vscode/.*" # Exclude jsonc
Expand All @@ -19,7 +19,7 @@ repos:
- id: pretty-format-ini
args: [--autofix]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.8 # Must match requirements-dev.txt
rev: v0.6.9 # Must match requirements-dev.txt
hooks:
- id: ruff
args: [--fix]
Expand Down
3 changes: 2 additions & 1 deletion docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
- **Direct3D Desktop Duplication** (slower, bound to display)
Duplicates the desktop using Direct3D.
It can record OpenGL and Hardware Accelerated windows.
About 10-15x slower than BitBlt. Not affected by window size.
Up to 15x slower than BitBlt for tiny regions. Not affected by window size.
Limited by the target window and monitor's refresh rate.
Overlapping windows will show up and can't record across displays.
This option may not be available for hybrid GPU laptops, see [D3DDD-Note-Laptops.md](/docs/D3DDD-Note-Laptops.md) for a solution.
- **Force Full Content Rendering** (very slow, can affect rendering)
Expand Down
3 changes: 2 additions & 1 deletion scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ $arguments = @(
'--exclude=pytweening',
'--exclude=mouseinfo')
if ($IsWindows) {
# These are used on Linux
$arguments += @(
# Installed by PyAutoGUI, but used by linux
# Installed by PyAutoGUI
'--exclude=pyscreeze'
# Installed by D3DShot
'--exclude=PIL')
Expand Down
4 changes: 1 addition & 3 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ If ($IsLinux) {
# These libraries install extra requirements we don't want
# Open suggestion for support in requirements files: https://github.com/pypa/pip/issues/9948 & https://github.com/pypa/pip/pull/10837
# PyAutoGUI: We only use it for hotkeys
# D3DShot: Will install Pillow, which we don't use on Windows.
# Even then, PyPI with Pillow>=7.2.0 will install 0.1.3 instead of 0.1.5
&"$python" -m pip install PyAutoGUI "D3DShot>=0.1.5 ; sys_platform == 'win32'" --no-deps --upgrade
&"$python" -m pip install PyAutoGUI --no-deps --upgrade

# Uninstall optional dependencies if PyAutoGUI or D3DShot was installed outside this script
# PyScreeze -> pyscreenshot -> mss deps call SetProcessDpiAwareness, used to be installed on Windows
Expand Down
3 changes: 1 addition & 2 deletions scripts/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
-r requirements.txt
#
# Linters & Formatters
ruff>=0.6.8 # Pre-commit fix # Must match .pre-commit-config.yaml
ruff>=0.6.9 # Pre-commit fix # Must match .pre-commit-config.yaml
#
# Types
types-D3DShot ; sys_platform == 'win32'
types-keyboard
types-psutil
types-PyAutoGUI
Expand Down
5 changes: 4 additions & 1 deletion scripts/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@ PySide6-Essentials>=6.6.0 # Python 3.12 support
scipy>=1.11.2 # Python 3.12 support
tomli-w>=1.1.0 # Typing fixes
typing-extensions>=4.4.0 # @override decorator support

#
# Build and compile resources
#
pyinstaller>=5.13 # Python 3.12 support

#
# https://peps.python.org/pep-0508/#environment-markers
#
# Windows-only dependencies:
comtypes<1.4.5 ; sys_platform == 'win32' # https://github.com/pyinstaller/pyinstaller-hooks-contrib/issues/807
pygrabber>=0.2 ; sys_platform == 'win32' # Completed types
pywin32>=301 ; sys_platform == 'win32'
typed-D3DShot[numpy]>=1.0.1 ; sys_platform == 'win32'
winrt-Windows.Graphics.Capture>=2.2.0 ; sys_platform == 'win32' # Python 3.13 support
winrt-Windows.Graphics.Capture.Interop>=2.2.0 ; sys_platform == 'win32' # Python 3.13 support
winrt-Windows.Graphics.DirectX>=2.2.0 ; sys_platform == 'win32' # Python 3.13 support
winrt-Windows.Graphics.DirectX.Direct3D11.Interop>=2.3.0 ; sys_platform == 'win32'
winrt-Windows.Graphics.Imaging>=2.2.0 ; sys_platform == 'win32' # Python 3.13 support
# D3DShot # See install.ps1
#
# Linux-only dependencies
PyScreeze ; sys_platform == 'linux'
Expand Down
11 changes: 4 additions & 7 deletions src/capture_method/DesktopDuplicationCaptureMethod.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

if sys.platform != "win32":
raise OSError
from typing import TYPE_CHECKING, cast
from typing import TYPE_CHECKING

import cv2
import d3dshot
import win32api
import win32con
import win32gui
from cv2.typing import MatLike
from typing_extensions import override

from capture_method.BitBltCaptureMethod import BitBltCaptureMethod
Expand All @@ -25,7 +24,8 @@ class DesktopDuplicationCaptureMethod(BitBltCaptureMethod):
description = f"""
Duplicates the desktop using Direct3D.
It can record OpenGL and Hardware Accelerated windows.
About 10-15x slower than BitBlt. Not affected by window size.
Up to 15x slower than BitBlt for tiny regions. Not affected by window size.
Limited by the target window and monitor's refresh rate.
Overlapping windows will show up and can't record across displays.
This option may not be available for hybrid GPU laptops,
see D3DDD-Note-Laptops.md for a solution.
Expand Down Expand Up @@ -57,10 +57,7 @@ def get_frame(self):
top = selection["y"] + offset_y + top_bounds
right = selection["width"] + left
bottom = selection["height"] + top
screenshot = cast(
MatLike | None,
self.desktop_duplication.screenshot((left, top, right, bottom)),
)
screenshot = self.desktop_duplication.screenshot((left, top, right, bottom))
if screenshot is None:
return None
return cv2.cvtColor(screenshot, cv2.COLOR_RGB2BGRA)

0 comments on commit a083f91

Please sign in to comment.