lupine-sdk 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.
- lupine_sdk-0.1.0/LICENSE +21 -0
- lupine_sdk-0.1.0/MANIFEST.in +2 -0
- lupine_sdk-0.1.0/PKG-INFO +273 -0
- lupine_sdk-0.1.0/README.md +240 -0
- lupine_sdk-0.1.0/lupine/__init__.py +95 -0
- lupine_sdk-0.1.0/lupine/automation.py +214 -0
- lupine_sdk-0.1.0/lupine/backup.py +180 -0
- lupine_sdk-0.1.0/lupine/camera.py +1084 -0
- lupine_sdk-0.1.0/lupine/cli.py +348 -0
- lupine_sdk-0.1.0/lupine/events.py +221 -0
- lupine_sdk-0.1.0/lupine/exceptions.py +47 -0
- lupine_sdk-0.1.0/lupine/exif.py +277 -0
- lupine_sdk-0.1.0/lupine/liveview.py +189 -0
- lupine_sdk-0.1.0/lupine/protocol/__init__.py +239 -0
- lupine_sdk-0.1.0/lupine/protocol/datatypes.py +164 -0
- lupine_sdk-0.1.0/lupine/protocol/opcodes.py +50 -0
- lupine_sdk-0.1.0/lupine/protocol/properties.py +690 -0
- lupine_sdk-0.1.0/lupine/py.typed +0 -0
- lupine_sdk-0.1.0/lupine/transport/__init__.py +86 -0
- lupine_sdk-0.1.0/lupine/transport/base.py +99 -0
- lupine_sdk-0.1.0/lupine/transport/mock.py +437 -0
- lupine_sdk-0.1.0/lupine/transport/usb.py +938 -0
- lupine_sdk-0.1.0/lupine/transport/wpd.py +802 -0
- lupine_sdk-0.1.0/lupine_sdk.egg-info/PKG-INFO +273 -0
- lupine_sdk-0.1.0/lupine_sdk.egg-info/SOURCES.txt +39 -0
- lupine_sdk-0.1.0/lupine_sdk.egg-info/dependency_links.txt +1 -0
- lupine_sdk-0.1.0/lupine_sdk.egg-info/entry_points.txt +2 -0
- lupine_sdk-0.1.0/lupine_sdk.egg-info/requires.txt +10 -0
- lupine_sdk-0.1.0/lupine_sdk.egg-info/top_level.txt +1 -0
- lupine_sdk-0.1.0/pyproject.toml +76 -0
- lupine_sdk-0.1.0/setup.cfg +4 -0
- lupine_sdk-0.1.0/tests/conftest.py +29 -0
- lupine_sdk-0.1.0/tests/fixtures/a7iii_sample_backup.json +1482 -0
- lupine_sdk-0.1.0/tests/fixtures/sample_sony.jpg +0 -0
- lupine_sdk-0.1.0/tests/test_automation_liveview.py +82 -0
- lupine_sdk-0.1.0/tests/test_backup_exif.py +67 -0
- lupine_sdk-0.1.0/tests/test_camera.py +146 -0
- lupine_sdk-0.1.0/tests/test_events.py +79 -0
- lupine_sdk-0.1.0/tests/test_hardware_live.py +409 -0
- lupine_sdk-0.1.0/tests/test_protocol.py +143 -0
- lupine_sdk-0.1.0/tests/test_usb_transport.py +376 -0
lupine_sdk-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zeyad Al-Najjar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lupine-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Programmatic USB control SDK for Sony Alpha cameras (ILCE-7M3 / A7 III) over Windows WPD and Linux/macOS libusb PTP
|
|
5
|
+
Author: Zeyad Al-Najjar
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/znajjar/LupineSDK
|
|
8
|
+
Project-URL: Repository, https://github.com/znajjar/LupineSDK
|
|
9
|
+
Project-URL: Documentation, https://github.com/znajjar/LupineSDK/tree/main/docs
|
|
10
|
+
Project-URL: Issues, https://github.com/znajjar/LupineSDK/issues
|
|
11
|
+
Keywords: sony,alpha,a7iii,camera,ptp,sdio,usb,wpd,libusb,sdk
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Multimedia :: Graphics :: Capture :: Digital Camera
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: comtypes>=1.4.0; sys_platform == "win32"
|
|
28
|
+
Requires-Dist: pyusb>=1.2.1; sys_platform != "win32"
|
|
29
|
+
Requires-Dist: Pillow>=10.0.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# Lupine SDK
|
|
35
|
+
|
|
36
|
+
**Lupine** is a cross-platform Python SDK and CLI for programmatic USB control of **Sony Alpha cameras** (built and verified live on **Sony Alpha 7 III / `ILCE-7M3 v4.01`** on Windows, Linux/WSL2, and macOS).
|
|
37
|
+
|
|
38
|
+
- **Cross-platform native USB:** Automatically uses Windows' built-in **WPD/MTP** stack (`PortableDeviceApi.dll` / `wpdmtp.inf`, zero driver swap) on Windows, and direct **`libusb-1.0` (`pyusb`)** ISO 15740 USB Still Image Class (PTP) on Linux (including WSL2 via `usbipd-win`) and macOS.
|
|
39
|
+
- **Full Sony SDIO protocol:** Implements Sony's 3-phase `0x9201` handshake, `0x9202` capability info, `0x9209` bulk property decoding (all 60 properties), `0x9205` direct property writes, `0x9207` control & relative dial stepping (`ISO`, `Shutter`, `Aperture`, `EV`, `Flash Comp`), and direct `0x1008`/`0x1009` object transfers (JPEG, RAW `.arw`, and dual RAW+JPEG).
|
|
40
|
+
- **Native Async Push Events + Polling:** Listens to Windows `IPortableDevice::Advise` or USB Interrupt-IN PTP vendor events (`0xC201`, `0xC202`, `0xC203`, device disconnect) with automatic property-diff fallback and deduplication.
|
|
41
|
+
- **LiveView MJPEG Server, Automation, Backup/Restore, and Sony MakerNote EXIF Inspector.**
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Documentation
|
|
46
|
+
|
|
47
|
+
Full, precise documentation lives in [`docs/`](https://github.com/znajjar/LupineSDK/blob/main/docs/README.md):
|
|
48
|
+
|
|
49
|
+
| Guide | Topics |
|
|
50
|
+
| :--- | :--- |
|
|
51
|
+
| [Getting Started & Platform Setup](https://github.com/znajjar/LupineSDK/blob/main/docs/getting-started.md) | Camera menu setup, Windows/Linux/WSL2/macOS installation, `udev` & `usbipd-win`, troubleshooting |
|
|
52
|
+
| [Python API Reference](https://github.com/znajjar/LupineSDK/blob/main/docs/api-reference.md) | `LupineCamera`, capture models, LiveView/MJPEG, `EventBus`/`EventMonitor`, automation, backup/restore, EXIF inspector, exceptions |
|
|
53
|
+
| [CLI Reference](https://github.com/znajjar/LupineSDK/blob/main/docs/cli-reference.md) | Every `lupine` subcommand, flag, default, output format, and exit code |
|
|
54
|
+
| [Transports & Testing Guide](https://github.com/znajjar/LupineSDK/blob/main/docs/transports-and-testing.md) | `PTPTransport`, `WPDPTPTransport`, `USBPTPTransport`, `MockPTPTransport`, custom backends, pytest suites |
|
|
55
|
+
| [Sony SDIO / PTP Protocol Reference](https://github.com/znajjar/LupineSDK/blob/main/docs/protocol-reference.md) | Handshake, opcodes, codecs, all 60 ILCE-7M3 properties, WB calibration, enum aliases, firmware limits |
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Supported Platforms & Transports
|
|
60
|
+
|
|
61
|
+
| Platform | Default Transport | Underlying Driver / Library | Async Push Events |
|
|
62
|
+
| :--- | :--- | :--- | :--- |
|
|
63
|
+
| **Windows** | `WPDPTPTransport` | Native `PortableDeviceApi.dll` (`wpdmtp.inf`, no Zadig) | `IPortableDevice::Advise` |
|
|
64
|
+
| **Linux / WSL2** | `USBPTPTransport` | `pyusb` + `libusb-1.0` (ISO 15740 PTP) | USB Interrupt-IN (`0x83`) |
|
|
65
|
+
| **macOS** | `USBPTPTransport` | `pyusb` + `libusb-1.0` (ISO 15740 PTP) | USB Interrupt-IN |
|
|
66
|
+
| **Offline / CI** | `MockPTPTransport` | In-memory Sony A7 III protocol simulator | Simulated push + poll |
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Camera Setup
|
|
71
|
+
|
|
72
|
+
On your Sony A7 III:
|
|
73
|
+
1. **MENU → Network → Ctrl w/ Smartphone → Off**
|
|
74
|
+
2. **MENU → Setup → USB Connection → PC Remote**
|
|
75
|
+
3. *(To download captured photos over USB)* **MENU → Setup → PC Remote Settings → Still Img. Save Dest. → PC+Camera** or **PC Only**
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Installation
|
|
80
|
+
|
|
81
|
+
Install from PyPI as `lupine-sdk` (the Python module and CLI command are both `lupine`):
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install lupine-sdk
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Windows
|
|
88
|
+
```powershell
|
|
89
|
+
python -m venv .venv
|
|
90
|
+
.\.venv\Scripts\python.exe -m pip install lupine-sdk
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
After installation, `lupine` is available on the venv PATH (`.\.venv\Scripts\lupine.exe`).
|
|
94
|
+
|
|
95
|
+
### Linux / WSL2
|
|
96
|
+
Install `libusb-1.0` and add a `udev` rule so non-root users can open Sony USB cameras:
|
|
97
|
+
```bash
|
|
98
|
+
sudo apt install libusb-1.0-0
|
|
99
|
+
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="054c", MODE="0666"' | sudo tee /etc/udev/rules.d/99-lupine-sony.rules
|
|
100
|
+
sudo udevadm control --reload-rules && sudo udevadm trigger
|
|
101
|
+
|
|
102
|
+
python3 -m venv .venv
|
|
103
|
+
.venv/bin/pip install lupine-sdk
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
> **WSL2 (`usbipd-win`) tip:** Force-bind the camera in **Administrator PowerShell** so Windows' `wpdmtp` driver does not hold a PTP session before WSL attaches it:
|
|
107
|
+
> ```powershell
|
|
108
|
+
> usbipd bind --force --busid <BUSID>
|
|
109
|
+
> # Power-cycle the camera (Off -> On), then attach:
|
|
110
|
+
> usbipd attach --wsl --auto-attach --busid <BUSID>
|
|
111
|
+
> ```
|
|
112
|
+
> Run `usbipd unbind --busid <BUSID>` later to restore native Windows WPD access.
|
|
113
|
+
|
|
114
|
+
### macOS
|
|
115
|
+
```bash
|
|
116
|
+
brew install libusb
|
|
117
|
+
python3 -m venv .venv
|
|
118
|
+
.venv/bin/pip install lupine-sdk
|
|
119
|
+
```
|
|
120
|
+
*(If macOS's built-in `ptpcamerad` daemon holds the camera, close Photos/Image Capture or run `killall ptpcamerad` before connecting.)*
|
|
121
|
+
|
|
122
|
+
### From Source (Development)
|
|
123
|
+
```bash
|
|
124
|
+
git clone https://github.com/znajjar/LupineSDK.git
|
|
125
|
+
cd LupineSDK
|
|
126
|
+
pip install -e ".[dev]"
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Python SDK Examples
|
|
132
|
+
|
|
133
|
+
### 1. Connect, Read Status & Adjust Exposure/Color
|
|
134
|
+
```python
|
|
135
|
+
from lupine import LupineCamera
|
|
136
|
+
|
|
137
|
+
with LupineCamera() as cam:
|
|
138
|
+
print(cam.get_status())
|
|
139
|
+
|
|
140
|
+
# Direct writable settings (0x9205)
|
|
141
|
+
cam.set_white_balance("auto")
|
|
142
|
+
cam.set_wb_shift(ab="A0.5", gm="M1.5")
|
|
143
|
+
cam.set_dro("off")
|
|
144
|
+
cam.set_compression("raw+jpeg_fine")
|
|
145
|
+
|
|
146
|
+
# Stepped exposure controls (0x9207 relative dial stepping)
|
|
147
|
+
cam.set_iso(400)
|
|
148
|
+
cam.set_shutter_speed("1/250")
|
|
149
|
+
# cam.set_f_number(2.8) # available in M or A dial modes
|
|
150
|
+
|
|
151
|
+
# Capture & download (automatically saves both .arw and .jpg in RAW+JPEG mode)
|
|
152
|
+
result = cam.capture("shot.jpg")
|
|
153
|
+
for f in result.files:
|
|
154
|
+
print(f.format, len(f.data), f.path)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### 2. Async Push Events (WPD / USB Interrupt-IN) & Hybrid Event Monitor
|
|
158
|
+
```python
|
|
159
|
+
import time
|
|
160
|
+
from lupine import LupineCamera
|
|
161
|
+
|
|
162
|
+
with LupineCamera() as cam:
|
|
163
|
+
cam.on("property_changed", lambda ev: print("Changed:", ev.params, ev.data))
|
|
164
|
+
cam.on("object_added", lambda ev: print("New photo:", ev))
|
|
165
|
+
cam.on("disconnected", lambda ev: print("Camera unplugged!"))
|
|
166
|
+
|
|
167
|
+
with cam.monitor_events(mode="hybrid", poll_interval=0.25):
|
|
168
|
+
time.sleep(10)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 3. LiveView MJPEG Browser Stream
|
|
172
|
+
```python
|
|
173
|
+
from lupine import LupineCamera
|
|
174
|
+
|
|
175
|
+
with LupineCamera() as cam:
|
|
176
|
+
# Serves HTML preview at http://127.0.0.1:8080/ and raw MJPEG at /stream.mjpg
|
|
177
|
+
cam.liveview_stream(fps=15.0).serve_mjpeg(host="127.0.0.1", port=8080)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### 4. Automation Workflows
|
|
181
|
+
```python
|
|
182
|
+
from lupine import LupineCamera, timelapse, focus_stack, exposure_bracket, wb_shift_bracket
|
|
183
|
+
|
|
184
|
+
with LupineCamera() as cam:
|
|
185
|
+
timelapse(cam, count=5, interval_seconds=3.0, output_dir="tl_out")
|
|
186
|
+
focus_stack(cam, count=5, step_size=2, output_dir="fs_out")
|
|
187
|
+
exposure_bracket(cam, ev_offsets=(-1.0, 0.0, 1.0), output_dir="eb_out")
|
|
188
|
+
wb_shift_bracket(cam, output_dir="wb_out")
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### 5. Backup, Diff, Restore & EXIF Inspection
|
|
192
|
+
```python
|
|
193
|
+
from lupine import LupineCamera, inspect_image
|
|
194
|
+
|
|
195
|
+
report = inspect_image("shot.jpg")
|
|
196
|
+
print(report.model, report.software, report.creative_style, report.green_tint_ratio)
|
|
197
|
+
|
|
198
|
+
with LupineCamera() as cam:
|
|
199
|
+
cam.create_backup("backups/my_backup.json")
|
|
200
|
+
print(cam.diff_backup("backups/my_backup.json"))
|
|
201
|
+
cam.restore_backup("backups/my_backup.json", dry_run=True)
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### 6. Offline Testing with `MockPTPTransport`
|
|
205
|
+
```python
|
|
206
|
+
from lupine import LupineCamera
|
|
207
|
+
|
|
208
|
+
with LupineCamera.from_mock("tests/fixtures/a7iii_sample_backup.json") as cam:
|
|
209
|
+
print(cam.get_status())
|
|
210
|
+
res = cam.capture("mock_shot.jpg")
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## CLI Reference
|
|
216
|
+
|
|
217
|
+
See [docs/cli-reference.md](https://github.com/znajjar/LupineSDK/blob/main/docs/cli-reference.md) for full flag descriptions, defaults, and exit codes.
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
lupine detect
|
|
221
|
+
lupine status [--json]
|
|
222
|
+
lupine props [--writable] [--json]
|
|
223
|
+
lupine set --wb auto --ab A0.5 --gm M1.5 --dro off --quality raw+jpeg_fine
|
|
224
|
+
lupine step --iso 1 --shutter -2
|
|
225
|
+
lupine capture shot.jpg [--no-af] [--bulb 5.0] [--timeout 12.0]
|
|
226
|
+
lupine liveview preview.jpg
|
|
227
|
+
lupine stream --host 127.0.0.1 --port 8080 --fps 15
|
|
228
|
+
lupine watch --mode hybrid --interval 0.25 [--duration 30]
|
|
229
|
+
lupine focus 3
|
|
230
|
+
lupine movie
|
|
231
|
+
lupine afmf
|
|
232
|
+
lupine aelock on
|
|
233
|
+
lupine magnifier on
|
|
234
|
+
lupine key right
|
|
235
|
+
lupine timelapse --count 10 --interval 5 --out tl_out [--af]
|
|
236
|
+
lupine focus-stack --count 5 --step-size 2 --out fs_out
|
|
237
|
+
lupine exposure-bracket --evs -1 0 1 --out eb_out
|
|
238
|
+
lupine wb-bracket --out wb_out
|
|
239
|
+
lupine backup backups/baseline.json
|
|
240
|
+
lupine diff backups/baseline.json
|
|
241
|
+
lupine restore backups/baseline.json [--dry-run] [--include-stepped]
|
|
242
|
+
lupine exif shot.jpg [--json]
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## Running Tests
|
|
248
|
+
|
|
249
|
+
### Offline Unit Tests (no camera required)
|
|
250
|
+
```bash
|
|
251
|
+
pytest -v -m "not hardware"
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Live Hardware Integration Tests (Sony A7 III attached via USB)
|
|
255
|
+
The live suite snapshots your camera settings beforehand and restores them automatically on completion.
|
|
256
|
+
|
|
257
|
+
**Linux / macOS / WSL2:**
|
|
258
|
+
```bash
|
|
259
|
+
LUPINE_LIVE_TEST=1 pytest tests/test_hardware_live.py -v -s
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Windows PowerShell:**
|
|
263
|
+
```powershell
|
|
264
|
+
$env:LUPINE_LIVE_TEST="1"; .\.venv\Scripts\python.exe -m pytest tests/test_hardware_live.py -v -s
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## License
|
|
270
|
+
|
|
271
|
+
Licensed under the [MIT License](https://github.com/znajjar/LupineSDK/blob/main/LICENSE).
|
|
272
|
+
|
|
273
|
+
*Sony and Alpha are trademarks of Sony Group Corporation. Lupine SDK is an independent project and is not affiliated with or endorsed by Sony.*
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# Lupine SDK
|
|
2
|
+
|
|
3
|
+
**Lupine** is a cross-platform Python SDK and CLI for programmatic USB control of **Sony Alpha cameras** (built and verified live on **Sony Alpha 7 III / `ILCE-7M3 v4.01`** on Windows, Linux/WSL2, and macOS).
|
|
4
|
+
|
|
5
|
+
- **Cross-platform native USB:** Automatically uses Windows' built-in **WPD/MTP** stack (`PortableDeviceApi.dll` / `wpdmtp.inf`, zero driver swap) on Windows, and direct **`libusb-1.0` (`pyusb`)** ISO 15740 USB Still Image Class (PTP) on Linux (including WSL2 via `usbipd-win`) and macOS.
|
|
6
|
+
- **Full Sony SDIO protocol:** Implements Sony's 3-phase `0x9201` handshake, `0x9202` capability info, `0x9209` bulk property decoding (all 60 properties), `0x9205` direct property writes, `0x9207` control & relative dial stepping (`ISO`, `Shutter`, `Aperture`, `EV`, `Flash Comp`), and direct `0x1008`/`0x1009` object transfers (JPEG, RAW `.arw`, and dual RAW+JPEG).
|
|
7
|
+
- **Native Async Push Events + Polling:** Listens to Windows `IPortableDevice::Advise` or USB Interrupt-IN PTP vendor events (`0xC201`, `0xC202`, `0xC203`, device disconnect) with automatic property-diff fallback and deduplication.
|
|
8
|
+
- **LiveView MJPEG Server, Automation, Backup/Restore, and Sony MakerNote EXIF Inspector.**
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Documentation
|
|
13
|
+
|
|
14
|
+
Full, precise documentation lives in [`docs/`](https://github.com/znajjar/LupineSDK/blob/main/docs/README.md):
|
|
15
|
+
|
|
16
|
+
| Guide | Topics |
|
|
17
|
+
| :--- | :--- |
|
|
18
|
+
| [Getting Started & Platform Setup](https://github.com/znajjar/LupineSDK/blob/main/docs/getting-started.md) | Camera menu setup, Windows/Linux/WSL2/macOS installation, `udev` & `usbipd-win`, troubleshooting |
|
|
19
|
+
| [Python API Reference](https://github.com/znajjar/LupineSDK/blob/main/docs/api-reference.md) | `LupineCamera`, capture models, LiveView/MJPEG, `EventBus`/`EventMonitor`, automation, backup/restore, EXIF inspector, exceptions |
|
|
20
|
+
| [CLI Reference](https://github.com/znajjar/LupineSDK/blob/main/docs/cli-reference.md) | Every `lupine` subcommand, flag, default, output format, and exit code |
|
|
21
|
+
| [Transports & Testing Guide](https://github.com/znajjar/LupineSDK/blob/main/docs/transports-and-testing.md) | `PTPTransport`, `WPDPTPTransport`, `USBPTPTransport`, `MockPTPTransport`, custom backends, pytest suites |
|
|
22
|
+
| [Sony SDIO / PTP Protocol Reference](https://github.com/znajjar/LupineSDK/blob/main/docs/protocol-reference.md) | Handshake, opcodes, codecs, all 60 ILCE-7M3 properties, WB calibration, enum aliases, firmware limits |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Supported Platforms & Transports
|
|
27
|
+
|
|
28
|
+
| Platform | Default Transport | Underlying Driver / Library | Async Push Events |
|
|
29
|
+
| :--- | :--- | :--- | :--- |
|
|
30
|
+
| **Windows** | `WPDPTPTransport` | Native `PortableDeviceApi.dll` (`wpdmtp.inf`, no Zadig) | `IPortableDevice::Advise` |
|
|
31
|
+
| **Linux / WSL2** | `USBPTPTransport` | `pyusb` + `libusb-1.0` (ISO 15740 PTP) | USB Interrupt-IN (`0x83`) |
|
|
32
|
+
| **macOS** | `USBPTPTransport` | `pyusb` + `libusb-1.0` (ISO 15740 PTP) | USB Interrupt-IN |
|
|
33
|
+
| **Offline / CI** | `MockPTPTransport` | In-memory Sony A7 III protocol simulator | Simulated push + poll |
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Camera Setup
|
|
38
|
+
|
|
39
|
+
On your Sony A7 III:
|
|
40
|
+
1. **MENU → Network → Ctrl w/ Smartphone → Off**
|
|
41
|
+
2. **MENU → Setup → USB Connection → PC Remote**
|
|
42
|
+
3. *(To download captured photos over USB)* **MENU → Setup → PC Remote Settings → Still Img. Save Dest. → PC+Camera** or **PC Only**
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
Install from PyPI as `lupine-sdk` (the Python module and CLI command are both `lupine`):
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install lupine-sdk
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Windows
|
|
55
|
+
```powershell
|
|
56
|
+
python -m venv .venv
|
|
57
|
+
.\.venv\Scripts\python.exe -m pip install lupine-sdk
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
After installation, `lupine` is available on the venv PATH (`.\.venv\Scripts\lupine.exe`).
|
|
61
|
+
|
|
62
|
+
### Linux / WSL2
|
|
63
|
+
Install `libusb-1.0` and add a `udev` rule so non-root users can open Sony USB cameras:
|
|
64
|
+
```bash
|
|
65
|
+
sudo apt install libusb-1.0-0
|
|
66
|
+
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="054c", MODE="0666"' | sudo tee /etc/udev/rules.d/99-lupine-sony.rules
|
|
67
|
+
sudo udevadm control --reload-rules && sudo udevadm trigger
|
|
68
|
+
|
|
69
|
+
python3 -m venv .venv
|
|
70
|
+
.venv/bin/pip install lupine-sdk
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
> **WSL2 (`usbipd-win`) tip:** Force-bind the camera in **Administrator PowerShell** so Windows' `wpdmtp` driver does not hold a PTP session before WSL attaches it:
|
|
74
|
+
> ```powershell
|
|
75
|
+
> usbipd bind --force --busid <BUSID>
|
|
76
|
+
> # Power-cycle the camera (Off -> On), then attach:
|
|
77
|
+
> usbipd attach --wsl --auto-attach --busid <BUSID>
|
|
78
|
+
> ```
|
|
79
|
+
> Run `usbipd unbind --busid <BUSID>` later to restore native Windows WPD access.
|
|
80
|
+
|
|
81
|
+
### macOS
|
|
82
|
+
```bash
|
|
83
|
+
brew install libusb
|
|
84
|
+
python3 -m venv .venv
|
|
85
|
+
.venv/bin/pip install lupine-sdk
|
|
86
|
+
```
|
|
87
|
+
*(If macOS's built-in `ptpcamerad` daemon holds the camera, close Photos/Image Capture or run `killall ptpcamerad` before connecting.)*
|
|
88
|
+
|
|
89
|
+
### From Source (Development)
|
|
90
|
+
```bash
|
|
91
|
+
git clone https://github.com/znajjar/LupineSDK.git
|
|
92
|
+
cd LupineSDK
|
|
93
|
+
pip install -e ".[dev]"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Python SDK Examples
|
|
99
|
+
|
|
100
|
+
### 1. Connect, Read Status & Adjust Exposure/Color
|
|
101
|
+
```python
|
|
102
|
+
from lupine import LupineCamera
|
|
103
|
+
|
|
104
|
+
with LupineCamera() as cam:
|
|
105
|
+
print(cam.get_status())
|
|
106
|
+
|
|
107
|
+
# Direct writable settings (0x9205)
|
|
108
|
+
cam.set_white_balance("auto")
|
|
109
|
+
cam.set_wb_shift(ab="A0.5", gm="M1.5")
|
|
110
|
+
cam.set_dro("off")
|
|
111
|
+
cam.set_compression("raw+jpeg_fine")
|
|
112
|
+
|
|
113
|
+
# Stepped exposure controls (0x9207 relative dial stepping)
|
|
114
|
+
cam.set_iso(400)
|
|
115
|
+
cam.set_shutter_speed("1/250")
|
|
116
|
+
# cam.set_f_number(2.8) # available in M or A dial modes
|
|
117
|
+
|
|
118
|
+
# Capture & download (automatically saves both .arw and .jpg in RAW+JPEG mode)
|
|
119
|
+
result = cam.capture("shot.jpg")
|
|
120
|
+
for f in result.files:
|
|
121
|
+
print(f.format, len(f.data), f.path)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 2. Async Push Events (WPD / USB Interrupt-IN) & Hybrid Event Monitor
|
|
125
|
+
```python
|
|
126
|
+
import time
|
|
127
|
+
from lupine import LupineCamera
|
|
128
|
+
|
|
129
|
+
with LupineCamera() as cam:
|
|
130
|
+
cam.on("property_changed", lambda ev: print("Changed:", ev.params, ev.data))
|
|
131
|
+
cam.on("object_added", lambda ev: print("New photo:", ev))
|
|
132
|
+
cam.on("disconnected", lambda ev: print("Camera unplugged!"))
|
|
133
|
+
|
|
134
|
+
with cam.monitor_events(mode="hybrid", poll_interval=0.25):
|
|
135
|
+
time.sleep(10)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 3. LiveView MJPEG Browser Stream
|
|
139
|
+
```python
|
|
140
|
+
from lupine import LupineCamera
|
|
141
|
+
|
|
142
|
+
with LupineCamera() as cam:
|
|
143
|
+
# Serves HTML preview at http://127.0.0.1:8080/ and raw MJPEG at /stream.mjpg
|
|
144
|
+
cam.liveview_stream(fps=15.0).serve_mjpeg(host="127.0.0.1", port=8080)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### 4. Automation Workflows
|
|
148
|
+
```python
|
|
149
|
+
from lupine import LupineCamera, timelapse, focus_stack, exposure_bracket, wb_shift_bracket
|
|
150
|
+
|
|
151
|
+
with LupineCamera() as cam:
|
|
152
|
+
timelapse(cam, count=5, interval_seconds=3.0, output_dir="tl_out")
|
|
153
|
+
focus_stack(cam, count=5, step_size=2, output_dir="fs_out")
|
|
154
|
+
exposure_bracket(cam, ev_offsets=(-1.0, 0.0, 1.0), output_dir="eb_out")
|
|
155
|
+
wb_shift_bracket(cam, output_dir="wb_out")
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### 5. Backup, Diff, Restore & EXIF Inspection
|
|
159
|
+
```python
|
|
160
|
+
from lupine import LupineCamera, inspect_image
|
|
161
|
+
|
|
162
|
+
report = inspect_image("shot.jpg")
|
|
163
|
+
print(report.model, report.software, report.creative_style, report.green_tint_ratio)
|
|
164
|
+
|
|
165
|
+
with LupineCamera() as cam:
|
|
166
|
+
cam.create_backup("backups/my_backup.json")
|
|
167
|
+
print(cam.diff_backup("backups/my_backup.json"))
|
|
168
|
+
cam.restore_backup("backups/my_backup.json", dry_run=True)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 6. Offline Testing with `MockPTPTransport`
|
|
172
|
+
```python
|
|
173
|
+
from lupine import LupineCamera
|
|
174
|
+
|
|
175
|
+
with LupineCamera.from_mock("tests/fixtures/a7iii_sample_backup.json") as cam:
|
|
176
|
+
print(cam.get_status())
|
|
177
|
+
res = cam.capture("mock_shot.jpg")
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## CLI Reference
|
|
183
|
+
|
|
184
|
+
See [docs/cli-reference.md](https://github.com/znajjar/LupineSDK/blob/main/docs/cli-reference.md) for full flag descriptions, defaults, and exit codes.
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
lupine detect
|
|
188
|
+
lupine status [--json]
|
|
189
|
+
lupine props [--writable] [--json]
|
|
190
|
+
lupine set --wb auto --ab A0.5 --gm M1.5 --dro off --quality raw+jpeg_fine
|
|
191
|
+
lupine step --iso 1 --shutter -2
|
|
192
|
+
lupine capture shot.jpg [--no-af] [--bulb 5.0] [--timeout 12.0]
|
|
193
|
+
lupine liveview preview.jpg
|
|
194
|
+
lupine stream --host 127.0.0.1 --port 8080 --fps 15
|
|
195
|
+
lupine watch --mode hybrid --interval 0.25 [--duration 30]
|
|
196
|
+
lupine focus 3
|
|
197
|
+
lupine movie
|
|
198
|
+
lupine afmf
|
|
199
|
+
lupine aelock on
|
|
200
|
+
lupine magnifier on
|
|
201
|
+
lupine key right
|
|
202
|
+
lupine timelapse --count 10 --interval 5 --out tl_out [--af]
|
|
203
|
+
lupine focus-stack --count 5 --step-size 2 --out fs_out
|
|
204
|
+
lupine exposure-bracket --evs -1 0 1 --out eb_out
|
|
205
|
+
lupine wb-bracket --out wb_out
|
|
206
|
+
lupine backup backups/baseline.json
|
|
207
|
+
lupine diff backups/baseline.json
|
|
208
|
+
lupine restore backups/baseline.json [--dry-run] [--include-stepped]
|
|
209
|
+
lupine exif shot.jpg [--json]
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Running Tests
|
|
215
|
+
|
|
216
|
+
### Offline Unit Tests (no camera required)
|
|
217
|
+
```bash
|
|
218
|
+
pytest -v -m "not hardware"
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Live Hardware Integration Tests (Sony A7 III attached via USB)
|
|
222
|
+
The live suite snapshots your camera settings beforehand and restores them automatically on completion.
|
|
223
|
+
|
|
224
|
+
**Linux / macOS / WSL2:**
|
|
225
|
+
```bash
|
|
226
|
+
LUPINE_LIVE_TEST=1 pytest tests/test_hardware_live.py -v -s
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
**Windows PowerShell:**
|
|
230
|
+
```powershell
|
|
231
|
+
$env:LUPINE_LIVE_TEST="1"; .\.venv\Scripts\python.exe -m pytest tests/test_hardware_live.py -v -s
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## License
|
|
237
|
+
|
|
238
|
+
Licensed under the [MIT License](https://github.com/znajjar/LupineSDK/blob/main/LICENSE).
|
|
239
|
+
|
|
240
|
+
*Sony and Alpha are trademarks of Sony Group Corporation. Lupine SDK is an independent project and is not affiliated with or endorsed by Sony.*
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""Lupine — Programmatic USB Control SDK for Sony Alpha cameras (Windows & Linux)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__version__ = "0.1.0"
|
|
6
|
+
|
|
7
|
+
from .automation import exposure_bracket, focus_stack, timelapse, wb_shift_bracket
|
|
8
|
+
from .backup import create_backup, diff_backup, restore_backup
|
|
9
|
+
from .camera import CapturedFile, CaptureResult, LupineCamera, SonyAlpha3
|
|
10
|
+
from .events import EventBus, EventMonitor
|
|
11
|
+
from .exceptions import (
|
|
12
|
+
CaptureTimeoutError,
|
|
13
|
+
DeviceNotFoundError,
|
|
14
|
+
DisconnectedError,
|
|
15
|
+
LupineError,
|
|
16
|
+
PTPError,
|
|
17
|
+
PropertyError,
|
|
18
|
+
PropertyNotWritableError,
|
|
19
|
+
PropertySteppingError,
|
|
20
|
+
PropertyValidationError,
|
|
21
|
+
TransportError,
|
|
22
|
+
)
|
|
23
|
+
from .exif import ExifReport, inspect_image
|
|
24
|
+
from .liveview import LiveViewFrame, LiveViewStream
|
|
25
|
+
from .protocol.properties import CameraProperty
|
|
26
|
+
from .transport import (
|
|
27
|
+
CameraEvent,
|
|
28
|
+
DeviceInfo,
|
|
29
|
+
MockPTPTransport,
|
|
30
|
+
PTPDeviceInfo,
|
|
31
|
+
PTPTransport,
|
|
32
|
+
USBPTPTransport,
|
|
33
|
+
WPDDeviceInfo,
|
|
34
|
+
WPDPTPTransport,
|
|
35
|
+
decode_ptp_event_container,
|
|
36
|
+
decode_wpd_event_guid,
|
|
37
|
+
default_transport,
|
|
38
|
+
find_sony_camera,
|
|
39
|
+
find_sony_cameras,
|
|
40
|
+
find_sony_usb_camera,
|
|
41
|
+
find_sony_usb_cameras,
|
|
42
|
+
list_devices,
|
|
43
|
+
list_usb_devices,
|
|
44
|
+
list_wpd_devices,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
__all__ = [
|
|
48
|
+
"CameraEvent",
|
|
49
|
+
"CameraProperty",
|
|
50
|
+
"CaptureResult",
|
|
51
|
+
"CaptureTimeoutError",
|
|
52
|
+
"CapturedFile",
|
|
53
|
+
"DeviceInfo",
|
|
54
|
+
"DeviceNotFoundError",
|
|
55
|
+
"DisconnectedError",
|
|
56
|
+
"EventBus",
|
|
57
|
+
"EventMonitor",
|
|
58
|
+
"ExifReport",
|
|
59
|
+
"LiveViewFrame",
|
|
60
|
+
"LiveViewStream",
|
|
61
|
+
"LupineCamera",
|
|
62
|
+
"LupineError",
|
|
63
|
+
"MockPTPTransport",
|
|
64
|
+
"PTPDeviceInfo",
|
|
65
|
+
"PTPError",
|
|
66
|
+
"PTPTransport",
|
|
67
|
+
"PropertyError",
|
|
68
|
+
"PropertyNotWritableError",
|
|
69
|
+
"PropertySteppingError",
|
|
70
|
+
"PropertyValidationError",
|
|
71
|
+
"SonyAlpha3",
|
|
72
|
+
"TransportError",
|
|
73
|
+
"USBPTPTransport",
|
|
74
|
+
"WPDDeviceInfo",
|
|
75
|
+
"WPDPTPTransport",
|
|
76
|
+
"__version__",
|
|
77
|
+
"create_backup",
|
|
78
|
+
"decode_ptp_event_container",
|
|
79
|
+
"decode_wpd_event_guid",
|
|
80
|
+
"default_transport",
|
|
81
|
+
"diff_backup",
|
|
82
|
+
"exposure_bracket",
|
|
83
|
+
"find_sony_camera",
|
|
84
|
+
"find_sony_cameras",
|
|
85
|
+
"find_sony_usb_camera",
|
|
86
|
+
"find_sony_usb_cameras",
|
|
87
|
+
"focus_stack",
|
|
88
|
+
"inspect_image",
|
|
89
|
+
"list_devices",
|
|
90
|
+
"list_usb_devices",
|
|
91
|
+
"list_wpd_devices",
|
|
92
|
+
"restore_backup",
|
|
93
|
+
"timelapse",
|
|
94
|
+
"wb_shift_bracket",
|
|
95
|
+
]
|