# file: webcam_capture.aus

## class: webcam_capture_module

[23:14] `static` **extends: object** 

Module JAR loader class.

#### Methods

- **webcam\_capture\_module** ()




## class: Webcam

[61:14] (extern: com.lehman.aussom.Webcam) **extends: object** 

Represents one physical webcam device.

#### Methods

- **Webcam** ()

	> Default constructor.



- **getName** ()

	> Gets the webcam device name. This function takes no options.

	- **@r** `A` string with the device name.


- **open** (`bool Async = true`)

	> Opens the webcam for capture. Async mode is required to use the streaming methods latestFrame(), nextFrame(), and startStream(). When Async is true a background thread grabs frames continuously at the rate set by setFps(); getImageBytes() and saveImage() return the most recent cached frame. When Async is false the webcam runs in pull-only mode and getImageBytes() blocks while it grabs each frame on demand. Set the capture size with setViewSize() or setResolution() before calling open().

	- **@p** `Async` is an optional bool. The default is true.
	- **@r** `This` object.


- **close** ()

	> Closes the webcam and releases the device. This function takes no options. Calling close() on a closed webcam is allowed. Stops any running stream before releasing the device.

	- **@r** `This` object.


- **isOpen** ()

	> Checks whether the webcam is open. This function takes no options.

	- **@r** `A` bool with true if the webcam is open and false if not.


- **getViewSize** ()

	> Gets the current capture size. This function takes no options.

	- **@r** `A` two item list containing width and height.


- **getViewSizes** ()

	> Gets the capture sizes supported by this webcam driver. This function takes no options. Use one of the returned [width, height] pairs when calling setViewSize().

	- **@r** `A` list of two item lists. Each child list contains width and height.


- **setViewSize** (`int Width, int Height`)

	> Sets the capture size. This should be called before open(). Width and Height must be one of the [width, height] pairs returned by getViewSizes() for this camera. Common examples include 160x120, 320x240, 640x480, 1280x720, and 1920x1080, but the real options are device-specific.

	- **@p** `Width` is an int with the capture width from getViewSizes().
	- **@p** `Height` is an int with the capture height from getViewSizes().
	- **@r** `This` object.


- **setResolution** (`string Name`)

	> Sets the capture size from a WebcamResolution enum name. This should be called before open(). Available names are QQVGA, HQVGA, QVGA, WQVGA, HVGA, VGA, WVGA, FWVGA, SVGA, DVGA, WSVGA1, WSVGA2, XGA, XGAP, WXGA1, WXGA2, WXGAP, SXGA, SXGAP, WSXGAP, UXGA, WUXGA, QWXGA, QXGA, WQXGA, QSXGA, WQSXGA, QUXGA, WQUXGA, HXGA, WHXGA, HSXGA, WHSXGA, HUXGA, WHUXGA, NHD, QHD, HD, HDP, FHD, FHDP, DCI2K, WQHD, WQHDP, UWQHD, UW4K, UHD4K, DCI4K, UW5K, UHDP5K, UW8K, UHD8K, PAL, and CIF. The name must exist in the library and the selected camera must support that size. Use getViewSizes() when you need the exact sizes reported by the active device.

	- **@p** `Name` is a string with a WebcamResolution enum name.
	- **@r** `This` object.


- **setFps** (`double Fps`)

	> Sets the target capture rate of the underlying frame updater. The rate is a soft cap, not a guarantee. The default is 9.6 frames per second. Only takes effect in async mode. Call before open() or while the webcam is open.

	- **@p** `Fps` is a double with the target frames per second. Must be greater than zero.
	- **@r** `This` object.


- **getFps** ()

	> Returns the target capture rate of the underlying frame updater.

	- **@r** `A` double with the target frames per second.


- **getImageBytes** (`string Format = "png"`)

	> Captures one frame and returns encoded image bytes. In async mode this returns the most recent cached frame. In sync mode it grabs a fresh frame from the device. Format must be an ImageIO writer format name. Common built-in Java options are png, jpg, jpeg, gif, bmp, and wbmp. Some Java runtimes also provide tif or tiff. Format names are case-insensitive.

	- **@p** `Format` is an optional ImageIO format name. The default is png.
	- **@r** `A` Buffer containing the encoded image.


