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.
Basic Usage
import { Camera } from '@darkgrade/link'
const camera = new Camera()
await camera.connect()
// Control camera settings
await camera.setIso('800')
await camera.setShutterSpeed('1/250')
await camera.setAperture('f/2.8')
// Capture an image
const { data } = await camera.captureImage()
await camera.disconnect()
That’s it! The Camera class automatically detects your camera’s brand and uses the appropriate vendor-specific implementation. No configuration needed.
How It Works
When you call connect(), Darkgrade Link:
- Scans for connected USB devices
- Identifies the camera’s vendor ID
- Selects the appropriate vendor-specific implementation:
- Sony ⍺ Series →
SonyCamera with live view, video recording, SDIO
- Nikon Z Series →
NikonCamera with extended properties
- Canon EOS R Series →
CanonCamera with remote control
- Other PTP Cameras →
GenericCamera with standard PTP operations
- Enables vendor-specific features automatically
Common Examples
Camera Settings
// Get current settings
const currentIso = await camera.getIso()
const currentShutter = await camera.getShutterSpeed()
const currentAperture = await camera.getAperture()
// Set new values
await camera.setIso('1600')
await camera.setShutterSpeed('1/500')
await camera.setAperture('f/4.0')
Event Handling
// Listen for camera events
camera.on(camera.getInstance().registry.events.ObjectAdded, event => {
console.log('New object added:', event.ObjectHandle)
})
camera.on(camera.getInstance().registry.events.PropertyChanged, event => {
console.log('Property changed:', event.PropertyName)
})
// Remove event listeners
camera.off(camera.getInstance().registry.events.ObjectAdded)
Live View
Capture live view frames (Sony & Nikon only):
const { data: liveViewFrame } = await camera.captureLiveView()
fs.writeFileSync('liveview.jpg', liveViewFrame)
Video Recording
Start and stop video recording (Sony & Canon only):
await camera.startRecording()
// ... record for some duration ...
await camera.stopRecording()
File Management
List and download files from the camera:
const objects = await camera.listObjects()
for (const [storageId, storage] of Object.entries(objects)) {
console.log(`Storage ${storageId}: ${storage.info.storageDescription}`)
for (const [handle, info] of Object.entries(storage.objects)) {
console.log(` - ${info.filename} (${info.objectCompressedSize} bytes)`)
// Download a specific object
const fileData = await camera.getObject(Number(handle), info.objectCompressedSize)
fs.writeFileSync(info.filename, fileData)
}
}
Advanced Property Access
Access vendor-specific properties directly:
const registry = camera.getInstance().registry
// Get property with type safety
const propValue = await camera.get(registry.properties.ExposureIndex)
// Set property
await camera.set(registry.properties.ExposureIndex, '3200')
Advanced Usage
Using Vendor-Specific Classes
Import vendor-specific camera classes directly:
import { SonyCamera, NikonCamera, CanonCamera, GenericCamera } from '@darkgrade/link'
const camera = new SonyCamera()
await camera.connect()
Manual Configuration
Specify device filters and logging options:
import { Camera, VendorIDs } from '@darkgrade/link'
const camera = new Camera({
device: {
usb: {
filters: [{ vendorId: VendorIDs.SONY }], // VendorIDs.NIKON, VendorIDs.CANON
},
},
logger: {
expanded: true, // Show detailed logging
},
})
await camera.connect()
Next Steps