QCamera

The QCamera class provides interface for system camera devices. More

Inheritance diagram of PySide6.QtMultimedia.QCamera

Synopsis

Functions

Detailed Description

QCamera can be used within a QMediaCaptureSession for video recording and image taking.

You can use QCameraDevice to list available cameras and choose which one to use.

const QList<QCameraDevice> cameras = QMediaDevices::videoInputs();
for (const QCameraDevice &cameraDevice : cameras) {
    if (cameraDevice.description() == "mycamera")
        camera = new QCamera(cameraDevice);
}

On hardware that supports it, QCamera lets you adjust the focus and zoom. This also includes functionality such as a “Macro” mode for close up work (e.g. reading barcodes, or recognizing letters), or “touch to focus” - indicating an interesting area of the image for the hardware to attempt to focus on.

camera->setFocusPointMode(QCamera::FocusModeManual);
camera->setCustomFocusPoint(QPointF(0.25f, 0.75f)); // A point near the bottom left, 25% away from the corner, near that shiny vase

The minimumZoomFactor() and maximumZoomFactor() methods provide the range of supported zoom factors. The zoomTo() method allows changing the zoom factor.

camera->setZoomFactor(3.0);

After capturing the raw data for a camera frame, the camera hardware and software performs various image processing tasks to produce the final image. This includes compensating for ambient light color, reducing noise, as well as making some other adjustments to the image.

You can control many of these processing steps through the Camera properties. For example, you can set the white balance (or color temperature) used for processing images:

camera->setWhiteBalanceMode(QCamera::WhiteBalanceFluorescent);

For more information on image processing of camera frames, see Camera Image Processing .

See the camera overview for more information.

class PySide6.QtMultimedia.QCamera(position[, parent=None])

PySide6.QtMultimedia.QCamera([parent=None])

PySide6.QtMultimedia.QCamera(cameraDevice[, parent=None])

Parameters

Construct a QCamera which uses a hardware camera located a the specified position.

For example on a mobile phone it can be used to easily choose between front-facing and back-facing cameras.

If no camera is available at the specified position or if position is UnspecifiedPosition , the default camera is used.

Construct a QCamera with a parent.

Selects the default camera on the system if more than one camera is available.

PySide6.QtMultimedia.QCamera.Error

This enum holds the last error code.

Constant

Description

QCamera.NoError

No errors have occurred.

QCamera.CameraError

An error has occurred.

PySide6.QtMultimedia.QCamera.FocusMode

Constant

Description

QCamera.FocusModeAuto

Continuous auto focus mode.

QCamera.FocusModeAutoNear

Continuous auto focus mode on near objects.

QCamera.FocusModeAutoFar

Continuous auto focus mode on objects far away.

QCamera.FocusModeHyperfocal

Focus to hyperfocal distance, with the maximum depth of field achieved. All objects at distances from half of this distance out to infinity will be acceptably sharp.

QCamera.FocusModeInfinity

Focus strictly to infinity.

QCamera.FocusModeManual

Manual or fixed focus mode.

New in version 6.1.

PySide6.QtMultimedia.QCamera.FlashMode

Constant

Description

QCamera.FlashOff

Flash is Off.

QCamera.FlashOn

Flash is On.

QCamera.FlashAuto

Automatic flash.

New in version 6.1.

PySide6.QtMultimedia.QCamera.TorchMode

Constant

Description

QCamera.TorchOff

Torch is Off.

QCamera.TorchOn

Torch is On.

QCamera.TorchAuto

Automatic torch.

New in version 6.1.

PySide6.QtMultimedia.QCamera.ExposureMode

Constant

Description

QCamera.ExposureAuto

Automatic mode.

QCamera.ExposureManual

Manual mode.

QCamera.ExposurePortrait

Portrait exposure mode.

QCamera.ExposureNight

Night mode.

QCamera.ExposureSports

Spots exposure mode.

QCamera.ExposureSnow

Snow exposure mode.

QCamera.ExposureBeach

Beach exposure mode.

QCamera.ExposureAction

Action mode. Since 5.5

QCamera.ExposureLandscape

Landscape mode. Since 5.5

QCamera.ExposureNightPortrait

Night portrait mode. Since 5.5

QCamera.ExposureTheatre

Theatre mode. Since 5.5

QCamera.ExposureSunset

Sunset mode. Since 5.5

QCamera.ExposureSteadyPhoto

