# Camera USB External

This function block connects to an external USB camera by device index and provides flexible controls for resolution, exposure and live frame streaming. It is suitable for automation and production setups where camera index, resolution and exposure are driven by other blocks or external signals.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Activate Signal` Use this boolean to start retrieving frames from the selected camera.

`Release Signal` Use this boolean to stop the camera and release its resources.

`Camera Index` Provide an integer to select the camera device (device index or scanned index mapping).

`Resolution Width` Provide an integer for the desired capture width.

`Resolution Height` Provide an integer for the desired capture height.

`Scan Cameras` Set to true to rescan connected USB cameras and refresh available device list.

`Set Exposure` Optional numeric value to set manual exposure on the camera when supported.

`Set Auto Exposure` Optional numeric value to set the camera auto-exposure mode when supported.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

`Camera Frame` The latest captured image frame from the selected USB camera.

## 🕹️ Controls <a href="#controls" id="controls"></a>

`Source / Resolution Info` A status label that shows current camera source and active resolution.

Note: Many controls are provided as input sockets so the block can be driven by other blocks or UI controls.

## 🎯 Features <a href="#features" id="features"></a>

* Camera selection by device index or scanned list mapping, suitable for multi-camera systems.
* Runtime resolution change using separate width and height inputs.
* Manual exposure and auto-exposure control when the camera and platform support them.
* Soft restart behavior: the block attempts to recover from blank or failed frames by restarting the camera automatically.
* Optional background frame uploader (if configured in the system) to stream frames for remote logging or analysis.
* Designed for headless or automated workflows because most settings are available via inputs.

## ⚙️ Running mechanism <a href="#running-mechanism" id="running-mechanism"></a>

* When `Activate Signal` is true the block attempts to deliver frames via `Camera Frame`.
* When `Release Signal` is true the block stops capture and frees camera resources.
* Changing `Camera Index` triggers the block to open the chosen device.
* Providing `Resolution Width` and `Resolution Height` while active will attempt to change the capture resolution.
* Providing `Set Exposure` or `Set Auto Exposure` will attempt to adjust camera exposure settings if supported by the device.
* If the block encounters repeated blank or failed frames it will perform a restart cycle to recover the camera automatically.
* If `Scan Cameras` is activated the block refreshes the available camera list (useful when plugging in new devices).

## 📝 Usage instructions <a href="#usage" id="usage"></a>

1. Use `Scan Cameras` or your system's camera discovery to list available devices.
2. Provide the desired device index to `Camera Index` to choose a camera.
3. Optionally set `Resolution Width` and `Resolution Height` for the capture size you want.
4. Send `Activate Signal` to begin frame capture. Monitor `Source / Resolution Info` for current state.
5. Adjust `Set Exposure` or `Set Auto Exposure` only if your camera supports these controls.
6. Send `Release Signal` when finished to free the device.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* To preview frames live, connect this block's `Camera Frame` output to the `Show Image` block for an interactive viewer.
* To save frames or create a dataset connect `Camera Frame` to the `Image Logger` or `Record Video` blocks.
* If the camera produces noisy frames, try sending frames through `Blur` or `Denoising` before passing them to detectors.
* Resize high-resolution captures before heavy processing to improve speed: connect `Camera Frame` to `Image Resize` then to downstream analysis blocks.
* For region-based analysis, crop the frame using `Image ROI Select` before running detectors such as `Find Object` or `Object Detection`.
* Combine with AI blocks like `Object Detection - Custom` or `Skeleton Estimation` for live inference pipelines.
* Use `Scan Cameras` when hot-plugging cameras so the block can discover new devices without restarting the whole system.

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* No frames or black/blank frames:
  * Verify the correct integer is provided to `Camera Index`. If unsure, run a scan with `Scan Cameras`.
  * Make sure no other application is using the camera. Release or close other apps and try again.
  * Try lower resolution values via `Resolution Width` and `Resolution Height` — some cameras cannot stream high resolutions reliably.
* Exposure controls have no effect:
  * Not all cameras or platforms support programmatic exposure control. If settings do not apply, try the camera vendor utility or use the block's Info label to confirm current values.
* Intermittent frame drops or failures:
  * Try using a different USB port or a powered USB hub. Use lower resolution to reduce bandwidth.
  * If automatic recovery does not help, toggle `Release Signal` then `Activate Signal` to force a full restart.
* Camera not detected on scan:
  * Ensure the device is powered and connected. Re-plug the camera and enable `Scan Cameras` again.
  * On some systems device indexes may change after reboot or re-plugging — use the scan list mapping to select reliably.

If issues persist, preview frames with `Show Image` and capture a short recording with `Record Video` to inspect the behavior and share with support.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.augelab.com/function-blocks/input-output/image-inputs/camera-usb-external.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
