CopperSpice API  1.9.1
QCameraImageCapture Class Reference

Used for recording media content from a camera device. More...

Inheritance diagram for QCameraImageCapture:
QObject QMediaBindableInterface

Public Typedefs

using CaptureDestinations = QFlags< CaptureDestination >
 

Public Types

enum  CaptureDestination
 
enum  DriveMode
 
enum  Error
 

Public Signals

void bufferFormatChanged (QVideoFrame::PixelFormat format)
 
void captureDestinationChanged (QCameraImageCapture::CaptureDestinations destination)
 
void error (int id, QCameraImageCapture::Error error, const QString &errorString)
 
void imageAvailable (int id, const QVideoFrame &buffer)
 
void imageCaptured (int id, const QImage &preview)
 
void imageExposed (int id)
 
void imageMetadataAvailable (int id, const QString &key, const QVariant &value)
 
void imageSaved (int id, const QString &fileName)
 
void readyForCaptureChanged (bool ready)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Slots

void cancelCapture ()
 
int capture (const QString &fileName=QString ())
 
- Public Slots inherited from QObject
void deleteLater ()
 

Public Methods

 QCameraImageCapture (QMediaObject *mediaObject, QObject *parent=nullptr)
 
 ~QCameraImageCapture ()
 
QMultimedia::AvailabilityStatus availability () const
 
QVideoFrame::PixelFormat bufferFormat () const
 
CaptureDestinations captureDestination () const
 
QImageEncoderSettings encodingSettings () const
 
Error error () const
 
QString errorString () const
 
QString imageCodecDescription (const QString &codecName) const
 
bool isAvailable () const
 
bool isCaptureDestinationSupported (CaptureDestinations destination) const
 
bool isReadyForCapture () const
 
QMediaObjectmediaObject () const override
 
void setBufferFormat (const QVideoFrame::PixelFormat format)
 
void setCaptureDestination (CaptureDestinations destination)
 
void setEncodingSettings (const QImageEncoderSettings &settings)
 
QList< QVideoFrame::PixelFormatsupportedBufferFormats () const
 
QStringList supportedImageCodecs () const
 
QList< QSizesupportedResolutions (const QImageEncoderSettings &settings=QImageEncoderSettings (), bool *continuous=nullptr) const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 
- Public Methods inherited from QMediaBindableInterface
virtual ~QMediaBindableInterface ()
 

Protected Methods

bool setMediaObject (QMediaObject *mediaObject) override
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Properties

 readyForCapture
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 

Detailed Description

The QCameraImageCapture class is used for recording media content from a camera device. This class is used with 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 Typedef Documentation

Member Enumeration Documentation

Values indicating where a captured image will be stored.

Constant Value Description
QCameraImageCapture::CaptureToFile 0x01 Capture the image to a file.
QCameraImageCapture::CaptureToBuffer 0x02 Capture the image to a buffer for further processing.

Value for the image capture sequencing mode.

Constant Value Description
QCameraImageCapture::SingleImageCapture 0 Drive mode is capturing a single picture.

List of values describing a capture 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 still image capture.
QCameraImageCapture::FormatError 5 Current format is not supported.

Constructor & Destructor Documentation

QCameraImageCapture::QCameraImageCapture ( QMediaObject mediaObject,
QObject parent = nullptr 
)
explicit

Constructs a QCameraImageCapture object using mediaObject and parent.

Constructs a QCameraImageCapture using mediaObject and parent.

QCameraImageCapture::~QCameraImageCapture ( )

Destroys this image capture object.

Method Documentation

QMultimedia::AvailabilityStatus QCameraImageCapture::availability ( ) const

Returns the availability of this object.

Returns the availability of this functionality.

QVideoFrame::PixelFormat QCameraImageCapture::bufferFormat ( ) const

Returns the buffer image capture format being used.

See also
supportedBufferFormats(), setBufferFormat()
void QCameraImageCapture::bufferFormatChanged ( QVideoFrame::PixelFormat  format)
signal

Signal emitted when the buffer format for the buffer image capture has changed.

void QCameraImageCapture::cancelCapture ( )
slot

Cancel incomplete capture requests. Already captured and queued for processing images may be discarded.

int QCameraImageCapture::capture ( const QString fileName = QString())
slot

Capture the image and save it to fileName. 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 chooses 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()

Capture the image and save it to the given fileName. 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 chooses 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()
CaptureDestinations QCameraImageCapture::captureDestination ( ) const

