linux-rt-upscaler 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- linux_rt_upscaler-0.1.0/MANIFEST.in +5 -0
- linux_rt_upscaler-0.1.0/PKG-INFO +96 -0
- linux_rt_upscaler-0.1.0/README.md +67 -0
- linux_rt_upscaler-0.1.0/pyproject.toml +51 -0
- linux_rt_upscaler-0.1.0/scripts/upscale.sh +9 -0
- linux_rt_upscaler-0.1.0/setup.cfg +4 -0
- linux_rt_upscaler-0.1.0/src/linux_rt_upscaler.egg-info/PKG-INFO +96 -0
- linux_rt_upscaler-0.1.0/src/linux_rt_upscaler.egg-info/SOURCES.txt +22 -0
- linux_rt_upscaler-0.1.0/src/linux_rt_upscaler.egg-info/dependency_links.txt +1 -0
- linux_rt_upscaler-0.1.0/src/linux_rt_upscaler.egg-info/entry_points.txt +2 -0
- linux_rt_upscaler-0.1.0/src/linux_rt_upscaler.egg-info/requires.txt +4 -0
- linux_rt_upscaler-0.1.0/src/linux_rt_upscaler.egg-info/top_level.txt +1 -0
- linux_rt_upscaler-0.1.0/src/upscaler/__init__.py +3 -0
- linux_rt_upscaler-0.1.0/src/upscaler/capture/__init__.py +5 -0
- linux_rt_upscaler-0.1.0/src/upscaler/capture/capture.py +32 -0
- linux_rt_upscaler-0.1.0/src/upscaler/capture/captureRGBX.c +137 -0
- linux_rt_upscaler-0.1.0/src/upscaler/capture/captureRGBX.so +0 -0
- linux_rt_upscaler-0.1.0/src/upscaler/cli.py +576 -0
- linux_rt_upscaler-0.1.0/src/upscaler/shaders/CuNNy-veryfast-NVL_Pass1.hlsl +155 -0
- linux_rt_upscaler-0.1.0/src/upscaler/shaders/CuNNy-veryfast-NVL_Pass2.hlsl +176 -0
- linux_rt_upscaler-0.1.0/src/upscaler/shaders/CuNNy-veryfast-NVL_Pass3.hlsl +155 -0
- linux_rt_upscaler-0.1.0/src/upscaler/shaders/CuNNy-veryfast-NVL_Pass4.hlsl +152 -0
- linux_rt_upscaler-0.1.0/src/upscaler/shaders/__init__.py +5 -0
- linux_rt_upscaler-0.1.0/src/upscaler/shaders/srcnn.py +162 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: linux-rt-upscaler
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Real-time AI upscaler for any Linux window using CuNNy
|
|
5
|
+
Author-email: Mauricio Valentín Barón Salinas <baronsmv@gmail.com>
|
|
6
|
+
License: GPL3.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/baronsmv/linux-rt-upscaler
|
|
8
|
+
Project-URL: Repository, https://github.com/baronsmv/linux-rt-upscaler.git
|
|
9
|
+
Project-URL: BugTracker, https://github.com/baronsmv/linux-rt-upscaler/issues
|
|
10
|
+
Keywords: upscaler,ai,cunny,linux,x11,vulkan
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
13
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Multimedia :: Graphics :: Capture
|
|
22
|
+
Classifier: Topic :: System :: Hardware :: Hardware Drivers
|
|
23
|
+
Requires-Python: >=3.8
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
Requires-Dist: compushady
|
|
26
|
+
Requires-Dist: pyside6
|
|
27
|
+
Requires-Dist: numpy
|
|
28
|
+
Requires-Dist: xlib
|
|
29
|
+
|
|
30
|
+
# Real‑Time Upscaler for Linux
|
|
31
|
+
|
|
32
|
+
A real‑time AI upscaler for any application window on GNU/Linux. Uses **CuNNy‑veryfast** neural networks to perform 2× upscaling, with full‑screen stretching and optional click/motion forwarding.
|
|
33
|
+
|
|
34
|
+
## Based on
|
|
35
|
+
|
|
36
|
+
Based on [RealTimeSuperResolutionScreenUpscalerforLinux](https://github.com/L65536/RealTimeSuperResolutionScreenUpscalerforLinux) by L65536, with the following differences:
|
|
37
|
+
|
|
38
|
+
- **Full‑screen scaling** – The upscaled image now fills the monitor, applying a second scaling layer while preserving aspect ratio.
|
|
39
|
+
- **Click/motion forwarding** – With the `-m` flag, mouse clicks and motion are forwarded to the original window with proper coordinate transformation.
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- **AI‑Powered Upscaling** – Uses CuNNy‑veryfast (4‑pass) neural network for high‑quality 2× upscaling.
|
|
44
|
+
- **Any Window** – Attach to an existing window or launch a new program.
|
|
45
|
+
- **Full‑Screen Output** – Stretch the upscaled image to fill your monitor (aspect‑ratio preserved, black bars).
|
|
46
|
+
- **Click/Motion Forwarding** (`-m`) – Click and move the mouse on the upscaled image as if it were the real window.
|
|
47
|
+
- **Opacity Control** – Overlay dims when mouse leaves the source window (optional, disabled with `-m`).
|
|
48
|
+
- **Hardware Accelerated** – GPU‑based compute via Compushady (Vulkan/Direct3D 12).
|
|
49
|
+
- **Low Overhead** – Minimal performance impact; scaling pass uses hardware bilinear filtering.
|
|
50
|
+
|
|
51
|
+
## Requirements
|
|
52
|
+
|
|
53
|
+
- GNU/Linux with X11 (Wayland not supported)
|
|
54
|
+
- Vulkan-capable GPU from any vendor (NVIDIA, AMD, Intel)
|
|
55
|
+
- Vulkan drivers (`libvulkan-dev` on Debian/Ubuntu)
|
|
56
|
+
- X11 development libraries (`libx11-dev`)
|
|
57
|
+
- Python 3.8 or newer
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
1. **Clone the repository**
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
git clone https://github.com/baronsmv/linux-rt-upscaler.git
|
|
65
|
+
cd linux-rt-upscaler
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
2. **Install system dependencies** (Debian/Ubuntu)
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
sudo apt install libvulkan-dev libx11-dev
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
3. **Install Python packages**
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pip install -r requirements.txt
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Usage
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Upscale the currently active window
|
|
84
|
+
python main.py
|
|
85
|
+
|
|
86
|
+
# Enable click/motion forwarding (mouse interacts with upscaled window)
|
|
87
|
+
python main.py -m
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Acknowledgments
|
|
91
|
+
|
|
92
|
+
- **[L65536](https://github.com/L65536)** – For the [RealTimeSuperResolutionScreenUpscalerforLinux](https://github.com/L65536/RealTimeSuperResolutionScreenUpscalerforLinux) project, which provided the foundational scripts and CuNNy integration that this project builds upon
|
|
93
|
+
- **CuNNy** – Neural network upscaling models
|
|
94
|
+
- **Compushady** – Python GPU compute library
|
|
95
|
+
- **PySide6** – Qt bindings for the overlay
|
|
96
|
+
- **python‑xlib** – X11 client library
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Real‑Time Upscaler for Linux
|
|
2
|
+
|
|
3
|
+
A real‑time AI upscaler for any application window on GNU/Linux. Uses **CuNNy‑veryfast** neural networks to perform 2× upscaling, with full‑screen stretching and optional click/motion forwarding.
|
|
4
|
+
|
|
5
|
+
## Based on
|
|
6
|
+
|
|
7
|
+
Based on [RealTimeSuperResolutionScreenUpscalerforLinux](https://github.com/L65536/RealTimeSuperResolutionScreenUpscalerforLinux) by L65536, with the following differences:
|
|
8
|
+
|
|
9
|
+
- **Full‑screen scaling** – The upscaled image now fills the monitor, applying a second scaling layer while preserving aspect ratio.
|
|
10
|
+
- **Click/motion forwarding** – With the `-m` flag, mouse clicks and motion are forwarded to the original window with proper coordinate transformation.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- **AI‑Powered Upscaling** – Uses CuNNy‑veryfast (4‑pass) neural network for high‑quality 2× upscaling.
|
|
15
|
+
- **Any Window** – Attach to an existing window or launch a new program.
|
|
16
|
+
- **Full‑Screen Output** – Stretch the upscaled image to fill your monitor (aspect‑ratio preserved, black bars).
|
|
17
|
+
- **Click/Motion Forwarding** (`-m`) – Click and move the mouse on the upscaled image as if it were the real window.
|
|
18
|
+
- **Opacity Control** – Overlay dims when mouse leaves the source window (optional, disabled with `-m`).
|
|
19
|
+
- **Hardware Accelerated** – GPU‑based compute via Compushady (Vulkan/Direct3D 12).
|
|
20
|
+
- **Low Overhead** – Minimal performance impact; scaling pass uses hardware bilinear filtering.
|
|
21
|
+
|
|
22
|
+
## Requirements
|
|
23
|
+
|
|
24
|
+
- GNU/Linux with X11 (Wayland not supported)
|
|
25
|
+
- Vulkan-capable GPU from any vendor (NVIDIA, AMD, Intel)
|
|
26
|
+
- Vulkan drivers (`libvulkan-dev` on Debian/Ubuntu)
|
|
27
|
+
- X11 development libraries (`libx11-dev`)
|
|
28
|
+
- Python 3.8 or newer
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
1. **Clone the repository**
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
git clone https://github.com/baronsmv/linux-rt-upscaler.git
|
|
36
|
+
cd linux-rt-upscaler
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
2. **Install system dependencies** (Debian/Ubuntu)
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
sudo apt install libvulkan-dev libx11-dev
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
3. **Install Python packages**
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install -r requirements.txt
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Upscale the currently active window
|
|
55
|
+
python main.py
|
|
56
|
+
|
|
57
|
+
# Enable click/motion forwarding (mouse interacts with upscaled window)
|
|
58
|
+
python main.py -m
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Acknowledgments
|
|
62
|
+
|
|
63
|
+
- **[L65536](https://github.com/L65536)** – For the [RealTimeSuperResolutionScreenUpscalerforLinux](https://github.com/L65536/RealTimeSuperResolutionScreenUpscalerforLinux) project, which provided the foundational scripts and CuNNy integration that this project builds upon
|
|
64
|
+
- **CuNNy** – Neural network upscaling models
|
|
65
|
+
- **Compushady** – Python GPU compute library
|
|
66
|
+
- **PySide6** – Qt bindings for the overlay
|
|
67
|
+
- **python‑xlib** – X11 client library
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "linux-rt-upscaler"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Real-time AI upscaler for any Linux window using CuNNy"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name = "Mauricio Valentín Barón Salinas", email = "baronsmv@gmail.com" }
|
|
12
|
+
]
|
|
13
|
+
license = { text = "GPL3.0" }
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: End Users/Desktop",
|
|
17
|
+
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
|
18
|
+
"Operating System :: POSIX :: Linux",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.8",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Topic :: Multimedia :: Graphics :: Capture",
|
|
26
|
+
"Topic :: System :: Hardware :: Hardware Drivers",
|
|
27
|
+
]
|
|
28
|
+
keywords = ["upscaler", "ai", "cunny", "linux", "x11", "vulkan"]
|
|
29
|
+
requires-python = ">=3.8"
|
|
30
|
+
dependencies = [
|
|
31
|
+
"compushady",
|
|
32
|
+
"pyside6",
|
|
33
|
+
"numpy",
|
|
34
|
+
"xlib",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Homepage = "https://github.com/baronsmv/linux-rt-upscaler"
|
|
39
|
+
Repository = "https://github.com/baronsmv/linux-rt-upscaler.git"
|
|
40
|
+
BugTracker = "https://github.com/baronsmv/linux-rt-upscaler/issues"
|
|
41
|
+
|
|
42
|
+
[project.scripts]
|
|
43
|
+
upscale = "upscaler.cli:main"
|
|
44
|
+
|
|
45
|
+
[tool.setuptools]
|
|
46
|
+
package-dir = { "" = "src" }
|
|
47
|
+
packages = ["upscaler", "upscaler.capture", "upscaler.shaders"]
|
|
48
|
+
|
|
49
|
+
[tool.setuptools.package-data]
|
|
50
|
+
"upscaler.shaders" = ["*.hlsl", "*.py"]
|
|
51
|
+
"upscaler.capture" = ["*.c", "*.so"]
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: linux-rt-upscaler
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Real-time AI upscaler for any Linux window using CuNNy
|
|
5
|
+
Author-email: Mauricio Valentín Barón Salinas <baronsmv@gmail.com>
|
|
6
|
+
License: GPL3.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/baronsmv/linux-rt-upscaler
|
|
8
|
+
Project-URL: Repository, https://github.com/baronsmv/linux-rt-upscaler.git
|
|
9
|
+
Project-URL: BugTracker, https://github.com/baronsmv/linux-rt-upscaler/issues
|
|
10
|
+
Keywords: upscaler,ai,cunny,linux,x11,vulkan
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
13
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Multimedia :: Graphics :: Capture
|
|
22
|
+
Classifier: Topic :: System :: Hardware :: Hardware Drivers
|
|
23
|
+
Requires-Python: >=3.8
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
Requires-Dist: compushady
|
|
26
|
+
Requires-Dist: pyside6
|
|
27
|
+
Requires-Dist: numpy
|
|
28
|
+
Requires-Dist: xlib
|
|
29
|
+
|
|
30
|
+
# Real‑Time Upscaler for Linux
|
|
31
|
+
|
|
32
|
+
A real‑time AI upscaler for any application window on GNU/Linux. Uses **CuNNy‑veryfast** neural networks to perform 2× upscaling, with full‑screen stretching and optional click/motion forwarding.
|
|
33
|
+
|
|
34
|
+
## Based on
|
|
35
|
+
|
|
36
|
+
Based on [RealTimeSuperResolutionScreenUpscalerforLinux](https://github.com/L65536/RealTimeSuperResolutionScreenUpscalerforLinux) by L65536, with the following differences:
|
|
37
|
+
|
|
38
|
+
- **Full‑screen scaling** – The upscaled image now fills the monitor, applying a second scaling layer while preserving aspect ratio.
|
|
39
|
+
- **Click/motion forwarding** – With the `-m` flag, mouse clicks and motion are forwarded to the original window with proper coordinate transformation.
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- **AI‑Powered Upscaling** – Uses CuNNy‑veryfast (4‑pass) neural network for high‑quality 2× upscaling.
|
|
44
|
+
- **Any Window** – Attach to an existing window or launch a new program.
|
|
45
|
+
- **Full‑Screen Output** – Stretch the upscaled image to fill your monitor (aspect‑ratio preserved, black bars).
|
|
46
|
+
- **Click/Motion Forwarding** (`-m`) – Click and move the mouse on the upscaled image as if it were the real window.
|
|
47
|
+
- **Opacity Control** – Overlay dims when mouse leaves the source window (optional, disabled with `-m`).
|
|
48
|
+
- **Hardware Accelerated** – GPU‑based compute via Compushady (Vulkan/Direct3D 12).
|
|
49
|
+
- **Low Overhead** – Minimal performance impact; scaling pass uses hardware bilinear filtering.
|
|
50
|
+
|
|
51
|
+
## Requirements
|
|
52
|
+
|
|
53
|
+
- GNU/Linux with X11 (Wayland not supported)
|
|
54
|
+
- Vulkan-capable GPU from any vendor (NVIDIA, AMD, Intel)
|
|
55
|
+
- Vulkan drivers (`libvulkan-dev` on Debian/Ubuntu)
|
|
56
|
+
- X11 development libraries (`libx11-dev`)
|
|
57
|
+
- Python 3.8 or newer
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
1. **Clone the repository**
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
git clone https://github.com/baronsmv/linux-rt-upscaler.git
|
|
65
|
+
cd linux-rt-upscaler
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
2. **Install system dependencies** (Debian/Ubuntu)
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
sudo apt install libvulkan-dev libx11-dev
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
3. **Install Python packages**
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pip install -r requirements.txt
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Usage
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Upscale the currently active window
|
|
84
|
+
python main.py
|
|
85
|
+
|
|
86
|
+
# Enable click/motion forwarding (mouse interacts with upscaled window)
|
|
87
|
+
python main.py -m
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Acknowledgments
|
|
91
|
+
|
|
92
|
+
- **[L65536](https://github.com/L65536)** – For the [RealTimeSuperResolutionScreenUpscalerforLinux](https://github.com/L65536/RealTimeSuperResolutionScreenUpscalerforLinux) project, which provided the foundational scripts and CuNNy integration that this project builds upon
|
|
93
|
+
- **CuNNy** – Neural network upscaling models
|
|
94
|
+
- **Compushady** – Python GPU compute library
|
|
95
|
+
- **PySide6** – Qt bindings for the overlay
|
|
96
|
+
- **python‑xlib** – X11 client library
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MANIFEST.in
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
scripts/upscale.sh
|
|
5
|
+
src/linux_rt_upscaler.egg-info/PKG-INFO
|
|
6
|
+
src/linux_rt_upscaler.egg-info/SOURCES.txt
|
|
7
|
+
src/linux_rt_upscaler.egg-info/dependency_links.txt
|
|
8
|
+
src/linux_rt_upscaler.egg-info/entry_points.txt
|
|
9
|
+
src/linux_rt_upscaler.egg-info/requires.txt
|
|
10
|
+
src/linux_rt_upscaler.egg-info/top_level.txt
|
|
11
|
+
src/upscaler/__init__.py
|
|
12
|
+
src/upscaler/cli.py
|
|
13
|
+
src/upscaler/capture/__init__.py
|
|
14
|
+
src/upscaler/capture/capture.py
|
|
15
|
+
src/upscaler/capture/captureRGBX.c
|
|
16
|
+
src/upscaler/capture/captureRGBX.so
|
|
17
|
+
src/upscaler/shaders/CuNNy-veryfast-NVL_Pass1.hlsl
|
|
18
|
+
src/upscaler/shaders/CuNNy-veryfast-NVL_Pass2.hlsl
|
|
19
|
+
src/upscaler/shaders/CuNNy-veryfast-NVL_Pass3.hlsl
|
|
20
|
+
src/upscaler/shaders/CuNNy-veryfast-NVL_Pass4.hlsl
|
|
21
|
+
src/upscaler/shaders/__init__.py
|
|
22
|
+
src/upscaler/shaders/srcnn.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
upscaler
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""
|
|
2
|
+
X11 window capture module using a custom C library.
|
|
3
|
+
Provides a capture_worker function that puts raw bitmap data into a queue.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import ctypes
|
|
7
|
+
import os
|
|
8
|
+
|
|
9
|
+
LibName = "captureRGBX.so"
|
|
10
|
+
AbsLibPath = os.path.dirname(os.path.abspath(__file__)) + os.path.sep + LibName
|
|
11
|
+
cap = ctypes.CDLL(AbsLibPath)
|
|
12
|
+
|
|
13
|
+
# Global flag to signal worker thread to stop
|
|
14
|
+
running = True
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def capture_worker(capture_queue, handle, clientW, clientH):
|
|
18
|
+
"""
|
|
19
|
+
Worker thread that continuously captures the specified X11 window.
|
|
20
|
+
Puts a ctypes buffer (clientW*clientH*4 bytes) into capture_queue.
|
|
21
|
+
"""
|
|
22
|
+
global running
|
|
23
|
+
cbuffer = (ctypes.c_ubyte * clientW * clientH * 4)()
|
|
24
|
+
# Timing variables (optional)
|
|
25
|
+
count = 0
|
|
26
|
+
|
|
27
|
+
while running:
|
|
28
|
+
# Note: window must not be minimized, otherwise capture may fail.
|
|
29
|
+
cap.captureBGRX(0, 0, clientW, clientH, handle, cbuffer)
|
|
30
|
+
if running:
|
|
31
|
+
capture_queue.put(cbuffer)
|
|
32
|
+
count += 1
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
#include <stdio.h>
|
|
2
|
+
#include <X11/X.h>
|
|
3
|
+
#include <X11/Xlib.h>
|
|
4
|
+
#include <X11/Xutil.h>
|
|
5
|
+
// For python ctypes, capture a window(xid) with XLIB, saves to provided buffer in RGBX RGBA BGRX BGRA formats
|
|
6
|
+
// gcc -shared -O3 -lX11 -fPIC -Wl,-soname,prtscn -o captureRGBX.so captureRGBX.c
|
|
7
|
+
// gcc -shared -O3 -lX11 -fPIC -o captureRGBX.so captureRGBX.c
|
|
8
|
+
// -03 = SIMD support
|
|
9
|
+
// REF https://stackoverflow.com/questions/69645/take-a-screenshot-via-a-python-script-on-linux/16141058#16141058
|
|
10
|
+
|
|
11
|
+
void captureRGBX(const int, const int, const int, const int, const XID, unsigned char *);
|
|
12
|
+
void captureRGBX(const int xx,const int yy,const int W, const int H, const XID xid, unsigned char * output_data)
|
|
13
|
+
{
|
|
14
|
+
Display *display = XOpenDisplay(NULL);
|
|
15
|
+
//Window root = DefaultRootWindow(display);
|
|
16
|
+
//XImage *image = XGetImage(display,root, xx,yy, W,H, AllPlanes, ZPixmap);
|
|
17
|
+
XImage *image = XGetImage(display, xid, 0, 0, W, H, AllPlanes, ZPixmap);
|
|
18
|
+
// if (!image) printf("XGetImage failed xid=%d\n", xid); // xlib aborts with its own error msg, this line does not run
|
|
19
|
+
|
|
20
|
+
unsigned long red_mask = image->red_mask;
|
|
21
|
+
unsigned long green_mask = image->green_mask;
|
|
22
|
+
unsigned long blue_mask = image->blue_mask;
|
|
23
|
+
int x, y;
|
|
24
|
+
int ii = 0;
|
|
25
|
+
for (y = 0; y < H; y++) {
|
|
26
|
+
for (x = 0; x < W; x++) {
|
|
27
|
+
unsigned long pixel = XGetPixel(image,x,y);
|
|
28
|
+
unsigned char blue = (pixel & blue_mask);
|
|
29
|
+
unsigned char green = (pixel & green_mask) >> 8;
|
|
30
|
+
unsigned char red = (pixel & red_mask) >> 16;
|
|
31
|
+
// output_data[ii + 3] = 0;
|
|
32
|
+
output_data[ii + 2] = blue;
|
|
33
|
+
output_data[ii + 1] = green;
|
|
34
|
+
output_data[ii + 0] = red;
|
|
35
|
+
ii += 4;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
XDestroyImage(image);
|
|
39
|
+
//XDestroyWindow(display, root);
|
|
40
|
+
XCloseDisplay(display);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void captureRGBA(const int, const int, const int, const int, const XID, unsigned char *);
|
|
44
|
+
void captureRGBA(const int xx,const int yy,const int W, const int H, const XID xid, unsigned char * output_data)
|
|
45
|
+
{
|
|
46
|
+
Display *display = XOpenDisplay(NULL);
|
|
47
|
+
//Window root = DefaultRootWindow(display);
|
|
48
|
+
//XImage *image = XGetImage(display,root, xx,yy, W,H, AllPlanes, ZPixmap);
|
|
49
|
+
XImage *image = XGetImage(display, xid, 0, 0, W, H, AllPlanes, ZPixmap);
|
|
50
|
+
// if (!image) printf("XGetImage failed xid=%d\n", xid); // xlib aborts with its own error msg, this line does not run
|
|
51
|
+
|
|
52
|
+
unsigned long red_mask = image->red_mask;
|
|
53
|
+
unsigned long green_mask = image->green_mask;
|
|
54
|
+
unsigned long blue_mask = image->blue_mask;
|
|
55
|
+
int x, y;
|
|
56
|
+
int ii = 0;
|
|
57
|
+
for (y = 0; y < H; y++) {
|
|
58
|
+
for (x = 0; x < W; x++) {
|
|
59
|
+
unsigned long pixel = XGetPixel(image,x,y);
|
|
60
|
+
unsigned char blue = (pixel & blue_mask);
|
|
61
|
+
unsigned char green = (pixel & green_mask) >> 8;
|
|
62
|
+
unsigned char red = (pixel & red_mask) >> 16;
|
|
63
|
+
output_data[ii + 3] = 0xff;
|
|
64
|
+
output_data[ii + 2] = blue;
|
|
65
|
+
output_data[ii + 1] = green;
|
|
66
|
+
output_data[ii + 0] = red;
|
|
67
|
+
ii += 4;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
XDestroyImage(image);
|
|
71
|
+
//XDestroyWindow(display, root);
|
|
72
|
+
XCloseDisplay(display);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
void captureBGRX(const int, const int, const int, const int, const XID, unsigned char *);
|
|
76
|
+
void captureBGRX(const int xx,const int yy,const int W, const int H, const XID xid, unsigned char * output_data)
|
|
77
|
+
{
|
|
78
|
+
Display *display = XOpenDisplay(NULL);
|
|
79
|
+
//Window root = DefaultRootWindow(display);
|
|
80
|
+
//XImage *image = XGetImage(display,root, xx,yy, W,H, AllPlanes, ZPixmap);
|
|
81
|
+
XImage *image = XGetImage(display, xid, 0, 0, W, H, AllPlanes, ZPixmap);
|
|
82
|
+
// if (!image) printf("XGetImage failed xid=%d\n", xid); // xlib aborts with its own error msg, this line does not run
|
|
83
|
+
|
|
84
|
+
unsigned long red_mask = image->red_mask;
|
|
85
|
+
unsigned long green_mask = image->green_mask;
|
|
86
|
+
unsigned long blue_mask = image->blue_mask;
|
|
87
|
+
int x, y;
|
|
88
|
+
int ii = 0;
|
|
89
|
+
for (y = 0; y < H; y++) {
|
|
90
|
+
for (x = 0; x < W; x++) {
|
|
91
|
+
unsigned long pixel = XGetPixel(image,x,y);
|
|
92
|
+
unsigned char blue = (pixel & blue_mask);
|
|
93
|
+
unsigned char green = (pixel & green_mask) >> 8;
|
|
94
|
+
unsigned char red = (pixel & red_mask) >> 16;
|
|
95
|
+
// output_data[ii + 3] = 0;
|
|
96
|
+
output_data[ii + 2] = red; // blue;
|
|
97
|
+
output_data[ii + 1] = green;
|
|
98
|
+
output_data[ii + 0] = blue; // red;
|
|
99
|
+
ii += 4;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
XDestroyImage(image);
|
|
103
|
+
//XDestroyWindow(display, root);
|
|
104
|
+
XCloseDisplay(display);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
void captureBGRA(const int, const int, const int, const int, const XID, unsigned char *);
|
|
108
|
+
void captureBGRA(const int xx,const int yy,const int W, const int H, const XID xid, unsigned char * output_data)
|
|
109
|
+
{
|
|
110
|
+
Display *display = XOpenDisplay(NULL);
|
|
111
|
+
//Window root = DefaultRootWindow(display);
|
|
112
|
+
//XImage *image = XGetImage(display,root, xx,yy, W,H, AllPlanes, ZPixmap);
|
|
113
|
+
XImage *image = XGetImage(display, xid, 0, 0, W, H, AllPlanes, ZPixmap);
|
|
114
|
+
// if (!image) printf("XGetImage failed xid=%d\n", xid); // xlib aborts with its own error msg, this line does not run
|
|
115
|
+
|
|
116
|
+
unsigned long red_mask = image->red_mask;
|
|
117
|
+
unsigned long green_mask = image->green_mask;
|
|
118
|
+
unsigned long blue_mask = image->blue_mask;
|
|
119
|
+
int x, y;
|
|
120
|
+
int ii = 0;
|
|
121
|
+
for (y = 0; y < H; y++) {
|
|
122
|
+
for (x = 0; x < W; x++) {
|
|
123
|
+
unsigned long pixel = XGetPixel(image,x,y);
|
|
124
|
+
unsigned char blue = (pixel & blue_mask);
|
|
125
|
+
unsigned char green = (pixel & green_mask) >> 8;
|
|
126
|
+
unsigned char red = (pixel & red_mask) >> 16;
|
|
127
|
+
output_data[ii + 3] = 0xff;
|
|
128
|
+
output_data[ii + 2] = red; // blue;
|
|
129
|
+
output_data[ii + 1] = green;
|
|
130
|
+
output_data[ii + 0] = blue; // red;
|
|
131
|
+
ii += 4;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
XDestroyImage(image);
|
|
135
|
+
//XDestroyWindow(display, root);
|
|
136
|
+
XCloseDisplay(display);
|
|
137
|
+
}
|
|
Binary file
|