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
()
def
load
()
def
searchAndLock
()
def
searchAndLock
(locks)
def
setCaptureMode
(mode)
def
start
()
def
stop
()
def
unload
()
def
unlock
()
def
unlock
(locks)
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)
def
availableDevices
()
def
deviceDescription
(device)
QCameracan be used withQCameraViewfinderfor viewfinder display,QMediaRecorderfor video recording andQCameraImageCapturefor image taking.可以使用
QCameraInfoto 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); }见 摄像头概述 了解更多信息。
QCamera
(
position
[
,
parent=None
]
)
¶
QCamera([parent=None])
QCamera(deviceName[, parent=None])
QCamera(cameraInfo[, parent=None])
- param parent
QObject- param cameraInfo
- param deviceName
QByteArray- param position
Position
构造
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.
构造
QCamera
采用
parent
.
PySide2.QtMultimedia.QCamera.
Status
¶
This enum holds the current status of the camera.
|
常量 |
描述 |
|---|---|
|
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
|
|
QCamera.StartingStatus |
The camera is starting in result of state transition to
|
|
QCamera.StoppingStatus |
The camera is stopping in result of state transition from
|
|
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
|
|
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
|
|
QCamera.UnloadingStatus |
The camera device is unloading in result of state transition from
|
|
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.
|
常量 |
描述 |
|---|---|
|
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.
|
常量 |
描述 |
|---|---|
|
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.
|
常量 |
描述 |
|---|---|
|
QCamera.NoError |
没有发生错误。 |
|
QCamera.CameraError |
有发生错误。 |
|
QCamera.InvalidRequestError |
System resource doesn’t support requested functionality. |
|
QCamera.ServiceMissingError |
没有可用摄像头服务。 |
|
QCamera.NotSupportedFeatureError |
不支持特征。 |
PySide2.QtMultimedia.QCamera.
LockStatus
¶
This enum holds the overall status for all the requested camera locks.
|
常量 |
描述 |
|---|---|
|
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
|
|
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
|
PySide2.QtMultimedia.QCamera.
LockChangeReason
¶
This enum holds the reason why the camera lock status changed.
|
常量 |
描述 |
|---|---|
|
QCamera.UserRequest |
The lock status changed in result of user request, usually to unlock camera settings. |
|
QCamera.LockAcquired |
The lock status successfuly changed to
|
|
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
|
|
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.
|
常量 |
描述 |
|---|---|
|
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.
|
常量 |
描述 |
|---|---|
|
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. |
另请参阅
PySide2.QtMultimedia.QCamera.
availableDevices
(
)
¶
注意
此函数被弃用。
Returns a list of camera device’s available from the default service provider.
另请参阅
PySide2.QtMultimedia.QCamera.
captureMode
(
)
¶
CaptureModes
另请参阅
setCaptureMode()
PySide2.QtMultimedia.QCamera.
captureModeChanged
(
arg__1
)
¶
arg__1
–
CaptureModes
PySide2.QtMultimedia.QCamera.
deviceDescription
(
device
)
¶
device
–
QByteArray
unicode
注意
此函数被弃用。
Returns the description of the
device
.
PySide2.QtMultimedia.QCamera.
errorString
(
)
¶
unicode
Returns a string describing a camera’s error state.
PySide2.QtMultimedia.QCamera.
exposure
(
)
¶
QCameraExposure
Returns the camera exposure control object.
PySide2.QtMultimedia.QCamera.
focus
(
)
¶
QCameraFocus
Returns the camera focus control object.
PySide2.QtMultimedia.QCamera.
imageProcessing
(
)
¶
QCameraImageProcessing
Returns the camera image processing control object.
PySide2.QtMultimedia.QCamera.
isCaptureModeSupported
(
mode
)
¶
mode
–
CaptureModes
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
(
)
¶
Returns the status of requested camera settings locks.
PySide2.QtMultimedia.QCamera.
lockStatus
(
lock
)
¶
lock
–
LockType
Returns the lock status for a given
lockType
.
PySide2.QtMultimedia.QCamera.
lockStatusChanged
(
status
,
reason
)
¶
status
–
LockStatus
reason
–
LockChangeReason
PySide2.QtMultimedia.QCamera.
lockStatusChanged
(
lock
,
status
,
reason
)
¶
lock
–
LockType
status
–
LockStatus
reason
–
LockChangeReason
PySide2.QtMultimedia.QCamera.
locked
(
)
¶
PySide2.QtMultimedia.QCamera.
requestedLocks
(
)
¶
LockTypes
Returns the requested lock types.
PySide2.QtMultimedia.QCamera.
searchAndLock
(
)
¶
Lock all the supported camera settings.
PySide2.QtMultimedia.QCamera.
searchAndLock
(
locks
)
¶
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.
locked()
signal is emitted when camera settings are successfully locked, otherwise
lockFailed()
is emitted.
QCamera
also emits
lockStatusChanged
(
LockType
,
LockStatus
) on individual lock status changes and
lockStatusChanged
(
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
)
¶
mode
–
CaptureModes
另请参阅
captureMode()
PySide2.QtMultimedia.QCamera.
setViewfinder
(
surface
)
¶
surface
–
QAbstractVideoSurface
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
)
¶
settings
–
QCameraViewfinderSettings
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
状态。
Changing the viewfinder settings while the camera is in the
ActiveState
state may cause the camera to be restarted.
另请参阅
viewfinderSettings()
supportedViewfinderResolutions()
supportedViewfinderFrameRateRanges()
supportedViewfinderPixelFormats()
PySide2.QtMultimedia.QCamera.
start
(
)
¶
Starts the camera.
State is changed to
ActiveState
if camera is started successfully, otherwise
errorOccurred()
信号被发射。
While the camera state is changed to
ActiveState
, starting the camera service can be asynchronous with the actual status reported with
status
特性。
PySide2.QtMultimedia.QCamera.
stop
(
)
¶
Stops the camera. The camera state is changed from
ActiveState
to
LoadedState
.
In this state, the camera still consumes power.
另请参阅
unload()
UnloadedState
PySide2.QtMultimedia.QCamera.
supportedLocks
(
)
¶
LockTypes
Returns the lock types that the camera supports.
PySide2.QtMultimedia.QCamera.
supportedViewfinderFrameRateRanges
(
[
settings=QCameraViewfinderSettings()
]
)
¶
settings
–
QCameraViewfinderSettings
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 partial
settings
applied.
The camera must be loaded before calling this function, otherwise the returned list is empty.
另请参阅
minimumFrameRate()
maximumFrameRate()
setViewfinderSettings()
PySide2.QtMultimedia.QCamera.
supportedViewfinderPixelFormats
(
[
settings=QCameraViewfinderSettings()
]
)
¶
settings
–
QCameraViewfinderSettings
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 partial
settings
applied.
The camera must be loaded before calling this function, otherwise the returned list is empty.
另请参阅
pixelFormat()
setViewfinderSettings()
PySide2.QtMultimedia.QCamera.
supportedViewfinderResolutions
(
[
settings=QCameraViewfinderSettings()
]
)
¶
settings
–
QCameraViewfinderSettings
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 partial
settings
applied.
The camera must be loaded before calling this function, otherwise the returned list is empty.
另请参阅
resolution()
setViewfinderSettings()
PySide2.QtMultimedia.QCamera.
supportedViewfinderSettings
(
[
settings=QCameraViewfinderSettings()
]
)
¶
settings
–
QCameraViewfinderSettings
Returns a list of supported viewfinder settings.
The list is ordered by preference; preferred settings come first.
可选
settings
argument can be used to conveniently filter the results. If
settings
is non null, the returned list is reduced to settings matching the given partial
settings
.
The status of the camera must be
LoadedStatus
before calling this function, otherwise the returned list is empty.
另请参阅
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
)
¶
locks
–
LockTypes
Unlocks the camera settings specified with
locks
or cancel the current locking if one is active.
PySide2.QtMultimedia.QCamera.
viewfinderSettings
(
)
¶
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
对象。
另请参阅
setViewfinderSettings()