PySide6.QtMultimedia.QCamera¶
- class QCamera¶
- The - QCameraclass provides interface for system camera devices. More…- Synopsis¶- Properties¶
- exposureCompensationᅟ- Exposure compensation in EV units
- exposureModeᅟ- Exposure mode being used
- exposureTimeᅟ- Camera’s exposure time in seconds
- flashModeᅟ- Flash mode being used
- flashReadyᅟ- Indicates if the flash is charged and ready to use
- focusModeᅟ- The current camera focus mode
- isoSensitivityᅟ- Sensor ISO sensitivity
- manualIsoSensitivityᅟ- Describes a manually set ISO sensitivity
- torchModeᅟ- Torch mode being used
- zoomFactorᅟ- Current zoom factor
 - Methods¶- def - __init__()
- def - cameraDevice()
- def - cameraFormat()
- def - captureSession()
- def - error()
- def - errorString()
- def - exposureMode()
- def - exposureTime()
- def - flashMode()
- def - focusDistance()
- def - focusMode()
- def - focusPoint()
- def - isActive()
- def - isAvailable()
- def - isFlashReady()
- def - isoSensitivity()
- def - setFocusMode()
- def - setZoomFactor()
- def - torchMode()
- def - zoomFactor()
 - Slots¶- def - setActive()
- def - setFlashMode()
- def - setTorchMode()
- def - start()
- def - stop()
- def - zoomTo()
 - Signals¶- def - activeChanged()
- def - errorChanged()
- def - errorOccurred()
- def - flashReady()
- def - hueChanged()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - QCameracan be used within a- QMediaCaptureSessionfor video recording and image taking.- You can use - QCameraDeviceto 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, - QCameralets 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 Error¶
- This enum holds the last error code. - Constant - Description - QCamera.NoError - No errors have occurred. - QCamera.CameraError - An error has occurred. 
 - class 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 - Camera lens focus distance is locked according to - focusDistance.- Added in version 6.1. 
 - class FlashMode¶
- Constant - Description - QCamera.FlashOff - Flash is Off. - QCamera.FlashOn - Flash is On. - QCamera.FlashAuto - Automatic flash. - Added in version 6.1. 
 - class TorchMode¶
- Constant - Description - QCamera.TorchOff - Torch is Off. - QCamera.TorchOn - Torch is On. - QCamera.TorchAuto - Automatic torch. - Added in version 6.1. 
 - class 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 - Added in version 6.1. 
 - class 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. - Added in version 6.1. 
 - class Feature¶
- (inherits - enum.Flag) 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 - focusDistanceproperty.- Added in version 6.1. 
 - Note - Properties can be used directly when - from __feature__ import true_propertyis used or via accessor functions otherwise.- property activeᅟ: bool¶
 - Describes whether the camera is currently active. - Access functions:
- Signal - activeChanged()
 
 - property cameraDeviceᅟ: QCameraDevice¶
 - Returns the - QCameraDeviceobject associated with this camera.- Access functions:
 - property cameraFormatᅟ: QCameraFormat¶
 - Returns the camera format currently used by the camera. - Note - When using the FFMPEG backend on an Android target device if you request YUV420P format, you will receive either a fully planar 4:2:0 YUV420P or a semi-planar NV12/NV21. This depends on the codec implemented by the device OEM. - See also - Access functions:
 - property colorTemperatureᅟ: int¶
 - Returns the current color temperature if the current white balance mode is - WhiteBalanceManual. For other modes the return value is undefined.- Access functions:
 - 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 - FocusPointCustomfocus mode.- You can check whether custom focus points are supported by querying - supportedFeatures()with the Feature.- CustomFocusPointflag.- Access functions:
 - property errorᅟ: QCamera.Error¶
 - Returns the error state of the camera. - Access functions:
- Signal - errorChanged()
 
 - property errorStringᅟ: str¶
 - Returns a human readable string describing a camera’s error state. - Access functions:
- Signal - errorChanged()
 
 - property exposureCompensationᅟ: float¶
 - This property holds Exposure compensation in EV units.. - Exposure compensation property allows to adjust the automatically calculated exposure. - Access functions:
 - property exposureModeᅟ: QCamera.ExposureMode¶
 - This property holds The exposure mode being used.. - See also - Access functions:
 - property exposureTimeᅟ: float¶
 - This property holds Camera’s exposure time in seconds.. - Access functions:
 - property flashModeᅟ: QCamera.FlashMode¶
 - This property holds The flash mode being used.. - Enables a certain flash mode if the camera has a flash. - See also - Access functions:
 - property flashReadyᅟ: bool¶
 - This property holds Indicates if the flash is charged and ready to use.. - Access functions:
