# AI USB camera
The **gst-ai-usb-camera-app** streams video from a USB webcam connected to the Qualcomm EVK. This webcam should be accessible as a `/dev/videoX` device. Additionally, you can perform object detection and preview the results.
You can choose to preview the output on Wayland, or encode to a video file, or live stream through the RTSP.
Alternatively, you can set `enable-object-detection`as *True* to perform object detection.
The following figures show a pipeline, which processes the input from the USB camera to generate various outputs.
For more information about the plugins used in these pipelines, see [Pipeline flow](https://docs.qualcomm.com/doc/80-80021-50/topic/ai-usb-camera.html#section-jjq-bln-42c).
Live camera preview on display
v4l2src
qtivtransform
capsfilter
waylandsink
Video encoding
v4l2src
qtivtransform
capsfilter
v4l2h264enc
h264parse
mp4mux
filesink
h264parse
qtirtspbin
Video encoding and RTSP streaming
v4l2src
qtivtransform
capsfilter
v4l2h264enc
Qualcomm
Open source
**Figure : gst-ai-usb-camera-app pipeline**
v4l2src
qtimlvtransform
qtimlvconverter
qtimltflite/ qtimlsnpe/ qtimlqnn
qtimlpostprocess
qtivcomposer
waylandsink
capsfilter
tee
v4l2src
qtimlvtransform
qtimlvconverter
qtimltflite/ qtimlsnpe/ qtimlqnn
qtimlpostprocess
qtivcomposer
filesink
capsfilter
tee
v4l2src
qtimlvtransform
qtimlvconverter
qtimltflite/ qtimlsnpe/ qtimlqnn
qtimlpostprocess
qtivcomposer
RTSP sink
capsfilter
tee
Qualcomm
Open source
**Figure : gst-ai-usb-camera-app pipeline with object detection**
## Input and output capabilities
The following table summarizes the input and output capabilities supported by the sample application:
| Config | Input | Input | Input | Input | Output | Output | Output |
| --- | --- | --- | --- | --- | --- | --- | --- |
| Config | File src | RTSP | USB camera | MIPI camera | File | Display | RTSP |
| Config #1 | Yes | Yes | yes | No | No | Yes | No |
| Config #2 | Yes | Yes | Yes | No | No | Yes | No |
| | | | | | | | |
## Sample model and label files
| **Runtime** | **Model files** | **Label files** |
| --- | --- | --- |
| Qualcomm Neural Processing SDK |
yolonas.dlc
yolov5.dlc
yolov8.dlc
| \* *yolonas.json* \* *yolov8.json* \* *yolov5.json* \* *yolox.json* |
| LiteRT | | \* *yolonas.json* \* *yolov8.json* \* *yolov5.json* \* *yolox.json* |
| Qualcomm AI Engine direct | *yolov8\_det\_quantized.bin* | \* *yolonas.json* \* *yolov8.json* \* *yolov5.json* \* *yolox.json* |
| | | |
| | | |
## Run the application on the target device
The sample application uses the `/etc/configs/config-usb-camera-app.json` file to read the input parameters. Ensure that you use the config JSON file to run the application.
To create your own config JSON file, use [config-usb-camera-app.json](https://git.codelinaro.org/clo/le/platform/vendor/qcom-opensource/gst-plugins-qti-oss/-/blob/imsdk.lnx.2.0.0.r2-rel/gst-sample-apps/gst-ai-usb-camera-app/config-usb-camera-app.json?ref_type=heads) as a reference.
1. Ensure to connect the USB webcam to the target device and complete the [Prerequisites](https://docs.qualcomm.com/doc/80-80021-50/topic/download-model-and-label-files.html).
Note
If the USB camera isn’t detected on the target device, Download the required firmware. See [Download PCIe to USB controller firmware](https://docs.qualcomm.com/bundle/publicresource/topics/80-80021-8/pcie.html#download-pcie-to-usb-controller-firmware).
Note
For USB camera input, set the `video-format`, `resolution`, and `framerate` parameters in the configuration file to match the capabilities of the camera. To check the camera capabilities, see [Configure USB camera](https://docs.qualcomm.com/bundle/publicresource/topics/80-80021-8/usb.html#configure-usb-camera).
2. Update the config JSON file based on the model, input stream, and other properties. For more information, see [Config JSON field description](https://docs.qualcomm.com/doc/80-80021-50/topic/gst-ai-object-detection.html#section-qjx-hqq-32c).
3. Use the following format of the `/etc/configs/config-usb-camera-app.json` file:
{
"width": "",
"height": "",
"framerate": "",
"video-format": "",
"output": "",
"ip-address":"",
"port":"",
"enable-object-detection": "",
"file-path": " ",
"ml-framework": "",
"yolo-model-type": "",
"model": "",
"labels": "",
"threshold": "",
"runtime": "",
"snpe-tensors": ""
}
Copy to clipboard
An example format file for Config #2 and Config #1 is as follows:
Tab Config #2
Tab Config #1
For example, run the application using RTSP input, LiteRT, YOLOx model, DSP runtime, and custom threshold value. The reference config file is as follows:
>
>
> {
> "width": 1920,
> "height": 1080,
> "framerate": 30,
> "output":"waylandsink",
> "video-format":"yuy2",
> "model":"/etc/models/yolox_quantized.tflite",
> "labels":"/etc/labels/yolox.json",
> "output-file":"/etc/media/output.mp4",
> "ip-address":"127.0.0.1",
> "port":"8900",
> "enable-object-detection": "TRUE",
> "ml-framework": "tflite",
> "yolo-model-type": "yolox",
> "threshold": 75,
> "runtime": "dsp"
> }
> Copy to clipboard
For example, run the application using RTSP input, LiteRT, YOLOx model, CPU runtime, and custom threshold value. The reference config file is as follows:
>
>
> {
> "width": 1920,
> "height": 1080,
> "framerate": 30,
> "output":"waylandsink",
> "video-format":"yuy2",
> "model":"/etc/models/yolox_quantized.tflite",
> "labels":"/etc/labels/yolox.json",
> "output-file":"/etc/media/output.mp4",
> "ip-address":"127.0.0.1",
> "port":"8900",
> "enable-object-detection": "TRUE",
> "ml-framework": "tflite",
> "yolo-model-type": "yolox",
> "threshold": 75,
> "runtime": "cpu"
> }
> Copy to clipboard
>
>
> Note
>
>
> Config #1 supports only LiteRT models and the CPU runtime.
Note
The `snpe-tensors` field applies only to the SNPE runtime. To retrieve the output tensor names for a DLC model, open the model in [Netron](https://netron.app/).
Note
When using DLC models from the AI Hub, the `snpe-tensors` field is optional.
4. Run the gst-ai-usb-camera-app application:
gst-ai-usb-camera-app --config-file=/etc/configs/config-usb-camera-app.json
Copy to clipboard
Note
You can run the `Yolo-NAS-Quantized.tflite` model using the YOLOv8 value in the `yolo-model-type` field.
5. To display the available help options, run the following command in the SSH shell:
gst-ai-usb-camera-app -h
Copy to clipboard
6. To stop the use case, use **CTRL + C**.
## Expected output
The following table lists the expected output for each use case:
Table : Expected output for gst-usb-camera-app
| Use case | Output |
| --- | --- |
| Preview | Preview of the camera stream. See [Expected output for gst-ai-usb-camera-app application–Preview](https://docs.qualcomm.com/doc/80-80021-50/topic/video-playback-using-opencv.html#fig-ihh-tqq-5bc). |
| Save the MP4 | Save the output to a file at `/etc/media/video.mp4` folder path. |
| RTSP | Stream the output over the network. |
| Object detection | See [Expected output for gst-ai-usb-camera-app application–object detection](https://docs.qualcomm.com/doc/80-80021-50/topic/rts-decode-ai-detection-yolo-v8-overlay-display.html#fig-rfc-yfd-5bc). |

**Figure : Expected output for gst-ai-usb-camera-app application–Preview**

**Figure : Expected output for gst-ai-usb-camera-app application–object detection**
## Pipeline flow
The following table lists the plugins used in AI USB camera pipelines:
| Pipeline | Description |
| --- | --- |
| Dump the USB camera to a filesink | USB camera captures the camera live stream.
qtivtransform transforms the stream data.
Capsfilter is applied to enforce constraints on the raw video data.
Filesink is used to dump the data into a file.
|
| Video encoding | USB camera captures the camera live stream.
qtivtransform transforms the stream data.
Capsfilter is applied to enforce constraints on the raw video data.
v4l2h264enc is used to encode the video using the H.264 format.
H264parse is used to parse the video.
Mp4mux is used to multiplex the video into an MP4 container.
Filesink is used to write the video to a file.
|
| RTSP streaming | USB camera captures the camera live stream.
qtivtransform transforms the stream data.
Capsfilter is applied to enforce constraints on the raw video data.
v4l2h264enc is used to encode the video using the H.264 format.
H264parse is used to parse the video.
qtirtspbin is used to load the stream to RTSP.
|
| USB camera and object detection on RTSP | USB camera captures the camera live stream.
Capsfilter is applied to enforce constraints on the raw video data.
tee is used to split the stream for inferencing.
qtivtransform transforms the stream data.
qtimlvconverter does preprocessing and converts the video stream to a tensor stream, which is used for inferencing.
qtimlsnpe , qtimltflite , or qtimlqnn run the inference on the stream.
qtimlpostprocess handles the inference results from any object detection model and produces video frames.
qtivcomposer composes the video frames and shares them with qtirtspsink.
qtirtspbin submits the composed video stream to Weston, which renders it on the local display.
|
| USB camera and object detection on wayland | USB camera captures the camera live stream.
Capsfilter is applied to enforce constraints on the raw video data.
tee is used to split the stream for inferencing.
qtivtransform transforms the stream data.
qtimlvconverter does preprocessing and converts the video stream to a tensor stream, which is used for inferencing.
qtimlsnpe , qtimltflite , or qtimlqnn run the inference on the stream.
qtimlpostprocess handles the inference results from any object detection model and produces video frames.
qtivcomposer composes the video frames and shares them with Waylandsink.
Waylandsink submits the composed video stream to Weston, which renders it on the local display.
|
| Object detection using USB camera and file encode | USB camera captures the camera live stream.
Capsfilter is applied to enforce constraints on the raw video data.
tee is used to split the stream for inferencing.
qtivtransform transforms the stream data.
qtimlvconverter does preprocessing and converts the video stream to a tensor stream, which is used for inferencing.
qtimlsnpe , qtimltflite , or qtimlqnn run the inference on the stream.
qtimlpostprocess handles the inference results from any object detection model and produces video frames.
qtivcomposer composes the video frames and shares them with Waylandsink.
Filesink submits the composed video stream to Weston, which renders it on the local display.
|
## Config JSON field description
The different parameters available to configure the JSON file and run the use case are as follows:
Table : Field description–config_detection.json file
| Field | Values/description |
| --- | --- |
| **ml-framework** | Use one of the following models: |
| **yolo-model-type** | Run the `yolov5`, `yolov8`, and `yolonas` models respectively. See [Sample model and label files](https://docs.qualcomm.com/doc/80-80021-50/topic/vision_ai_demo_app.html#section-ohr-1qq-32c). |
| **runtime** | Use one of the following runtimes: |
| **output** | filesink
waylandsink
rtspsink
|
| **enable-object-detection** | |
| **snpe-tensors** | `["output-tensor-name","output-tensor-name"]` |
| **USB camera video-format and resolution** | Use one of the following video-formats: Use the following resolution parameters:width : Input USB camera source resolution width.
height : Input USB camera source resolution height.
framerate : Input USB camera source framerate.
|
## Known issues
Tab Config #2
Tab Config #1
- Lag is observed in video streaming with USB camera source as quantized models aren't supported in the TFlite IM SDK framework.
- The GPU delegate doesn't function in the QNN and TFLite IM SDK frameworks.
- The application may intermittently fail due to USB camera enumeration issues.
- The file encode use case doesn't work.
The application may intermittently fail due to USB camera enumeration issues.
## Related information
[Object detection](https://docs.qualcomm.com/doc/80-80021-50/topic/gst-ai-object-detection.html)
Last Published: Mar 26, 2026
[Previous Topic
AI event encoder](https://docs.qualcomm.com/bundle/publicresource/80-80021-50/topics/gst-ai-event-encoder.md) [Next Topic
Hardware benchmarking application](https://docs.qualcomm.com/bundle/publicresource/80-80021-50/topics/vision_ai_demo_app.md)
Source: [https://docs.qualcomm.com/doc/80-80021-50/topic/ai-usb-camera.html](https://docs.qualcomm.com/doc/80-80021-50/topic/ai-usb-camera.html)