> ## Documentation Index
> Fetch the complete documentation index at: https://darkgrade.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Cameras

> The Camera class provides a high-level interface for interacting with PTP-compatible cameras. It automatically selects the appropriate vendor-specific implementation (Sony, Nikon, Canon, or Generic) based on the connected device.

## Import

```typescript theme={null}
import { Camera } from '@packages/link/src/camera'
```

## Constructor

```typescript theme={null}
constructor(options?: CameraOptions)
```

### Parameters

| Parameter          | Type                          | Required | Description                                                                                                                   |
| ------------------ | ----------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
| **options**        | `CameraOptions`               |          | Optional configuration for the camera instance.                                                                               |
| **options.logger** | `Partial&lt;LoggerConfig&gt;` |          | Logger configuration for debugging and logging.                                                                               |
| **options.device** | `DeviceDescriptor`            |          | Device descriptor for the camera. If provided, the appropriate vendor-specific implementation will be selected automatically. |

## Methods

### connect

Connect to a camera device.

```typescript theme={null}
async connect(device?: DeviceDescriptor): Promise&lt;void&gt;
```

| Parameter  | Type               | Required | Description                                                                                |
| ---------- | ------------------ | -------- | ------------------------------------------------------------------------------------------ |
| **device** | `DeviceDescriptor` |          | Optional device descriptor. If not provided, uses the device from the constructor options. |

### disconnect

Disconnect from the camera device.

```typescript theme={null}
async disconnect(): Promise&lt;void&gt;
```

### send

Send a PTP operation to the camera.

```typescript theme={null}
async send(
  operation: OperationDefinition,
  params: any,
  data?: Uint8Array,
  maxDataLength?: number
): Promise&lt;any&gt;
```

| Parameter         | Type                  | Required | Description                       |
| ----------------- | --------------------- | -------- | --------------------------------- |
| **operation**     | `OperationDefinition` | ✓        | The operation definition to send. |
| **params**        | `any`                 | ✓        | Parameters for the operation.     |
| **data**          | `Uint8Array`          |          | Optional data payload.            |
| **maxDataLength** | `number`              |          | Optional maximum data length.     |

### get

Get a camera property value.

```typescript theme={null}
async get(property: PropertyDefinition): Promise&lt;any&gt;
```

| Parameter    | Type                 | Required | Description                     |
| ------------ | -------------------- | -------- | ------------------------------- |
| **property** | `PropertyDefinition` | ✓        | The property definition to get. |

### set

Set a camera property value.

```typescript theme={null}
async set(
  property: PropertyDefinition,
  value: any
): Promise&lt;void&gt;
```

| Parameter    | Type                 | Required | Description                     |
| ------------ | -------------------- | -------- | ------------------------------- |
| **property** | `PropertyDefinition` | ✓        | The property definition to set. |
| **value**    | `any`                | ✓        | The value to set.               |

### on

Register an event handler.

```typescript theme={null}
on(
  event: EventDefinition,
  handler: function
): void
```

| Parameter   | Type              | Required | Description                                         |
| ----------- | ----------------- | -------- | --------------------------------------------------- |
| **event**   | `EventDefinition` | ✓        | The event definition to listen for.                 |
| **handler** | `function`        | ✓        | The handler function to call when the event occurs. |

### off

Unregister an event handler.

```typescript theme={null}
off(
  event: EventDefinition,
  handler?: function
): void
```

| Parameter   | Type              | Required | Description                                                                         |
| ----------- | ----------------- | -------- | ----------------------------------------------------------------------------------- |
| **event**   | `EventDefinition` | ✓        | The event definition to stop listening for.                                         |
| **handler** | `function`        |          | Optional handler function. If not provided, all handlers for the event are removed. |

### getAperture

Get the current aperture value.

```typescript theme={null}
async getAperture(): Promise&lt;string&gt;
```

### setAperture

Set the aperture value.

```typescript theme={null}
async setAperture(value: string): Promise&lt;void&gt;
```

| Parameter | Type     | Required | Description                |
| --------- | -------- | -------- | -------------------------- |
| **value** | `string` | ✓        | The aperture value to set. |

### getShutterSpeed

Get the current shutter speed value.

```typescript theme={null}
async getShutterSpeed(): Promise&lt;string&gt;
```

### setShutterSpeed

Set the shutter speed value.

```typescript theme={null}
async setShutterSpeed(value: string): Promise&lt;void&gt;
```

| Parameter | Type     | Required | Description                     |
| --------- | -------- | -------- | ------------------------------- |
| **value** | `string` | ✓        | The shutter speed value to set. |

### getIso

Get the current ISO value.

```typescript theme={null}
async getIso(): Promise&lt;string&gt;
```

### setIso

Set the ISO value.

```typescript theme={null}
async setIso(value: string): Promise&lt;void&gt;
```

| Parameter | Type     | Required | Description           |
| --------- | -------- | -------- | --------------------- |
| **value** | `string` | ✓        | The ISO value to set. |

### captureImage

Capture an image from the camera.

```typescript theme={null}
async captureImage(params?: object)
```

| Parameter              | Type      | Required | Description                                                         |
| ---------------------- | --------- | -------- | ------------------------------------------------------------------- |
| **params**             | `object`  |          | Capture parameters.                                                 |
| **params.includeInfo** | `boolean` |          | Whether to include object info in the response. Defaults to `true`. |
| **params.includeData** | `boolean` |          | Whether to include image data in the response. Defaults to `true`.  |

### captureLiveView

Capture a live view frame from the camera.

```typescript theme={null}
async captureLiveView(params?: object)
```

| Parameter              | Type      | Required | Description                                                         |
| ---------------------- | --------- | -------- | ------------------------------------------------------------------- |
| **params**             | `object`  |          | Live view capture parameters.                                       |
| **params.includeInfo** | `boolean` |          | Whether to include object info in the response. Defaults to `true`. |
| **params.includeData** | `boolean` |          | Whether to include image data in the response. Defaults to `true`.  |

### startRecording

Start video recording.

```typescript theme={null}
async startRecording(): Promise&lt;void&gt;
```

### stopRecording

Stop video recording.

```typescript theme={null}
async stopRecording(): Promise&lt;void&gt;
```

### listObjects

List all objects stored on the camera.

```typescript theme={null}
async listObjects(): Promise&lt;object&gt;
```

### getObject

Retrieve an object from the camera.

```typescript theme={null}
async getObject(
  objectHandle: number,
  objectSize: number
): Promise&lt;Uint8Array&gt;
```

| Parameter        | Type     | Required | Description                           |
| ---------------- | -------- | -------- | ------------------------------------- |
| **objectHandle** | `number` | ✓        | The handle of the object to retrieve. |
| **objectSize**   | `number` | ✓        | The size of the object in bytes.      |

## Exports

The module also exports the vendor-specific camera implementations:

* `CanonCamera`
* `GenericCamera`
* `NikonCamera`
* `SonyCamera`

These can be imported directly if you need vendor-specific functionality:

```typescript theme={null}
import { SonyCamera } from '@packages/link/src/camera'
import { GenericCamera } from '@packages/link/src/camera'
```