Steady photo mode. Since 5.5

QCamera.ExposureFireworks

Fireworks mode. Since 5.5

QCamera.ExposureParty

Party mode. Since 5.5

QCamera.ExposureCandlelight

Candlelight mode. Since 5.5

QCamera.ExposureBarcode

Barcode mode. Since 5.5

New in version 6.1.

PySide6.QtMultimedia.QCamera.WhiteBalanceMode

Constant

Description

QCamera.WhiteBalanceAuto

Auto white balance mode.

QCamera.WhiteBalanceManual

Manual white balance. In this mode the white balance should be set with setColorTemperature()

QCamera.WhiteBalanceSunlight

Sunlight white balance mode.

QCamera.WhiteBalanceCloudy

Cloudy white balance mode.

QCamera.WhiteBalanceShade

Shade white balance mode.

QCamera.WhiteBalanceTungsten

Tungsten (incandescent) white balance mode.

QCamera.WhiteBalanceFluorescent

Fluorescent white balance mode.

QCamera.WhiteBalanceFlash

Flash white balance mode.

QCamera.WhiteBalanceSunset

Sunset white balance mode.

New in version 6.1.

PySide6.QtMultimedia.QCamera.Feature

Describes a set of features supported by the camera. The returned value can be a combination of:

Constant

Description

QCamera.Feature.ColorTemperature

The Camera supports setting a custom colorTemperature .

QCamera.Feature.ExposureCompensation

The Camera supports setting a custom exposureCompensation .

QCamera.Feature.IsoSensitivity

The Camera supports setting a custom isoSensitivity .

QCamera.Feature.ManualExposureTime

The Camera supports setting a manual exposure Time .

QCamera.Feature.CustomFocusPoint

The Camera supports setting a custom focus point .

QCamera.Feature.FocusDistance

The Camera supports setting the focusDistance property.

New in version 6.1.

PySide6.QtMultimedia.QCamera.activeChanged(arg__1)
Parameters

arg__1 – bool

PySide6.QtMultimedia.QCamera.brightnessChanged()
PySide6.QtMultimedia.QCamera.cameraDevice()
Return type

PySide6.QtMultimedia.QCameraDevice

Returns the QCameraDevice object associated with this camera.

PySide6.QtMultimedia.QCamera.cameraDeviceChanged()
PySide6.QtMultimedia.QCamera.cameraFormat()
Return type

PySide6.QtMultimedia.QCameraFormat

Returns the camera format currently used by the camera.

PySide6.QtMultimedia.QCamera.cameraFormatChanged()
PySide6.QtMultimedia.QCamera.captureSession()
Return type

PySide6.QtMultimedia.QMediaCaptureSession

Returns the capture session this camera is connected to, or a nullptr if the camera is not connected to a capture session.

use setCamera() to connect the camera to a session.

PySide6.QtMultimedia.QCamera.colorTemperature()
Return type

int

Returns the current color temperature if the current white balance mode is WhiteBalanceManual. For other modes the return value is undefined.

PySide6.QtMultimedia.QCamera.colorTemperatureChanged()
PySide6.QtMultimedia.QCamera.contrastChanged()
PySide6.QtMultimedia.QCamera.customFocusPoint()
Return type

PySide6.QtCore.QPointF

PySide6.QtMultimedia.QCamera.customFocusPointChanged()
PySide6.QtMultimedia.QCamera.error()
Return type

Error

Returns the error state of the camera.

PySide6.QtMultimedia.QCamera.errorChanged()
PySide6.QtMultimedia.QCamera.errorOccurred(error, errorString)
Parameters
  • errorError

  • errorString – str

This signal is emitted when error state changes to error. A description of the error is provided as errorString.

PySide6.QtMultimedia.QCamera.errorString()
Return type

str

Returns a human readable string describing a camera’s error state.

PySide6.QtMultimedia.QCamera.exposureCompensation()
Return type

float

PySide6.QtMultimedia.QCamera.exposureCompensationChanged(arg__1)
Parameters

arg__1 – float

Signal emitted when the exposure compensation changes to value.

PySide6.QtMultimedia.QCamera.exposureMode()
Return type

ExposureMode

PySide6.QtMultimedia.QCamera.exposureModeChanged()
PySide6.QtMultimedia.QCamera.exposureTime()
Return type

float

Returns the current exposure time in seconds.

PySide6.QtMultimedia.QCamera.exposureTimeChanged(speed)
Parameters