Returns the image captureDdestination being used.

See also
isCaptureDestinationSupported(), setCaptureDestination()

Returns the image capture destination being used.

See also
isCaptureDestinationSupported(), setCaptureDestination()
void QCameraImageCapture::captureDestinationChanged ( QCameraImageCapture::CaptureDestinations  destination)
signal

Signal emitted when the capture destination has changed.

Signal emitted when the capture destination has changed.

QImageEncoderSettings QCameraImageCapture::encodingSettings ( ) const

Returns the image encoder settings being used.

See also
setEncodingSettings()
Error QCameraImageCapture::error ( ) const

Returns the current error state.

See also
errorString()
void QCameraImageCapture::error ( int  id,
QCameraImageCapture::Error  error,
const QString errorString 
)
signal

This signal indicates the capture request with the given id has failed with an error and the errorString description.

Signals the capture request id failed with the given error code and message errorString.

QString QCameraImageCapture::errorString ( ) const

Returns a string describing the current error state.

See also
error()
void QCameraImageCapture::imageAvailable ( int  id,
const QVideoFrame buffer 
)
signal

This signal indicates the capture request with the given id is available in buffer.

Signal emitted when the frame with request id is available as buffer.

void QCameraImageCapture::imageCaptured ( int  id,
const QImage preview 
)
signal

This signal indicates the capture request with the given id was captured however it has not yet been processed and saved. The preview image can be displayed.

This signal indicates that an image with a given requestId has been captured and a preview is available.

QString QCameraImageCapture::imageCodecDescription ( const QString codecName) const

Returns a description of an image codecName.

void QCameraImageCapture::imageExposed ( int  id)
signal

This signal indicates the capture request with the given id has been exposed.

Signal emitted when the frame with request id was exposed.

void QCameraImageCapture::imageMetadataAvailable ( int  id,
const QString key,
const QVariant value 
)
signal

This signal indicates the capture request with the given id will contain metadata consisting of a key and a value.

This signal is emitted between the imageExposed and imageSaved signals.

Signals the metadata for an image with the requested id is available. The key and value contain the metadata. This signal should be emitted between imageExposed and imageSaved signals.

void QCameraImageCapture::imageSaved ( int  id,
const QString fileName 
)
signal

This signal indicates the capture request with the given id was saved to fileName.

Signal emitted when the frame with request id was saved to fileName.

bool QCameraImageCapture::isAvailable ( ) const

Returns true if the image capture service is ready to use.

Returns true if the images capture service ready to use.

bool QCameraImageCapture::isCaptureDestinationSupported ( CaptureDestinations  destination) const

Returns true if the image capture destination is supported otherwise returns false.

See also
captureDestination(), setCaptureDestination()
bool QCameraImageCapture::isReadyForCapture ( ) const

Returns true if the image capture service is ready to capture an image.

QMediaObject * QCameraImageCapture::mediaObject ( ) const
overridevirtual
void QCameraImageCapture::readyForCaptureChanged ( bool  ready)
signal

This signal indicates the readyForCapture property has changed to ready.

Signals a camera's ready for capture state has changed.

void QCameraImageCapture::setBufferFormat ( const QVideoFrame::PixelFormat  format)

Sets the buffer image capture format to be used.

See also
bufferFormat(), supportedBufferFormats(), captureDestination()
void QCameraImageCapture::setCaptureDestination ( CaptureDestinations  destination)

Sets the capture destination to be used.

See also
isCaptureDestinationSupported(), captureDestination()
void QCameraImageCapture::setEncodingSettings ( const QImageEncoderSettings settings)

Sets the image encoding to settings. If some parameters are not specified the encoder defaults will be used.

See also
encodingSettings()

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()
bool QCameraImageCapture::setMediaObject ( QMediaObject mediaObject)
overrideprotectedvirtual
QList< QVideoFrame::PixelFormat > QCameraImageCapture::supportedBufferFormats ( ) const

Returns the list of supported buffer image capture formats.

See also
bufferFormat(), 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 supported image resolutions. If the settings parameter is not empty only compatible resolutions will be returned. 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()

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()

Property Documentation

QCameraImageCapture::readyForCapture

This property will be true when the service is ready to capture an image. Calling capture() while this property is false results in an error.

PropertiesClass Methods
read isReadyForCapture
notify readyForCaptureChanged