# webcam-capture

This is the standard Aussom-Lang webcam capture module. It provides webcam
discovery and frame capture support based on
[webcam-capture by Sarxos v0.3.12](https://github.com/sarxos/webcam-capture),
which is distributed under the MIT license.

The module exposes a static `WebcamCapture` class for device discovery and a
`Webcam` class for capturing single frames, streaming frames asynchronously,
and saving images to disk.


## Usage

Here's a short example, please see the API doc for details.

```
// Get the default webcam
cam = WebcamCapture.getDefault();

// Pick a resolution the device supports
sizes = cam.getViewSizes();
cam.setViewSize(sizes[0][0], sizes[0][1]);

// Open in async mode so streaming methods work
cam.open(true);

// Save a single frame to disk
cam.saveImage('frame.png');

// Stream frames to a callback
cam.startStream(::onFrame, 10.0);
sys.sleep(2000);
cam.stopStream();

// Close the device
cam.close();

public onFrame(Frame) {
    c.log('Got a frame of size ' + Frame.size());
}
```


## License

Copyright 2026 Austin Lehman

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
