QCameraImageCapture Class
The QCameraImageCapture class is used for the recording of media content. More...
| Header: | #include <QCameraImageCapture> |
| qmake: | QT += multimedia |
| Inherits: | QObject and QMediaBindableInterface |
Public Types
| enum | CaptureDestination { CaptureToFile, CaptureToBuffer } |
| flags | CaptureDestinations |
| enum | DriveMode { SingleImageCapture } |
| enum | Error { NoError, NotReadyError, ResourceError, OutOfSpaceError, NotSupportedFeatureError, FormatError } |
Properties
- readyForCapture : const bool
- 1 property inherited from QObject
Public Functions
| QCameraImageCapture(QMediaObject *mediaObject, QObject *parent = nullptr) | |
| virtual | ~QCameraImageCapture() |
| QMultimedia::AvailabilityStatus | availability() const |
| QVideoFrame::PixelFormat | bufferFormat() const |
| QCameraImageCapture::CaptureDestinations | captureDestination() const |
| QImageEncoderSettings | encodingSettings() const |
| QCameraImageCapture::Error | error() const |
| QString | errorString() const |
| QString | imageCodecDescription(const QString &codec) const |
| bool | isAvailable() const |
| bool | isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const |
| bool | isReadyForCapture() const |
| void | setBufferFormat(const QVideoFrame::PixelFormat format) |
| void | setCaptureDestination(QCameraImageCapture::CaptureDestinations destination) |
| void | setEncodingSettings(const QImageEncoderSettings &settings) |
| QList<QVideoFrame::PixelFormat> | supportedBufferFormats() const |
| QStringList | supportedImageCodecs() const |
| QList<QSize> | supportedResolutions(const QImageEncoderSettings &settings = QImageEncoderSettings(), bool *continuous = nullptr) const |
Reimplemented Public Functions
| virtual QMediaObject * | mediaObject() const override |
- 30 public functions inherited from QObject
Public Slots
| void | cancelCapture() |
| int | capture(const QString &file = QString()) |
- 1 public slot inherited from QObject
Signals
| void | readyForCaptureChanged(bool ready) |
- 2 signals inherited from QObject
Reimplemented Protected Functions
| virtual bool | setMediaObject(QMediaObject *mediaObject) override |
- 9 protected functions inherited from QObject
Related Non-Members
| typedef | QObjectList |
| QList<T> | qFindChildren(const QObject *obj, const QRegExp ®Exp) |
| T | qobject_cast(QObject *object) |
| T | qobject_cast(const QObject *object) |
Macros
| QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
| Q_CLASSINFO(Name, Value) | |
| Q_DISABLE_COPY(Class) | |
| Q_DISABLE_COPY_MOVE(Class) | |
| Q_DISABLE_MOVE(Class) | |
| Q_EMIT | |
| Q_ENUM(...) | |
| Q_ENUM_NS(...) | |
| Q_FLAG(...) | |
| Q_FLAG_NS(...) | |
| Q_GADGET | |
| Q_INTERFACES(...) | |
| Q_INVOKABLE | |
| Q_NAMESPACE | |
| Q_OBJECT | |
| Q_PROPERTY(...) | |
| Q_REVISION | |
| Q_SET_OBJECT_NAME(Object) | |
| Q_SIGNAL | |
| Q_SIGNALS | |
| Q_SLOT | |
| Q_SLOTS |
Additional Inherited Members
Detailed Description
The QCameraImageCapture class is a high level images recording class. It's not intended to be used alone but for accessing the media recording functions of other media objects, like QCamera.
camera = new QCamera; viewfinder = new QCameraViewfinder(); viewfinder->show(); camera->setViewfinder(viewfinder); imageCapture = new QCameraImageCapture(camera); camera->setCaptureMode(QCamera::CaptureStillImage); camera->start(); //on half pressed shutter button camera->searchAndLock(); //on shutter button pressed imageCapture->capture(); //on shutter button released camera->unlock();
See also QCamera.
Member Type Documentation
enum QCameraImageCapture::CaptureDestination
flags QCameraImageCapture::CaptureDestinations
| Constant | Value | Description |
|---|---|---|
QCameraImageCapture::CaptureToFile | 0x01 | Capture the image to a file. |
QCameraImageCapture::CaptureToBuffer | 0x02 | Capture the image to a buffer for further processing. |
The CaptureDestinations type is a typedef for QFlags<CaptureDestination>. It stores an OR combination of CaptureDestination values.
enum QCameraImageCapture::DriveMode
| Constant | Value | Description |
|---|---|---|
QCameraImageCapture::SingleImageCapture | 0 | Drive mode is capturing a single picture. |
enum QCameraImageCapture::Error
| Constant | Value | Description |
|---|---|---|
QCameraImageCapture::NoError | 0 | No Errors. |
QCameraImageCapture::NotReadyError | 1 | The service is not ready for capture yet. |
QCameraImageCapture::ResourceError | 2 | Device is not ready or not available. |
QCameraImageCapture::OutOfSpaceError | 3 | No space left on device. |
QCameraImageCapture::NotSupportedFeatureError | 4 | Device does not support stillimages capture. |
QCameraImageCapture::FormatError | 5 | Current format is not supported. |
Property Documentation
readyForCapture : const bool
This property holds whether the service is ready to capture a an image immediately.
Calling capture() while readyForCapture is false is not permitted and results in an error.
Access functions:
| bool | isReadyForCapture() const |
Notifier signal:
| void | readyForCaptureChanged(bool ready) |
Member Function Documentation
QCameraImageCapture::QCameraImageCapture(QMediaObject *mediaObject, QObject *parent = nullptr)
Constructs a media recorder which records the media produced by mediaObject.
The parent is passed to QMediaObject.
[slot] void QCameraImageCapture::cancelCapture()
Cancel incomplete capture requests. Already captured and queused for proicessing images may be discarded.
[slot] int QCameraImageCapture::capture(const QString &file = QString())
Capture the image and save it to file. This operation is asynchronous in majority of cases, followed by signals QCameraImageCapture::imageExposed(), QCameraImageCapture::imageCaptured(), QCameraImageCapture::imageSaved() or QCameraImageCapture::error().
If an empty file is passed, the camera backend choses the default location and naming scheme for photos on the system, if only file name without full path is specified, the image will be saved to the default directory, with a full path reported with imageCaptured() and imageSaved() signals.
QCamera saves all the capture parameters like exposure settings or image processing parameters, so changes to camera parameters after capture() is called do not affect previous capture requests.
QCameraImageCapture::capture returns the capture Id parameter, used with imageExposed(), imageCaptured() and imageSaved() signals.
See also isReadyForCapture().
[virtual] QCameraImageCapture::~QCameraImageCapture()
Destroys images capture object.
QMultimedia::AvailabilityStatus QCameraImageCapture::availability() const
Returns the availability of this functionality.
QVideoFrame::PixelFormat QCameraImageCapture::bufferFormat() const
Returns the buffer image capture format being used.
See also supportedBufferFormats() and setBufferFormat().
QCameraImageCapture::CaptureDestinations QCameraImageCapture::captureDestination() const
Returns the image capture destination being used.
See also isCaptureDestinationSupported() and setCaptureDestination().
QImageEncoderSettings QCameraImageCapture::encodingSettings() const
Returns the image encoder settings being used.
See also setEncodingSettings().
QCameraImageCapture::Error QCameraImageCapture::error() const
Returns the current error state.
See also errorString().
QString QCameraImageCapture::errorString() const
Returns a string describing the current error state.
See also error().
QString QCameraImageCapture::imageCodecDescription(const QString &codec) const
Returns a description of an image codec.
bool QCameraImageCapture::isAvailable() const
Returns true if the images capture service ready to use.
bool QCameraImageCapture::isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const
Returns true if the image capture destination is supported; otherwise returns false.
See also captureDestination() and setCaptureDestination().
[override virtual] QMediaObject *QCameraImageCapture::mediaObject() const
See also setMediaObject().
void QCameraImageCapture::setBufferFormat(const QVideoFrame::PixelFormat format)
Sets the buffer image capture format to be used.
See also bufferFormat(), supportedBufferFormats(), and captureDestination().
void QCameraImageCapture::setCaptureDestination(QCameraImageCapture::CaptureDestinations destination)
Sets the capture destination to be used.
See also isCaptureDestinationSupported() and captureDestination().
void QCameraImageCapture::setEncodingSettings(const QImageEncoderSettings &settings)
Sets the image encoding settings.
If some parameters are not specified, or null settings are passed, the encoder choose the default encoding parameters.
See also encodingSettings().
[override virtual protected] bool QCameraImageCapture::setMediaObject(QMediaObject *mediaObject)
See also mediaObject().
QList<QVideoFrame::PixelFormat> QCameraImageCapture::supportedBufferFormats() const
Returns the list of supported buffer image capture formats.
See also bufferFormat() and setBufferFormat().
QStringList QCameraImageCapture::supportedImageCodecs() const
Returns a list of supported image codecs.
QList<QSize> QCameraImageCapture::supportedResolutions(const QImageEncoderSettings &settings = QImageEncoderSettings(), bool *continuous = nullptr) const
Returns a list of resolutions images can be encoded at.
If non null image settings parameter is passed, the returned list is reduced to resolution supported with partial settings like image codec or quality applied.
If the encoder supports arbitrary resolutions within the supported range, *continuous is set to true, otherwise *continuous is set to false.
See also QImageEncoderSettings::resolution().