QCamera

The QCamera class provides interface for system camera devices. More

Inheritance diagram of PySide6.QtMultimedia.QCamera

Synopsis

Functions

Slots

Signals

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.

cameras = QMediaDevices.videoInputs()
for cameraDevice in cameras:
    if (cameraDevice.description() == "mycamera")
        camera = 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.

Construct a QCamera from a camera description cameraDevice and parent.

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

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

PySide6.QtMultimedia.QCameraFormat

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

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

PySide6.QtCore.QPointF

This property represents the position of the custom focus point, in relative frame coordinates: QPointF (0,0) points to the left top frame point, QPointF (0.5,0.5) points to the frame center.

The custom focus point property is used only in FocusPointCustom focus mode.

You can check whether custom focus points are supported by querying supportedFeatures() with the Feature. CustomFocusPoint flag.

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

Error

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

  • errorString – str

PySide6.QtMultimedia.QCamera.errorString()
Return type

str

PySide6.QtMultimedia.QCamera.exposureCompensation()
Return type

float

This property holds Exposure compensation in EV units..

Exposure compensation property allows to adjust the automatically calculated exposure.

PySide6.QtMultimedia.QCamera.exposureCompensationChanged(arg__1)
Parameters

arg__1 – float

PySide6.QtMultimedia.QCamera.exposureMode()
Return type

ExposureMode

This property holds The exposure mode being used..

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

float

This property holds Camera’s exposure time in seconds..

PySide6.QtMultimedia.QCamera.exposureTimeChanged(speed)
Parameters

speed – float

PySide6.QtMultimedia.QCamera.flashMode()
Return type

FlashMode

This property holds The flash mode being used..

Enables a certain flash mode if the camera has a flash.

See also

FlashMode isFlashModeSupported isFlashReady

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

arg__1 – bool

PySide6.QtMultimedia.QCamera.focusDistance()
Return type

float

This property return an approximate focus distance of the camera. The value reported is between 0 and 1, 0 being the closest possible focus distance, 1 being as far away as possible. Note that 1 is often, but not always infinity.

Setting the focus distance will be ignored unless the focus mode is set to FocusModeManual .

PySide6.QtMultimedia.QCamera.focusDistanceChanged(arg__1)
Parameters

arg__1 – float

PySide6.QtMultimedia.QCamera.focusMode()
Return type

FocusMode

This property holds the current camera focus mode..

Sets up different focus modes for the camera. All auto focus modes will focus continuously. Locking the focus is possible by setting the focus mode to FocusModeManual . This will keep the current focus and stop any automatic focusing.

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

PySide6.QtCore.QPointF

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

bool

Describes whether 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

This property holds Indicates if the flash is charged and ready to use..

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

This property holds The sensor ISO sensitivity..

Describes the ISO sensitivity currently used by the camera.

PySide6.QtMultimedia.QCamera.isoSensitivityChanged(arg__1)
Parameters

arg__1 – int

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

This property Describes a manually set ISO sensitivity.

Setting this property to -1 (the default), implies that the camera automatically adjusts the ISO sensitivity.

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

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

PySide6.QtMultimedia.QCamera.minimumZoomFactorChanged(arg__1)
Parameters

arg__1 – float

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

active – bool

Describes whether the camera is currently active.

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

PySide6.QtMultimedia.QCamera.setCameraFormat(format)
Parameters

formatPySide6.QtMultimedia.QCameraFormat

PySide6.QtMultimedia.QCamera.setColorTemperature(colorTemperature)
Parameters

colorTemperature – int

PySide6.QtMultimedia.QCamera.setCustomFocusPoint(point)
Parameters

pointPySide6.QtCore.QPointF

This property represents the position of the custom focus point, in relative frame coordinates: QPointF (0,0) points to the left top frame point, QPointF (0.5,0.5) points to the frame center.

The custom focus point property is used only in FocusPointCustom focus mode.

You can check whether custom focus points are supported by querying supportedFeatures() with the Feature. CustomFocusPoint flag.

PySide6.QtMultimedia.QCamera.setExposureCompensation(ev)
Parameters

ev – float

This property holds Exposure compensation in EV units..

Exposure compensation property allows to adjust the automatically calculated exposure.

PySide6.QtMultimedia.QCamera.setExposureMode(mode)
Parameters

modeExposureMode

This property holds The exposure mode being used..

PySide6.QtMultimedia.QCamera.setFlashMode(mode)
Parameters

modeFlashMode

This property holds The flash mode being used..

Enables a certain flash mode if the camera has a flash.

See also

FlashMode isFlashModeSupported isFlashReady

PySide6.QtMultimedia.QCamera.setFocusDistance(d)
Parameters

d – float

This property return an approximate focus distance of the camera. The value reported is between 0 and 1, 0 being the closest possible focus distance, 1 being as far away as possible. Note that 1 is often, but not always infinity.

Setting the focus distance will be ignored unless the focus mode is set to FocusModeManual .

PySide6.QtMultimedia.QCamera.setFocusMode(mode)
Parameters

modeFocusMode

This property holds the current camera focus mode..

Sets up different focus modes for the camera. All auto focus modes will focus continuously. Locking the focus is possible by setting the focus mode to FocusModeManual . This will keep the current focus and stop any automatic focusing.

PySide6.QtMultimedia.QCamera.setManualExposureTime(seconds)
Parameters

seconds – float

Set the manual exposure time to seconds

PySide6.QtMultimedia.QCamera.setManualIsoSensitivity(iso)
Parameters

iso – int

This property Describes a manually set ISO sensitivity.

Setting this property to -1 (the default), implies that the camera automatically adjusts the ISO sensitivity.

PySide6.QtMultimedia.QCamera.setTorchMode(mode)
Parameters

modeTorchMode

This property holds The torch mode being used..

A torch is a continuous source of light. It can be used during video recording in low light conditions. Enabling torch mode will usually override any currently set flash mode.

See also

TorchMode isTorchModeSupported flashMode

PySide6.QtMultimedia.QCamera.setWhiteBalanceMode(mode)
Parameters

modeWhiteBalanceMode

PySide6.QtMultimedia.QCamera.setZoomFactor(factor)
Parameters

factor – float

This property holds The current zoom factor..

Gets or sets the current zoom factor. Values will be clamped between minimumZoomFactor and maximumZoomFactor .

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

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

TorchMode

This property holds The torch mode being used..

A torch is a continuous source of light. It can be used during video recording in low light conditions. Enabling torch mode will usually override any currently set flash mode.

See also

TorchMode isTorchModeSupported flashMode

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

WhiteBalanceMode

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

float

This property holds The current zoom factor..

Gets or sets the current zoom factor. Values will be clamped between minimumZoomFactor and maximumZoomFactor .

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.