- Signal - flashReady()
 
 - property focusDistanceᅟ: float¶
 - This property defines the lens focus distance when the camera device works in manual focus mode. Valid values range from 0 to 1, where 0 is the closest possible focus distance, and 1 is the farthest. The farthest point is typically at infinity, but this may not be the case for all devices. - This property is applied to the device only when - focusModeis set to- FocusModeManual, and- supportedFeaturesincludes the- FocusDistanceflag.- If you assign a value to this property while - focusModeis not set to Camera.FocusModeManual, the property stores the value but does not affect the device until Camera.FocusModeManual is active.- Assigning a value outside the valid range [0, 1] has no effect on this property. - If - supportedFeaturesdoes not include the- FocusDistanceflag, any attempt to set this property is ignored.- This property will not be updated by the camera when it is in an automatic focus mode. - The default value is 1. - Access functions:
 - property focusModeᅟ: QCamera.FocusMode¶
 - This property holds the current camera focus mode.. - This property holds the value that controls focus mode for the camera device. In all autofocus modes, the camera device keeps focusing continuously. - To check whether the camera device supports a particular focus mode, pass the corresponding - FocusModevalue to the- isFocusModeSupportedfunction as a parameter. The function returns false if the focus mode value is not supported. Assigning this mode to the focusMode property has no effect.- If you set the focusMode property to Camera.FocusModeManual, the lens locks to the focus according to - focusDistance.- See also - Access functions:
 - Returns the point currently used by the auto focus system to focus onto. - Access functions:
- Signal - focusPointChanged()
 
 - property isoSensitivityᅟ: int¶
 - This property holds The sensor ISO sensitivity.. - Describes the ISO sensitivity currently used by the camera. - Access functions:
 - property manualExposureTimeᅟ: float¶
 - Set the manual exposure time to - seconds- Access functions:
 - property manualIsoSensitivityᅟ: 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. - Access functions:
 - property maximumZoomFactorᅟ: float¶
 - Returns the maximum zoom factor. - This will be - 1.0on cameras that do not support zooming.- Access functions:
 - property minimumZoomFactorᅟ: float¶
 - Returns the minimum zoom factor. - This will be - 1.0on cameras that do not support zooming.- Access functions:
 - property supportedFeaturesᅟ: Combination of QCamera.Feature¶
 - Returns the features supported by this camera. - See also - Access functions:
 - property torchModeᅟ: QCamera.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 - Access functions:
 - property whiteBalanceModeᅟ: QCamera.WhiteBalanceMode¶
 - Returns the white balance mode being used. - Access functions:
 - property zoomFactorᅟ: float¶
 - This property holds The current zoom factor.. - Gets or sets the current zoom factor. Values will be clamped between - minimumZoomFactorand- maximumZoomFactor.- Access functions:
 - Construct a - QCamerawith a- parent.- Selects the default camera on the system if more than one camera is available. - Construct a - QCamerawhich 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 - positionor if- positionis- UnspecifiedPosition, the default camera is used.- __init__(cameraDevice[, parent=None])
- Parameters:
- cameraDevice – - QCameraDevice
- parent – - QObject
 
 
 - Construct a - QCamerafrom a camera description- cameraDeviceand- parent.- activeChanged(arg__1)¶
- Parameters:
- arg__1 – bool 
 
 - Notification signal of property - activeᅟ.- brightnessChanged()¶
 - cameraDevice()¶
- Return type:
 - See also 
 - Getter of property - cameraDeviceᅟ.- cameraDeviceChanged()¶
 - Notification signal of property - cameraDeviceᅟ.- cameraFormat()¶
- Return type:
 - See also 
 - Getter of property - cameraFormatᅟ.- cameraFormatChanged()¶
 - Notification signal of property - cameraFormatᅟ.- captureSession()¶
- Return type:
 
 - 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.- colorTemperature()¶
- Return type:
- int 
 - See also 
 - Getter of property - colorTemperatureᅟ.- colorTemperatureChanged()¶
 - Notification signal of property - colorTemperatureᅟ.- contrastChanged()¶
 - customFocusPoint()¶
- Return type:
 - See also 
 - Getter of property - customFocusPointᅟ.- customFocusPointChanged()¶
 - Notification signal of property - customFocusPointᅟ.- Getter of property - errorᅟ.- errorChanged()¶
 - Notification signal of property - errorᅟ.- This signal is emitted when error state changes to - error. A description of the error is provided as- errorString.- errorString()¶
