The QCamera class provides interface for system camera devices. More...
#include <QCamera>
Inherits: QMediaObject.
This class was introduced in Qt Mobility 1.1.
enum | CaptureMode { CaptureStillImage, CaptureVideo } |
enum | Error { NoError, CameraError, InvalidRequestError, ServiceMissingError, NotSupportedFeatureError } |
enum | LockChangeReason { UserRequest, LockAcquired, LockFailed, LockLost, LockTemporaryLost } |
enum | LockStatus { Unlocked, Searching, Locked } |
enum | LockType { NoLock, LockExposure, LockWhiteBalance, LockFocus } |
flags | LockTypes |
enum | State { UnloadedState, LoadedState, ActiveState } |
enum | Status { ActiveStatus, StartingStatus, StandbyStatus, LoadedStatus, ..., UnavailableStatus } |
QCamera ( QObject * parent = 0, QMediaServiceProvider * provider = QMediaServiceProvider::defaultServiceProvider() ) | |
QCamera ( const QByteArray & device, QObject * parent = 0 ) | |
~QCamera () | |
CaptureMode | captureMode () const |
Error | error () const |
QString | errorString () const |
QCameraExposure * | exposure () const |
QCameraFocus * | focus () const |
QCameraImageProcessing * | imageProcessing () const |
bool | isCaptureModeSupported ( CaptureMode mode ) const |
QCamera::LockStatus | lockStatus () const |
QCamera::LockStatus | lockStatus ( QCamera::LockType lockType ) const |
QCamera::LockTypes | requestedLocks () const |
void | setViewfinder ( QVideoWidget * viewfinder ) |
void | setViewfinder ( QGraphicsVideoItem * viewfinder ) |
void | setViewfinder ( QAbstractVideoSurface * surface ) |
State | state () const |
Status | status () const |
QCamera::LockTypes | supportedLocks () const |
virtual QtMultimediaKit::AvailabilityError | availabilityError () const |
virtual bool | isAvailable () const |
void | load () |
void | searchAndLock () |
void | searchAndLock ( QCamera::LockTypes locks ) |
void | setCaptureMode ( QCamera::CaptureMode mode ) |
void | start () |
void | stop () |
void | unload () |
void | unlock () |
void | unlock ( QCamera::LockTypes locks ) |
void | captureModeChanged ( QCamera::CaptureMode mode ) |
void | error ( QCamera::Error value ) |
void | lockFailed () |
void | lockStatusChanged ( QCamera::LockStatus status, QCamera::LockChangeReason reason ) |
void | lockStatusChanged ( QCamera::LockType lock, QCamera::LockStatus status, QCamera::LockChangeReason reason ) |
void | locked () |
void | stateChanged ( QCamera::State state ) |
void | statusChanged ( QCamera::Status status ) |
QList<QByteArray> | availableDevices () |
QString | deviceDescription ( const QByteArray & device ) |
The QCamera class provides interface for system camera devices.
QCamera can be used with QVideoWidget for viewfinder display, QMediaRecorder for video recording and QCameraImageCapture for image taking.
QMediaPlayerControl *control = qobject_cast<QMediaPlayerControl *>( mediaService->requestControl("com.nokia.Qt.QMediaPlayerControl/1.0"));
Constant | Value | Description |
---|---|---|
QCamera::CaptureStillImage | 0 | Camera is configured for still frames capture. |
QCamera::CaptureVideo | 1 | Camera is configured for video capture. |
This enum was introduced or modified in Qt Mobility 1.1.
Constant | Value | Description |
---|---|---|
QCamera::NoError | 0 | No errors have occurred. |
QCamera::CameraError | 1 | An error has occurred. |
QCamera::InvalidRequestError | 2 | System resource doesn't support requested functionality. |
QCamera::ServiceMissingError | 3 | No camera service available. |
QCamera::NotSupportedFeatureError | 4 | The feature is not supported. |
Constant | Value | Description |
---|---|---|
QCamera::UserRequest | 0 | The lock status changed in result of user request, usually to unlock camera settings. |
QCamera::LockAcquired | 1 | The lock status successfuly changed to QCamera::Locked. |
QCamera::LockFailed | 2 | The camera failed to acquire the requested lock in result of autofocus failure, exposure out of supported range, etc. |
QCamera::LockLost | 3 | The camera is not able to maintain the requested lock any more. Lock status is changed to QCamera::Unlocked. |
QCamera::LockTemporaryLost | 4 | 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 LockTemporaryLost reason. |
Constant | Value | Description |
---|---|---|
QCamera::Unlocked | 0 | 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 | 1 | The application has requested the camera focus, exposure or white balance lock with QCamera::searchAndLock(). This state indicates the camera is focusing or calculating exposure and white balance. |
QCamera::Locked | 2 | The camera focus, exposure or white balance is locked. The camera is ready to capture, application may check the exposure parameters. |
The locked state usually means the requested parameter stays the same, except of the cases when the parameter is requested to be constantly updated. For example in continuous focusing mode, the focus is considered locked as long and the object is in focus, even while the actual focusing distance may be constantly changing.
Constant | Value | Description |
---|---|---|
QCamera::NoLock | 0 | |
QCamera::LockExposure | 0x01 | Lock camera exposure. |
QCamera::LockWhiteBalance | 0x02 | Lock the white balance. |
QCamera::LockFocus | 0x04 | Lock camera focus. |
The LockTypes type is a typedef for QFlags<LockType>. It stores an OR combination of LockType values.
Constant | Value | Description |
---|---|---|
QCamera::UnloadedState | 0 | The initial camera state, with camera not loaded, the camera capabilities except of 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.
Constant | Value | Description |
---|---|---|
QCamera::LoadedState | 1 | The camera is loaded and ready to be configured. |
In the Idle state it's allowed to query camera capabilities, set capture resolution, codecs, etc.
The viewfinder is not active in the loaded state.
Constant | Value | Description |
---|---|---|
QCamera::ActiveState | 2 | In the active state as soon as camera is started the viewfinder displays video frames and the camera is ready for capture. |
Constant | Value | Description |
---|---|---|
QCamera::ActiveStatus | 6 | 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 LoadedStatus and StartingStatus while the settings are applied and back to ActiveStatus when the camera is ready.
Constant | Value | Description |
---|---|---|
QCamera::StartingStatus | 5 | The camera is starting in result of state transition to QCamera::ActiveState. The camera service is not ready to capture yet. |
QCamera::StandbyStatus | 4 | 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::LoadedState state. |
QCamera::LoadedStatus | 3 | 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 | 2 | The camera device loading in result of state transition from QCamera::UnloadedState to QCamera::LoadedState or QCamera::ActiveState. |
QCamera::UnloadedStatus | 1 | The initial camera status, with camera not loaded. The camera capabilities including supported capture settings may be unknown. |
QCamera::UnavailableStatus | 0 | The camera or camera backend is not available. |
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 QCamera::LoadedStatus, QCamera::LoadingStatus, and when the camera is ready to QCamera::ActiveStatus.
This property was introduced in Qt Mobility 1.1.
Access functions:
CaptureMode | captureMode () const |
void | setCaptureMode ( QCamera::CaptureMode mode ) |
Notifier signal:
void | captureModeChanged ( QCamera::CaptureMode mode ) |
This property holds the overall status for all the requested camera locks.
This property was introduced in Qt Mobility 1.1.
Access functions:
QCamera::LockStatus | lockStatus () const |
QCamera::LockStatus | lockStatus ( QCamera::LockType lockType ) const |
Notifier signal:
void | lockStatusChanged ( QCamera::LockStatus status, QCamera::LockChangeReason reason ) |
void | lockStatusChanged ( QCamera::LockType lock, QCamera::LockStatus status, QCamera::LockChangeReason reason ) |
This property holds the current state of the camera object.
This property was introduced in Qt Mobility 1.1.
Access functions:
State | state () const |
Notifier signal:
void | stateChanged ( QCamera::State state ) |
This property holds the current status of the camera object.
This property was introduced in Qt Mobility 1.1.
Access functions:
Status | status () const |
Notifier signal:
void | statusChanged ( QCamera::Status status ) |
Construct a QCamera from service provider and parent.
Construct a QCamera from device name device and parent.
Destroys the camera object.
Reimplemented from QMediaObject::availabilityError().
Returns the error state of the camera service.
This function was introduced in Qt Mobility 1.1.
Returns a list of camera device's available from the default service provider.
This function was introduced in Qt Mobility 1.1.
Signals the capture mode has changed.
This function was introduced in Qt Mobility 1.1.
Returns the description of the device.
This function was introduced in Qt Mobility 1.1.
Returns the error state of the object.
This function was introduced in Qt Mobility 1.1.
Signal emitted when error state changes to value.
This function was introduced in Qt Mobility 1.1.
Returns a string describing a camera's error state.
This function was introduced in Qt Mobility 1.1.
Returns the camera exposure control object.
This function was introduced in Qt Mobility 1.1.
Returns the camera focus control object.
This function was introduced in Qt Mobility 1.1.
Returns the camera image processing control object.
This function was introduced in Qt Mobility 1.1.
Reimplemented from QMediaObject::isAvailable().
Return true if the camera service is ready to use.
This function was introduced in Qt Mobility 1.1.
Returns true if the capture mode is suported.
This function was introduced in Qt Mobility 1.1.
Open the camera device. The camera state is changed to QCamera::LoadedStatus.
It's not necessary to explcitly load the camera, unless unless the application have to read the supported camera settings and change the default depending on the camera capabilities.
In all the other cases it's possible to start the camera directly from unloaded state.
This function was introduced in Qt Mobility 1.1.
Signals locking of at least one requested camera settings failed.
This function was introduced in Qt Mobility 1.1.
Signals the overall status for all the requested camera locks was changed with specified reason.
This function was introduced in Qt Mobility 1.1.
Signals the lock status was changed with specified reason.
This function was introduced in Qt Mobility 1.1.
Signals all the requested camera settings are locked.
This function was introduced in Qt Mobility 1.1.
Returns the requested lock types.
This function was introduced in Qt Mobility 1.1.
Lock all the supported camera settings.
This function was introduced in Qt Mobility 1.1.
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 QCamera::locked() signal is emitted when camera settings are successfully locked, otherwise QCamera::lockFailed() is emitted.
QCamera also emits lockStatusChanged(QCamera::LockType, QCamera::LockStatus) on individual lock status changes and lockStatusChanged(QCamera::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 QCamera::Unlocked.
It's also acceptable to relock already locked settings, depending on the lock parameter this initiates new focusing, exposure or white balance calculation.
This function was introduced in Qt Mobility 1.1.
Sets the QVideoWidget based camera viewfinder. The previously set viewfinder is detached.
This function was introduced in Qt Mobility 1.1.
Sets the QGraphicsVideoItem based camera viewfinder. The previously set viewfinder is detached.
This function was introduced in Qt Mobility 1.1.
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.
This function was introduced in Qt Mobility 1.2.
Starts the camera.
State is changed to QCamera::ActiveState if camera is started successfully, otherwise error() signal is emitted.
While the camera state is changed to QCamera::ActiveState, starting the camera service can be asynchronous with the actual status reported with QCamera::status property.
This function was introduced in Qt Mobility 1.1.
Signals the camera state has changed.
Usually the state changes is caused by calling load(), unload(), start() and stop(), but the state can also be changed change as a result of camera error.
This function was introduced in Qt Mobility 1.1.
Signals the camera status has changed.
This function was introduced in Qt Mobility 1.1.
Stops the camera. The camera state is changed from QCamera::ActiveState to QCamera::LoadedState.
This function was introduced in Qt Mobility 1.1.
Returns the lock types, camera supports.
This function was introduced in Qt Mobility 1.1.
Close the camera device and deallocate the related resources. The camera state is changed to QCamera::UnloadedStatus.
This function was introduced in Qt Mobility 1.1.
Unlock all the requested camera locks.
This function was introduced in Qt Mobility 1.1.
Unlocks the camera settings specified with locks or cancel the current locking if one is active.
This function was introduced in Qt Mobility 1.1.