On this page

Simple Face Detection

Runs face detection on a live camera stream and logs the results.

This example shows the smallest useful Qt Edge AI application: a QML scene that displays live camera video and, at the same time, feeds the frames into an on-device inference pipeline. The pipeline is declared entirely in QML with the InferenceFlow, InferenceVideoSource, VisionInference, and InferenceResultParser types; no C++ inference code is needed. Study it to see how a capture session from Qt Multimedia is shared between the on-screen video preview and an inference flow, and how an application receives inference results.

Running the example

Running the Example

You can run the example from:

The example needs a camera and the GStreamer backend of Qt Edge AI; see Platform notes below.

What to look for

One capture session for preview and inference
CaptureSession {
    id: session
    camera: Camera {}
    videoOutput: videoOutput
}

VideoOutput {
    id: videoOutput
    anchors.fill: parent
}

A CaptureSession owns the Camera and renders its frames to the VideoOutput that fills the window. The same session is assigned to the flow's InferenceVideoSource below, so the preview and the inference pipeline work from one camera source.

The inference pipeline
InferenceFlow {
    id: pipeline

    InferenceVideoSource {
        id: videoSource
        captureSession: session
    }

    VisionInference {
        id: detectionStep
        name: "edgeimpulse"
        model: "libgstedgeimpulse.so"
    }

    InferenceResultParser {
        id: jsonParser
        onDataAvailable: data => console.log(data)
    }
}

The steps are declared as children of InferenceFlow. None of them declares an explicit DataPortConnection, so the flow chains them in declaration order by matching output and input port types: camera video flows from the InferenceVideoSource into the VisionInference step, and the model output continues into the InferenceResultParser.

On the VisionInference step, name selects the edgeimpulse backend variant and model names the Edge Impulse model library for the backend to load. The parser's dataAvailable signal delivers each parsed result, which this example simply logs to the console.

Starting the flow
Component.onCompleted: {
    session.camera.start()
    pipeline.start(window)
}

The camera and the flow only start once the scene has loaded: the handler starts the camera and calls start(), passing the window so that the pipeline starts on the render thread.

Platform notes

The inference steps are provided by the GStreamer backend plugin of Qt Edge AI, which is built only when GStreamer 1.20 or later is available. The example also sets the QT_MEDIA_BACKEND environment variable to gstreamer in main.cpp, so it requires a Qt Multimedia GStreamer media backend, and an Edge Impulse GStreamer plugin must be available as the model library.

Files:

See also Qt Edge AI and Qt Edge AI QML Types.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.