- Return type:
- str 
 
 - Getter of property - errorStringᅟ.- exposureCompensation()¶
- Return type:
- float 
 - See also 
 - Getter of property - exposureCompensationᅟ.- exposureCompensationChanged(value)¶
- Parameters:
- value – float 
 
 - Signal emitted when the exposure compensation changes to - value.- Notification signal of property - exposureCompensationᅟ.- exposureMode()¶
- Return type:
 - See also 
 - Getter of property - exposureModeᅟ.- exposureModeChanged()¶
 - Notification signal of property - exposureModeᅟ.- exposureTime()¶
- Return type:
- float 
 
 - Returns the current exposure time in seconds. - Getter of property - exposureTimeᅟ.- exposureTimeChanged(speed)¶
- Parameters:
- speed – float 
 
 - Signals that a camera’s exposure - speedhas changed.- Notification signal of property - exposureTimeᅟ.- flashMode()¶
- Return type:
 - See also 
 - Getter of property - flashModeᅟ.- flashModeChanged()¶
 - Notification signal of property - flashModeᅟ.- flashReady(ready)¶
- Parameters:
- ready – bool 
 
 - Signal the flash - readystatus has changed.- Notification signal of property - flashReadyᅟ.- focusDistance()¶
- Return type:
- float 
 - See also 
 - Getter of property - focusDistanceᅟ.- focusDistanceChanged(arg__1)¶
- Parameters:
- arg__1 – float 
 
 - Notification signal of property - focusDistanceᅟ.- focusMode()¶
- Return type:
 - See also 
 - Getter of property - focusModeᅟ.- focusModeChanged()¶
 - Signals when the - focusModechanges.- Notification signal of property - focusModeᅟ.- Getter of property - focusPointᅟ.- focusPointChanged()¶
 - Notification signal of property - focusPointᅟ.- hueChanged()¶
 - isActive()¶
- Return type:
- bool 
 
 - Returns true if the camera is currently active. - Getter of property - activeᅟ.- isAvailable()¶
- Return type:
- bool 
 
 - Returns true if the camera can be used. - isExposureModeSupported(mode)¶
- Parameters:
- mode – - ExposureMode
- Return type:
- bool 
 
 - Returns true if the exposure - modeis supported.- Returns true if the flash - modeis supported.- isFlashReady()¶
- Return type:
- bool 
 
 - Returns true if flash is charged. - Getter of property - flashReadyᅟ.- Returns true if the focus - modeis supported by the camera.- If - FocusModeManualis reported as supported, the feature- FocusDistanceis implied to be supported as well.- Returns true if the torch - modeis supported.- isWhiteBalanceModeSupported(mode)¶
- Parameters:
- mode – - WhiteBalanceMode
- Return type:
- bool 
 
 - Returns true if the white balance - modeis supported.- isoSensitivity()¶
- Return type:
- int 
 
 - Getter of property - isoSensitivityᅟ.- isoSensitivityChanged(value)¶
- Parameters:
- value – int 
 
 - Signal emitted when sensitivity changes to - value.- Notification signal of property - isoSensitivityᅟ.- manualExposureTime()¶
- Return type:
- float 
 
 - Returns the manual exposure time in seconds, or -1 if the camera is using automatic exposure times. - See also - Getter of property - manualExposureTimeᅟ.- manualExposureTimeChanged(speed)¶
- Parameters:
- speed – float 
 
 - Notification signal of property - manualExposureTimeᅟ.- manualIsoSensitivity()¶
- Return type:
- int 
 - See also 
 - Getter of property - manualIsoSensitivityᅟ.- manualIsoSensitivityChanged(arg__1)¶
- Parameters:
- arg__1 – int 
 
 - Notification signal of property - manualIsoSensitivityᅟ.- maximumExposureTime()¶
- Return type:
- float 
 
 - The maximal exposure time in seconds. - maximumIsoSensitivity()¶
- Return type:
- int 
 
 - Returns the maximum ISO sensitivity supported by the camera. - maximumZoomFactor()¶
- Return type:
- float 
 
 - Getter of property - maximumZoomFactorᅟ.- maximumZoomFactorChanged(arg__1)¶
- Parameters:
- arg__1 – float 
 
 - Notification signal of property - maximumZoomFactorᅟ.- minimumExposureTime()¶
- Return type:
- float 
 
 - The minimal exposure time in seconds. - minimumIsoSensitivity()¶
