Skip to content

Latest commit

 

History

History
129 lines (91 loc) · 2.99 KB

File metadata and controls

129 lines (91 loc) · 2.99 KB

Alpha SDK Python Example

Minimal Python example repo for Jupyter notebooks and simple data-collection workflows.

This repo is not the Python SDK package itself. Install the published client from PyPI:

pip install alpha-sdk-client

Use this repo as copy-paste/reference code for:

  • discovering and connecting to a camera
  • collecting repeated property snapshots into row dictionaries
  • triggering AF + shutter capture
  • enabling live view and fetching a JPEG frame
  • previewing SD card files in remote-transfer mode

Requirements

  • Python 3.8+
  • the Alpha Camera server (CameraWebApp), built from source
  • a camera supported by the SDK

The camera server is built from source — it needs Sony's Camera Remote SDK and is never shipped as a package. Build it once with the crsdk CLI:

git clone https://github.com/crsdk/alpha-sdk-api.git
cd alpha-sdk-api
./crsdk install --zip <sony-camera-remote-sdk.zip>
./crsdk build

Then either let this script spawn it (point CRSDK_BINARY at the built binary):

export CRSDK_BINARY=/path/to/alpha-sdk-api/api/server/build/CameraWebApp

…or run it yourself (./crsdk start) and the script will adopt the running server. The spawn/adopt logic lives in camera_server.managed_server.

Install

pip install -r requirements.txt

If you do not want Jupyter installed, the only required runtime dependency is:

pip install alpha-sdk-client

Files

  • notebook_data_collection.py — notebook-friendly helper functions plus a small CLI smoke test
  • camera_server.py — spawn/adopt lifecycle for the native CameraWebApp (stdlib only)

Quick smoke test

From the repo root:

python notebook_data_collection.py

That will:

  • discover cameras
  • connect to the first one
  • collect a few property snapshots
  • print the results

To trigger one real capture:

python notebook_data_collection.py --capture

Use in Jupyter

Start Jupyter from this repo root:

jupyter notebook

Then in a notebook cell:

from alpha_sdk_client import AlphaSDKClient
from notebook_data_collection import (
    collect_property_rows,
    connect_first_camera,
    enable_live_view,
    fetch_live_view_frame,
    save_live_view_frame,
)

client = AlphaSDKClient(base_url="http://localhost:8080")
camera = connect_first_camera(client, mode="remote")
rows = collect_property_rows(client, camera.id, count=5, interval_s=1.0)

If you want a DataFrame:

import pandas as pd

df = pd.DataFrame(rows)
df.head()

Live view example

enable_live_view(client, camera.id)
frame = fetch_live_view_frame(client, camera.id)
save_live_view_frame(frame, "frame.jpg")

Notes

  • mode="remote" is the simplest default for control and capture.
  • Use mode="remote-transfer" if you also want SD card listing/downloads.
  • The helper waits for connection status after connect() rather than assuming the server flips to connected immediately.