Skip to content

qpycam-detect Command

The qpycam-detect command performs AI-based image analysis, such as object detection, image classification, segmentation, and pose estimation. It supports real-time processing and can stream results via RTSP or MQTT.

Usage

qpycam-detect [OPTIONS]

Commonly Used Options

Option Description
-ct, --camera_type Selects the camera type (0: CSI, 1: USB, 2: RTSP).
-id, --device_id Specifies the device ID for USB cameras (default: 2).
-url, --input_rtsp_url RTSP stream URL (only for RTSP cameras).
-t, --timeout Sets the stream duration in ms (0 for infinite).
--mqtt_topic MQTT topic to publish inference results.
--mqtt_host MQTT broker IP address
--mqtt_port MQTT broker port number
--mqtt_config Path to the MQTT configuration file

For a full list of common options, refer to Common Options.

AI Detection Options

Option Description
--display Enable video stream display on screen
-dt, --detect_type Type of detection (classification, detection, segmentation, pose, superresolution).
--module AI model module to use (e.g., yolo-nas, mobilenet, posenet).
--delegate Backend for model inference (gpu, cpu, xnnpack).
-m, --model Path to the AI model file.
-l, --labels Path to the label file.
--threshold Confidence threshold for detection (default: 50).
--results Number of detection results to display (default: 10).
--constants Additional constants for the model.

Note

The qpycam-detect command supports saving video, inference, displaying output, and RTSP streaming. It combines the features of qpycam-hello, qpycam-rtsp, and qpycam-record. However, display is disabled by default. To enable it, use the --display option.

Supported Models

Qpycam currently supports models in the TFLite format for computer vision inference.

Model Type Model File(s)
classification inception_v3_quantized.tflite
object detection Yolo-v7-Quantized.tflite
YOLOv8-Detection-Quantized.tflite
segmentation deeplabv3_resnet50.tflite
pose hrnet_pose_quantized.tflite
posenet_mobilenet_v1.tflite

Example Usage

  1. Run segmentation using an unquantized DeepLab model

    qpycam-detect --detect_type segmentation --module deeplab-argmax --model /opt/demo/model/deeplabv3_resnet50.tflite --label /opt/demo/label/deeplabv3_resnet50.labels
    
  2. Run object detection using a quantized YOLOv8 model with additional constants

    qpycam-detect --detect_type detection --module yolov8 -m /opt/yolov8_quantized.tflite -l /opt/coco_labels.labels --constants YOLOv8,q-offsets=<21.0, 0.0, 0.0>,q-scales=<3.093529462814331, 0.00390625, 1.0>;
    
  3. Send detection results to an MQTT broker

    qpycam-detect --detect_type detection --module yolov8 -m /opt/yolov8.tflite -l /opt/yolov8.labels --mqtt_host 192.168.1.50 --mqtt_port 1883 --mqtt_topic "ai/detections"
    

For configuration file usage, see Configuration Guide.