speed – float

Signals that a camera’s exposure speed has changed.

PySide6.QtMultimedia.QCamera.flashMode()
Return type

FlashMode

See also

setFlashMode()

PySide6.QtMultimedia.QCamera.flashModeChanged()
PySide6.QtMultimedia.QCamera.flashReady(arg__1)
Parameters

arg__1 – bool

Signal the flash ready status has changed.

PySide6.QtMultimedia.QCamera.focusDistance()
Return type

float

PySide6.QtMultimedia.QCamera.focusDistanceChanged(arg__1)
Parameters

arg__1 – float

PySide6.QtMultimedia.QCamera.focusMode()
Return type

FocusMode

See also

setFocusMode()

PySide6.QtMultimedia.QCamera.focusModeChanged()
PySide6.QtMultimedia.QCamera.focusPoint()
Return type

PySide6.QtCore.QPointF

Returns the point currently used by the auto focus system to focus onto.

PySide6.QtMultimedia.QCamera.focusPointChanged()
PySide6.QtMultimedia.QCamera.hueChanged()
PySide6.QtMultimedia.QCamera.isActive()
Return type

bool

Returns true if the camera is currently active.

PySide6.QtMultimedia.QCamera.isAvailable()
Return type

bool

Returns true if the camera can be used.

PySide6.QtMultimedia.QCamera.isExposureModeSupported(mode)
Parameters

modeExposureMode

Return type

bool

Returns true if the exposure mode is supported.

PySide6.QtMultimedia.QCamera.isFlashModeSupported(mode)
Parameters

modeFlashMode

Return type

bool

Returns true if the flash mode is supported.

PySide6.QtMultimedia.QCamera.isFlashReady()
Return type

bool

Returns true if flash is charged.

PySide6.QtMultimedia.QCamera.isFocusModeSupported(mode)
Parameters

modeFocusMode

Return type

bool

Returns true if the focus mode is supported by the camera.

PySide6.QtMultimedia.QCamera.isTorchModeSupported(mode)
Parameters

modeTorchMode

Return type

bool

Returns true if the torch mode is supported.

PySide6.QtMultimedia.QCamera.isWhiteBalanceModeSupported(mode)
Parameters

modeWhiteBalanceMode

Return type

bool

Returns true if the white balance mode is supported.

PySide6.QtMultimedia.QCamera.isoSensitivity()
Return type

int

PySide6.QtMultimedia.QCamera.isoSensitivityChanged(arg__1)
Parameters

arg__1 – int

Signal emitted when sensitivity changes to value.

PySide6.QtMultimedia.QCamera.manualExposureTime()
Return type

float

Returns the manual exposure time in seconds, or -1 if the camera is using automatic exposure times.

PySide6.QtMultimedia.QCamera.manualExposureTimeChanged(speed)
Parameters

speed – float

PySide6.QtMultimedia.QCamera.manualIsoSensitivity()
Return type

int

PySide6.QtMultimedia.QCamera.manualIsoSensitivityChanged(arg__1)
Parameters

arg__1 – int

PySide6.QtMultimedia.QCamera.maximumExposureTime()
Return type

float

The maximal exposure time in seconds.

PySide6.QtMultimedia.QCamera.maximumIsoSensitivity()
Return type

int

Returns the maximum ISO sensitivity supported by the camera.

PySide6.QtMultimedia.QCamera.maximumZoomFactor()
Return type

float

Returns the maximum zoom factor.

This will be 1.0 on cameras that do not support zooming.

PySide6.QtMultimedia.QCamera.maximumZoomFactorChanged(arg__1)
Parameters

arg__1 – float

PySide6.QtMultimedia.QCamera.minimumExposureTime()
Return type

float

The minimal exposure time in seconds.

PySide6.QtMultimedia.QCamera.minimumIsoSensitivity()
Return type

int

Returns the minimum ISO sensitivity supported by the camera.

PySide6.QtMultimedia.QCamera.minimumZoomFactor()
Return type

float

Returns the minimum zoom factor.

This will be 1.0 on cameras that do not support zooming.

PySide6.QtMultimedia.QCamera.minimumZoomFactorChanged(arg__1)
Parameters

arg__1 – float

PySide6.QtMultimedia.QCamera.saturationChanged()
PySide6.QtMultimedia.QCamera.setActive(active)
Parameters

active – bool

Turns the camera on if active is true, or off if it’s false.

