QCamera Class Reference
The QCamera class provides interface for system camera devices. More...
#include <QCamera>
This class is under development and is subject to change.
Inherits QMediaObject.
Public Types
enum | CaptureMode { CaptureDisabled, 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 { ActiveState, IdleState, StoppedState } |
Properties
Public Functions
Reimplemented Public Functions
Public Slots
Signals
Static Public Members
Additional Inherited Members
Detailed Description
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 images taking.
camera = new QCamera;
viewfinder = new QCameraViewfinder();
viewfinder->show();
camera->setViewfinder(viewfinder);
recorder = new QMediaRecorder(camera);
imageCapture = new QCameraImageCapture(camera);
camera->setCaptureMode(QCamera::CaptureStillImage);
camera->start();
The Camera API of Qt Mobility is still in Technology Preview. It has not undergone the same level of review and testing as the rest of the APIs.
The API exposed by the classes in this component are not stable, and will undergo modification or removal prior to the final release of Qt Mobility.
Member Type Documentation
enum QCamera::CaptureMode
|
Constant | Value | Description |
QCamera::CaptureDisabled | 0 | Camera is not configured for capture yet. This is the initial camera mode in the QCamera::Stopped state. |
QCamera::CaptureStillImage | 1 | Camera is configured for still frames capture. |
QCamera::CaptureVideo | 2 | Camera is configured for video capture. |
enum QCamera::Error
|
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. |
enum QCamera::LockChangeReason
|
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. |
enum QCamera::LockStatus
|
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 continous 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.
enum QCamera::LockType
flags QCamera::LockTypes
|
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.
enum QCamera::State
|
Constant | Value | Description |
QCamera::ActiveState | 2 | The camera has been started and can produce data. The viewfinder displays video frames in active state. |
It may be not allowed to change some camera settings, like image resolution or codec in the active state.
|
Constant | Value | Description |
QCamera::IdleState | 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 camera state is asyncronyously changed to IdleState with QCamera::setCaptureMode().
|
Constant | Value | Description |
QCamera::StoppedState | 0 | The initial camera state, with camera not loaded, the camera capabilities except of supported capture modes are unknown. |
Property Documentation
The type of media (video or still images), the camera is configured to capture.
Access functions:
CaptureMode | captureMode () const |
void | setCaptureMode ( QCamera::CaptureMode mode ) |
Notifier signal:
This property holds the overall status for all the requested camera locks.
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.
Access functions:
Notifier signal:
Member Function Documentation
QCamera::QCamera ( QObject * parent = 0, QMediaServiceProvider * provider = QMediaServiceProvider::defaultServiceProvider() )
Construct a QCamera from service provider and parent.
QCamera::QCamera ( const QByteArray & device, QObject * parent = 0 )
Construct a QCamera from device name device and parent.
QCamera::~QCamera ()
Destroys the camera object.
QtMultimediaKit::AvailabilityError QCamera::availabilityError () const [virtual]
Reimplemented from QMediaObject::availabilityError().
Returns the error state of the camera service.
QList<QByteArray> QCamera::availableDevices () [static]
Returns a list of camera device's available from the default service provider.
void QCamera::captureModeChanged ( QCamera::CaptureMode ) [signal]
QString QCamera::deviceDescription ( const QByteArray & device ) [static]
Returns the description of the device.
Error QCamera::error () const
Returns the error state of the object.
void QCamera::error ( QCamera::Error value ) [signal]
Signal emitted when error state changes to value.
QString QCamera::errorString () const
Returns a string describing a camera's error state.
Returns the camera exposure control object.
QCameraFocus * QCamera::focus () const
Returns the camera focus control object.
Returns the camera image processing control object.
bool QCamera::isAvailable () const [virtual]
Reimplemented from QMediaObject::isAvailable().
Returne true if the camera service is ready to use.
bool QCamera::isCaptureModeSupported ( CaptureMode mode ) const
Returns true if the capture mode is suported. QCamera::CaptureDisabled mode is always supported.
void QCamera::lockFailed () [signal]
Signals locking of at least one requested camera settings failed.
Signals the overall status for all the requested camera locks was changed with specified reason.
Signals the lock status was changed with specified reason.
void QCamera::locked () [signal]
Signals all the requested camera settings are locked.
Returns the requested lock types.
void QCamera::searchAndLock () [slot]
Lock all the supported camera settings.
See also QCamera::searchAndLock(QCamera::LockTypes).
void QCamera::searchAndLock ( QCamera::LockTypes locks ) [slot]
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 emited when camera settings are successfully locked, otherwise QCamera::lockFailed() is emited.
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.
void QCamera::setViewfinder ( QVideoWidget * viewfinder )
Sets the QVideoWidget based camera viewfinder. The previously set viewfinder is detached.
void QCamera::setViewfinder ( QGraphicsVideoItem * viewfinder )
Sets the QGraphicsVideoItem based camera viewfinder. The previously set viewfinder is detached.
void QCamera::start () [slot]
Starts the camera.
This can involve powering up the camera device and can be asynchronyous.
State is changed to QCamera::ActiveState if camera is started succesfully, otherwise error() signal is emited.
void QCamera::stateChanged ( QCamera::State state ) [signal]
Signal emitted when state of the Camera object has changed.
void QCamera::stop () [slot]
Stops the camera.
Returns the lock types, camera supports.
void QCamera::unlock () [slot]
Unlock all the requested camera locks.
See also QCamera::searchAndLock(QCamera::LockTypes).
void QCamera::unlock ( QCamera::LockTypes locks ) [slot]
Unlocks the camera settings specified with locks or cancel the current locking if one is active.
See also QCamera::searchAndLock(QCamera::LockTypes).