QCamera¶
Synopsis¶
Functions¶
def
captureMode
()def
error
()def
errorString
()def
exposure
()def
focus
()def
imageProcessing
()def
isCaptureModeSupported
(mode)def
lockStatus
()def
lockStatus
(lock)def
requestedLocks
()def
setViewfinder
(surface)def
setViewfinderSettings
(settings)def
state
()def
status
()def
supportedLocks
()def
supportedViewfinderFrameRateRanges
([settings=QCameraViewfinderSettings()])def
supportedViewfinderPixelFormats
([settings=QCameraViewfinderSettings()])def
supportedViewfinderResolutions
([settings=QCameraViewfinderSettings()])def
supportedViewfinderSettings
([settings=QCameraViewfinderSettings()])def
viewfinderSettings
()
Slots¶
def
load
()def
searchAndLock
()def
searchAndLock
(locks)def
setCaptureMode
(mode)def
start
()def
stop
()def
unload
()def
unlock
()def
unlock
(locks)
Signals¶
def
captureModeChanged
(arg__1)def
error
(arg__1)def
errorOccurred
(arg__1)def
lockFailed
()def
lockStatusChanged
(lock, status, reason)def
lockStatusChanged
(status, reason)def
locked
()def
stateChanged
(state)def
statusChanged
(status)
Static functions¶
def
availableDevices
()def
deviceDescription
(device)
Detailed Description¶
QCamera
can be used withQCameraViewfinder
for viewfinder display,QMediaRecorder
for video recording andQCameraImageCapture
for image taking.You can use
QCameraInfo
to list available cameras and choose which one to use.const QList<QCameraInfo> cameras = QCameraInfo::availableCameras(); for (const QCameraInfo &cameraInfo : cameras) { if (cameraInfo.deviceName() == "mycamera") camera = new QCamera(cameraInfo); }See the camera overview for more information.
- class PySide2.QtMultimedia.QCamera(position[, parent=None])¶
PySide2.QtMultimedia.QCamera([parent=None])
PySide2.QtMultimedia.QCamera(deviceName[, parent=None])
PySide2.QtMultimedia.QCamera(cameraInfo[, parent=None])
- param parent:
- param cameraInfo:
- param deviceName:
- param position:
Construct a
QCamera
which uses a hardware camera located a the specifiedposition
.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 ifposition
isUnspecifiedPosition
, the default camera is used.Construct a
QCamera
with aparent
.
- PySide2.QtMultimedia.QCamera.Status¶
This enum holds the current status of the camera.
Constant
Description
QCamera.ActiveStatus
The camera has been started and can produce data. The viewfinder displays video frames in active state. Depending on backend, changing some camera settings like capture mode, codecs or resolution in
ActiveState
may lead to changing the camera status to and while the settings are applied and back to when the camera is ready.QCamera.StartingStatus
The camera is starting in result of state transition to
ActiveState
. The camera service is not ready to capture yet.QCamera.StoppingStatus
The camera is stopping in result of state transition from
ActiveState
toLoadedState
orUnloadedState
.QCamera.StandbyStatus
The camera is in the power saving standby mode. The camera may come to the standby mode after some time of inactivity in the
LoadedState
state.QCamera.LoadedStatus
The camera is loaded and ready to be configured. This status indicates the camera device is opened and it’s possible to query for supported image and video capture settings, like resolution, framerate and codecs.
QCamera.LoadingStatus
The camera device loading in result of state transition from
UnloadedState
toLoadedState
orActiveState
.QCamera.UnloadingStatus
The camera device is unloading in result of state transition from
LoadedState
orActiveState
toUnloadedState
.QCamera.UnloadedStatus
The initial camera status, with camera not loaded. The camera capabilities including supported capture settings may be unknown.
QCamera.UnavailableStatus
The camera or camera backend is not available.
- PySide2.QtMultimedia.QCamera.State¶
This enum holds the current state of the camera.
Constant
Description
QCamera.UnloadedState
The initial camera state, with camera not loaded. The camera capabilities, except supported capture modes, are unknown. While the supported settings are unknown in this state, it’s allowed to set the camera capture settings like codec, resolution, or frame rate.
QCamera.LoadedState
The camera is loaded and ready to be configured. In this state it’s allowed to query camera capabilities, set capture resolution, codecs, etc. The viewfinder is not active in the loaded state. The camera consumes power in the loaded state.
QCamera.ActiveState
In the active state as soon as camera is started the viewfinder displays video frames and the camera is ready for capture.
- PySide2.QtMultimedia.QCamera.CaptureMode¶
This enum holds the capture mode of the camera.
Constant
Description
QCamera.CaptureViewfinder
Camera is only configured to display viewfinder.
QCamera.CaptureStillImage
Camera is configured for still frames capture.
QCamera.CaptureVideo
Camera is configured for video capture.
- PySide2.QtMultimedia.QCamera.Error¶
This enum holds the last error code.
Constant
Description
QCamera.NoError
No errors have occurred.
QCamera.CameraError
An error has occurred.
QCamera.InvalidRequestError
System resource doesn’t support requested functionality.
QCamera.ServiceMissingError
No camera service available.
QCamera.NotSupportedFeatureError
The feature is not supported.
- PySide2.QtMultimedia.QCamera.LockStatus¶
This enum holds the overall status for all the requested camera locks.
Constant
Description
QCamera.Unlocked
The application is not interested in camera settings value. The camera may keep this parameter without changes, this is common with camera focus, or adjust exposure and white balance constantly to keep the viewfinder image nice.
QCamera.Searching
The application has requested the camera focus, exposure or white balance lock with
searchAndLock()
. This state indicates the camera is focusing or calculating exposure and white balance.QCamera.Locked
The camera focus, exposure or white balance is locked. The camera is ready to capture, application may check the exposure stays the same, parameters. The
Locked
status usually means the requested parameter except in the cases when the parameter is requested to be constantly updated. For example, in continuous focusing mode, the focus is considered locked as long as the object is in focus, even while the actual focusing distance may be constantly changing.
- PySide2.QtMultimedia.QCamera.LockChangeReason¶
This enum holds the reason why the camera lock status changed.
Constant
Description
QCamera.UserRequest
The lock status changed in result of user request, usually to unlock camera settings.
QCamera.LockAcquired
The lock status successfuly changed to
Locked
.QCamera.LockFailed
The camera failed to acquire the requested lock in result of autofocus failure, exposure out of supported range, etc.
QCamera.LockLost
The camera is not able to maintain the requested lock any more. Lock status is changed to
Unlocked
.QCamera.LockTemporaryLost
The lock is lost, but the camera is working hard to reacquire it. This value may be used in continuous focusing mode, when the camera loses the focus, the focus lock state is changed to Qcamera::Searching with reason.
- PySide2.QtMultimedia.QCamera.LockType¶
This enum holds the camera lock type.
Constant
Description
QCamera.NoLock
QCamera.LockExposure
Lock camera exposure.
QCamera.LockWhiteBalance
Lock the white balance.
QCamera.LockFocus
Lock camera focus.
- PySide2.QtMultimedia.QCamera.Position¶
This enum specifies the physical position of the camera on the system hardware.
Constant
Description
QCamera.UnspecifiedPosition
The camera position is unspecified or unknown.
QCamera.BackFace
The camera is on the back face of the system hardware. For example on a mobile device, it means it is on the opposite side to that of the screen.
QCamera.FrontFace
The camera is on the front face of the system hardware. For example on a mobile device, it means it is on the same side as that of the screen. Viewfinder frames of front-facing cameras are mirrored horizontally, so the users can see themselves as looking into a mirror. Captured images or videos are not mirrored.
See also
- static PySide2.QtMultimedia.QCamera.availableDevices()¶
- Return type:
Note
This function is deprecated.
Returns a list of camera device’s available from the default service provider.
See also
- PySide2.QtMultimedia.QCamera.captureMode()¶
- Return type:
CaptureModes
The type of media (video or still images), the camera is configured to capture.
It’s allowed to change capture mode in any camera state, but if the camera is currently active, chaging capture mode is likely to lead to camera status chaged to
LoadedStatus
,LoadingStatus
, and when the camera is ready toActiveStatus
.
- PySide2.QtMultimedia.QCamera.captureModeChanged(arg__1)¶
- Parameters:
arg__1 –
CaptureModes
- static PySide2.QtMultimedia.QCamera.deviceDescription(device)¶
- Parameters:
device –
PySide2.QtCore.QByteArray
- Return type:
str
Note
This function is deprecated.
Returns the description of the
device
.See also
- PySide2.QtMultimedia.QCamera.error(arg__1)
- Parameters:
arg__1 –
Error
- PySide2.QtMultimedia.QCamera.errorString()¶
- Return type:
str
Returns a string describing a camera’s error state.
- PySide2.QtMultimedia.QCamera.exposure()¶
- Return type:
Returns the camera exposure control object.
- PySide2.QtMultimedia.QCamera.focus()¶
- Return type:
Returns the camera focus control object.
- PySide2.QtMultimedia.QCamera.imageProcessing()¶
- Return type:
Returns the camera image processing control object.
- PySide2.QtMultimedia.QCamera.isCaptureModeSupported(mode)¶
- Parameters:
mode –
CaptureModes
- Return type:
bool
Returns true if the capture
mode
is suported.
- PySide2.QtMultimedia.QCamera.load()¶
Opens the camera device. The camera state is changed to
LoadedState
.It’s not necessary to explicitly load the camera, unless the application needs to read the supported camera settings and change the default values according to the camera capabilities.
In all the other cases, it’s possible to start the camera directly from the unloaded state.
/sa
UnloadedState
- PySide2.QtMultimedia.QCamera.lockFailed()¶
- PySide2.QtMultimedia.QCamera.lockStatus()¶
- Return type:
This property holds The overall status for all the requested camera locks..
- PySide2.QtMultimedia.QCamera.lockStatus(lock)
- Parameters:
lock –
LockType
- Return type:
Returns the lock status for a given
lockType
.
- PySide2.QtMultimedia.QCamera.lockStatusChanged(status, reason)¶
- Parameters:
status –
LockStatus
reason –
LockChangeReason
- PySide2.QtMultimedia.QCamera.lockStatusChanged(lock, status, reason)
- Parameters:
lock –
LockType
status –
LockStatus
reason –
LockChangeReason
- PySide2.QtMultimedia.QCamera.locked()¶
- PySide2.QtMultimedia.QCamera.requestedLocks()¶
- Return type:
LockTypes
Returns the requested lock types.
- PySide2.QtMultimedia.QCamera.searchAndLock()¶
Lock all the supported camera settings.
- PySide2.QtMultimedia.QCamera.searchAndLock(locks)
- Parameters:
locks –
LockTypes
Locks the camera settings with the requested
locks
, including focusing in the single autofocus mode, exposure and white balance if the exposure and white balance modes are not manual.The camera settings are usually locked before taking one or multiple still images, in responce to the shutter button being half pressed.
The
locked()
signal is emitted when camera settings are successfully locked, otherwiselockFailed()
is emitted.QCamera
also emitslockStatusChanged
(LockType
,LockStatus
) on individual lock status changes andlockStatusChanged
(LockStatus
) signal on composite status changes.Locking serves two roles: it initializes calculation of automatic parameter (focusing, calculating the correct exposure and white balance) and allows to keep some or all of those parameters during number of shots.
If the camera doesn’t support keeping one of parameters between shots, the related lock state changes to
Unlocked
.It’s also acceptable to relock already locked settings, depending on the lock parameter this initiates new focusing, exposure or white balance calculation.
- PySide2.QtMultimedia.QCamera.setCaptureMode(mode)¶
- Parameters:
mode –
CaptureModes
The type of media (video or still images), the camera is configured to capture.
It’s allowed to change capture mode in any camera state, but if the camera is currently active, chaging capture mode is likely to lead to camera status chaged to
LoadedStatus
,LoadingStatus
, and when the camera is ready toActiveStatus
.
- PySide2.QtMultimedia.QCamera.setViewfinder(surface)¶
- Parameters:
Sets a video
surface
as the viewfinder of a camera.If a viewfinder has already been set on the camera the new surface will replace it.
- PySide2.QtMultimedia.QCamera.setViewfinderSettings(settings)¶
- Parameters:
Sets the viewfinder
settings
.If some parameters are not specified, or null settings are passed, the camera will choose default values.
If the camera is used to capture videos or images, the viewfinder settings might be ignored if they conflict with the capture settings. You can check the actual viewfinder settings once the camera is in the
QCamera::ActiveStatus
status.Changing the viewfinder settings while the camera is in the
ActiveState
state may cause the camera to be restarted.See also
viewfinderSettings()
supportedViewfinderResolutions()
supportedViewfinderFrameRateRanges()
supportedViewfinderPixelFormats()
- PySide2.QtMultimedia.QCamera.start()¶
Starts the camera.
State is changed to
ActiveState
if camera is started successfully, otherwiseerrorOccurred()
signal is emitted.While the camera state is changed to
ActiveState
, starting the camera service can be asynchronous with the actual status reported withstatus
property.
- PySide2.QtMultimedia.QCamera.state()¶
- Return type:
This property holds The current state of the camera object..
- PySide2.QtMultimedia.QCamera.status()¶
- Return type:
This property holds The current status of the camera object..
- PySide2.QtMultimedia.QCamera.stop()¶
Stops the camera. The camera state is changed from
ActiveState
toLoadedState
.In this state, the camera still consumes power.
See also
unload()
UnloadedState
- PySide2.QtMultimedia.QCamera.supportedLocks()¶
- Return type:
LockTypes
Returns the lock types that the camera supports.
- PySide2.QtMultimedia.QCamera.supportedViewfinderFrameRateRanges([settings=QCameraViewfinderSettings()])¶
- Parameters:
- Return type:
Returns a list of supported viewfinder frame rate ranges.
This is a convenience function which retrieves unique frame rate ranges from the supported settings.
If non null viewfinder
settings
are passed, the returned list is reduced to frame rate ranges supported with partialsettings
applied.The camera must be loaded before calling this function, otherwise the returned list is empty.
See also
minimumFrameRate()
maximumFrameRate()
setViewfinderSettings()
- PySide2.QtMultimedia.QCamera.supportedViewfinderPixelFormats([settings=QCameraViewfinderSettings()])¶
- Parameters:
- Return type:
Returns a list of supported viewfinder pixel formats.
This is a convenience function which retrieves unique pixel formats from the supported settings.
If non null viewfinder
settings
are passed, the returned list is reduced to pixel formats supported with partialsettings
applied.The camera must be loaded before calling this function, otherwise the returned list is empty.
See also
pixelFormat()
setViewfinderSettings()
- PySide2.QtMultimedia.QCamera.supportedViewfinderResolutions([settings=QCameraViewfinderSettings()])¶
- Parameters:
- Return type:
Returns a list of supported viewfinder resolutions.
This is a convenience function which retrieves unique resolutions from the supported settings.
If non null viewfinder
settings
are passed, the returned list is reduced to resolutions supported with partialsettings
applied.The camera must be loaded before calling this function, otherwise the returned list is empty.
See also
resolution()
setViewfinderSettings()
- PySide2.QtMultimedia.QCamera.supportedViewfinderSettings([settings=QCameraViewfinderSettings()])¶
- Parameters:
- Return type:
Returns a list of supported viewfinder settings.
The list is ordered by preference; preferred settings come first.
The optional
settings
argument can be used to conveniently filter the results. Ifsettings
is non null, the returned list is reduced to settings matching the given partialsettings
.The status of the camera must be
LoadedStatus
before calling this function, otherwise the returned list is empty.See also
setViewfinderSettings()
supportedViewfinderResolutions()
supportedViewfinderFrameRateRanges()
supportedViewfinderPixelFormats()
- PySide2.QtMultimedia.QCamera.unload()¶
Closes the camera device and deallocates the related resources. The camera state is changed to
UnloadedState
.
- PySide2.QtMultimedia.QCamera.unlock()¶
Unlock all the requested camera locks.
- PySide2.QtMultimedia.QCamera.unlock(locks)
- Parameters:
locks –
LockTypes
Unlocks the camera settings specified with
locks
or cancel the current locking if one is active.
- PySide2.QtMultimedia.QCamera.viewfinderSettings()¶
- Return type:
Returns the viewfinder settings being used by the camera.
Settings may change when the camera is started, for example if the viewfinder settings are undefined or if unsupported values are set.
If viewfinder settings are not supported by the camera, it always returns a null
QCameraViewfinderSettings
object.See also
setViewfinderSettings()
© 2022 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.