See also

isActive()

PySide6.QtMultimedia.QCamera.setAutoExposureTime()

Use automatically calculated exposure time

PySide6.QtMultimedia.QCamera.setAutoIsoSensitivity()

Turn on auto sensitivity

PySide6.QtMultimedia.QCamera.setCameraDevice(cameraDevice)
Parameters

cameraDevicePySide6.QtMultimedia.QCameraDevice

Connects the camera object to the physical camera device described by cameraDevice. Using a default constructed QCameraDevice object as cameraDevice will connect the camera to the system default camera device.

See also

cameraDevice()

PySide6.QtMultimedia.QCamera.setCameraFormat(format)
Parameters

formatPySide6.QtMultimedia.QCameraFormat

Tells the camera to use the format described by format. This can be used to define as specific resolution and frame rate to be used for recording and image capture.

See also

cameraFormat()

PySide6.QtMultimedia.QCamera.setColorTemperature(colorTemperature)
Parameters

colorTemperature – int

Sets manual white balance to colorTemperature. This is used when whiteBalanceMode() is set to WhiteBalanceManual. The units are Kelvin.

Setting a color temperature will only have an effect if WhiteBalanceManual is supported. In this case, setting a temperature greater 0 will automatically set the white balance mode to WhiteBalanceManual . Setting the temperature to 0 will reset the white balance mode to WhiteBalanceAuto .

PySide6.QtMultimedia.QCamera.setCustomFocusPoint(point)
Parameters

pointPySide6.QtCore.QPointF

PySide6.QtMultimedia.QCamera.setExposureCompensation(ev)
Parameters

ev – float

PySide6.QtMultimedia.QCamera.setExposureMode(mode)
Parameters

modeExposureMode

See also

exposureMode()

PySide6.QtMultimedia.QCamera.setFlashMode(mode)
Parameters

modeFlashMode

See also

flashMode()

PySide6.QtMultimedia.QCamera.setFocusDistance(d)
Parameters

d – float

See also

focusDistance()

PySide6.QtMultimedia.QCamera.setFocusMode(mode)
Parameters

modeFocusMode

See also

focusMode()

PySide6.QtMultimedia.QCamera.setManualExposureTime(seconds)
Parameters

seconds – float

Set the manual exposure time to seconds

PySide6.QtMultimedia.QCamera.setManualIsoSensitivity(iso)
Parameters

iso – int

PySide6.QtMultimedia.QCamera.setTorchMode(mode)
Parameters

modeTorchMode

See also

torchMode()

PySide6.QtMultimedia.QCamera.setWhiteBalanceMode(mode)
Parameters

modeWhiteBalanceMode

Sets the white balance to mode.

PySide6.QtMultimedia.QCamera.setZoomFactor(factor)
Parameters

factor – float

Zooms to a zoom factor factor at a rate of 1 factor per second.

See also

zoomFactor()

PySide6.QtMultimedia.QCamera.start()

Starts the camera.

Same as setActive (true).

If the camera can’t be started for some reason, the errorOccurred() signal is emitted.

PySide6.QtMultimedia.QCamera.stop()

Stops the camera. Same as setActive (false).

PySide6.QtMultimedia.QCamera.supportedFeatures()
Return type

Features

Returns the features supported by this camera.

See also

Feature

PySide6.QtMultimedia.QCamera.supportedFeaturesChanged()
PySide6.QtMultimedia.QCamera.torchMode()
Return type

TorchMode

See also

setTorchMode()

PySide6.QtMultimedia.QCamera.torchModeChanged()
PySide6.QtMultimedia.QCamera.whiteBalanceMode()
Return type

WhiteBalanceMode

Returns the white balance mode being used.

PySide6.QtMultimedia.QCamera.whiteBalanceModeChanged()
PySide6.QtMultimedia.QCamera.zoomFactor()
Return type

float

See also

setZoomFactor()

PySide6.QtMultimedia.QCamera.zoomFactorChanged(arg__1)
Parameters

arg__1 – float

PySide6.QtMultimedia.QCamera.zoomTo(zoom, rate)
Parameters
  • zoom – float

  • rate – float

Zooms to a zoom factor factor using rate.

The rate is specified in powers of two per second. At a rate of 1 it would take 2 seconds to go from a zoom factor of 1 to 4.

Note

Using a specific rate is not supported on all cameras. If not supported, zooming will happen as fast as possible.