- Return type:
- int 
 
 - Returns the minimum ISO sensitivity supported by the camera. - minimumZoomFactor()¶
- Return type:
- float 
 
 - Getter of property - minimumZoomFactorᅟ.- minimumZoomFactorChanged(arg__1)¶
- Parameters:
- arg__1 – float 
 
 - Notification signal of property - minimumZoomFactorᅟ.- saturationChanged()¶
 - setActive(active)¶
- Parameters:
- active – bool 
 
 - Turns the camera on if - activeis- true, or off if it’s- false.- See also - Setter of property - activeᅟ.- setAutoExposureTime()¶
 - Use automatically calculated exposure time - setAutoIsoSensitivity()¶
 - Turn on auto sensitivity - setCameraDevice(cameraDevice)¶
- Parameters:
- cameraDevice – - QCameraDevice
 
 - Connects the camera object to the physical camera device described by - cameraDevice. Using a default constructed- QCameraDeviceobject as- cameraDevicewill connect the camera to the system default camera device.- When switching camera devices, the - QCamera‘s capabilities are updated. Additionally, the- QCamera‘s control properties (such as- focusMode,- flashMode,- focusDistance,- zoomFactor) are updated as follows:- If a property is supported on the new device, the property value is applied to the camera device. 
- If a property is supported but its range of valid values was changed, the property is clamped to the new range and applied to the camera device. 
- If the new camera device does not support a property, the property value is reset to default, and no changes are made to the camera device. 
 - See also - Setter of property - cameraDeviceᅟ.- setCameraFormat(format)¶
- Parameters:
- format – - QCameraFormat
 
 - Tells the camera to use the format described by - format. This can be used to define a specific resolution and frame rate to be used for recording and image capture.- Note - When using the FFMPEG backend on an Android target device if you request YUV420P format, you will receive either a fully planar 4:2:0 YUV420P or a semi-planar NV12/NV21. This depends on the codec implemented by the device OEM. - See also - Setter of property - cameraFormatᅟ.- 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 - WhiteBalanceManualis 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.- See also - Setter of property - colorTemperatureᅟ.- Setter of property - customFocusPointᅟ.- setExposureCompensation(ev)¶
- Parameters:
- ev – float 
 - See also 
 - Setter of property - exposureCompensationᅟ.- setExposureMode(mode)¶
- Parameters:
- mode – - ExposureMode
 - See also 
 - Setter of property - exposureModeᅟ.- Setter of property - flashModeᅟ.- setFocusDistance(d)¶
- Parameters:
- d – float 
 - See also 
 - Setter of property - focusDistanceᅟ.- Setter of property - focusModeᅟ.- setManualExposureTime(seconds)¶
- Parameters:
- seconds – float 
 - See also 
 - Setter of property - manualExposureTimeᅟ.- setManualIsoSensitivity(iso)¶
- Parameters:
- iso – int 
 - See also 
 - Setter of property - manualIsoSensitivityᅟ.- Setter of property - torchModeᅟ.- setWhiteBalanceMode(mode)¶
- Parameters:
- mode – - WhiteBalanceMode
 
 - Sets the white balance to - mode.- See also - Setter of property - whiteBalanceModeᅟ.- setZoomFactor(factor)¶
- Parameters:
- factor – float 
 
 - Zooms to a zoom factor - factorat a rate of 1 factor per second.- See also - Setter of property - zoomFactorᅟ.- start()¶
 - Starts the camera. - Same as - setActive(true).- If the camera can’t be started for some reason, the - errorOccurred()signal is emitted.- stop()¶
 - Stops the camera. Same as - setActive(false).- Getter of property - supportedFeaturesᅟ.- supportedFeaturesChanged()¶
 - Notification signal of property - supportedFeaturesᅟ.- torchMode()¶
- Return type:
 - See also 
 - Getter of property - torchModeᅟ.- torchModeChanged()¶
 - Notification signal of property - torchModeᅟ.- whiteBalanceMode()¶
- Return type:
 - See also 
 - Getter of property - whiteBalanceModeᅟ.- whiteBalanceModeChanged()¶
 - Notification signal of property - whiteBalanceModeᅟ.- zoomFactor()¶
- Return type:
- float 
 - See also 
 - Getter of property - zoomFactorᅟ.- zoomFactorChanged(arg__1)¶
- Parameters:
- arg__1 – float 
 
 - Notification signal of property - zoomFactorᅟ.- zoomTo(zoom, rate)¶
- Parameters:
- zoom – float 
- rate – float 
 
 
 - Zooms to a zoom factor - factorusing- rate.- The - rateis 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.