- **saveImage** (`string Path, string Format = null`)

	> Captures one frame and saves it to disk. Format must be an ImageIO writer format name. Common built-in Java options are png, jpg, jpeg, gif, bmp, and wbmp. Some Java runtimes also provide tif or tiff. Format names are case-insensitive. If Format is null, the file extension from Path is used.

	- **@p** `Path` is a string with the image output path. The parent directory must exist.
	- **@p** `Format` is an optional ImageIO format name or null to use the file extension.
	- **@r** `This` object.


- **latestFrame** (`string Format = "png"`)

	> Returns the most recent cached frame as encoded image bytes. Non-blocking. Returns null when no frame has arrived yet. Requires the webcam to be open in async mode. Useful for a JavaFX preview driven by an AnimationTimer that pulls frames on its own clock.

	- **@p** `Format` is an optional ImageIO format name. The default is png.
	- **@r** `A` Buffer with the encoded frame, or null when no frame is available.


- **nextFrame** (`int TimeoutMs = 0, string Format = "png"`)

	> Blocks until a fresh frame arrives, then returns its encoded bytes. Each call returns a frame newer than the one returned by the previous call on this Webcam object. If the consumer is slow, intermediate frames are dropped silently and the call returns the latest one. Requires the webcam to be open in async mode.

	- **@p** `TimeoutMs` is an int with the maximum wait time in milliseconds. A value of zero or less waits forever. The default is zero.
	- **@p** `Format` is an optional ImageIO format name. The default is png.
	- **@r** `A` Buffer with the encoded frame, or null when the timeout elapses.


- **startStream** (`callback OnFrame, double Fps = 30.0, string Format = "png"`)

	> Starts a push stream that calls the provided callback for each new frame. Requires the webcam to be open in async mode. The callback receives one Buffer argument with the encoded frame bytes. The callback runs on a background stream thread, not on the Aussom main thread. Slow callbacks slow the loop and cause frames to be dropped silently; the loop never queues frames. IMPORTANT: When using JavaFX, scene-graph nodes such as ImageView and WritableImage may only be touched from the JavaFX Application Thread. A startStream callback that writes directly into a scene-graph node will throw "Not on FX application thread". Marshal those writes back onto the FX thread (for example with fxapp.runLater(...)), or use latestFrame() from inside an AnimationTimer instead. Only one stream may be active per Webcam at a time. Calling startStream() while one is already running throws.

	- **@p** `OnFrame` is a callback invoked with one Buffer argument per frame.
	- **@p** `Fps` is an optional double with the target frames per second. The default is 30.0. The rate is a soft cap, not a guarantee.
	- **@p** `Format` is an optional ImageIO format name. The default is png.
	- **@r** `This` object.


- **stopStream** ()

	> Stops a push stream started with startStream() and waits briefly for the stream thread to exit. Safe to call when no stream is running.

	- **@r** `This` object.


- **isStreaming** ()

	> Returns whether a push stream is currently running.

	- **@r** `A` bool with true if a stream is active and false if not.




## class: WebcamCapture

[32:21] `static` (extern: com.lehman.aussom.WebcamCapture) **extends: object** 

Static entry point for webcam discovery.

#### Methods

- **getDefault** ()

	> Gets the system default webcam. This function takes no options. The selected device is chosen by the webcam-capture library and the operating system.

	- **@r** `A` Webcam object, or null if no webcam is available.


- **getWebcams** ()

	> Gets all webcams detected on the system. This function takes no options. Device discovery is handled by the webcam-capture library.

	- **@r** `A` list of Webcam objects. The list is empty when no webcam is found.


- **getDefaultName** ()

	> Gets the name of the system default webcam. This function takes no options. The selected device is chosen by the webcam-capture library and the operating system.

	- **@r** `A` string with the webcam name, or null if no webcam is available.




