The QCameraImageCapture class is used for the recording of media content. 更多...
| 頭: | #include <QCameraImageCapture> |
| qmake: | QT += multimedia |
| 繼承: | QObject and QMediaBindableInterface |
| enum | CaptureDestination { CaptureToFile, CaptureToBuffer } |
| flags | CaptureDestinations |
| enum | DriveMode { SingleImageCapture } |
| enum | Error { NoError, NotReadyError, ResourceError, OutOfSpaceError, NotSupportedFeatureError, FormatError } |
| QCameraImageCapture (QMediaObject * mediaObject , QObject * parent = Q_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 & codec ) const |
| bool | isAvailable () const |
| bool | isCaptureDestinationSupported (CaptureDestinations destination ) const |
| bool | isReadyForCapture () const |
| void | setBufferFormat (const QVideoFrame::PixelFormat format ) |
| void | setCaptureDestination (CaptureDestinations destination ) |
| void | setEncodingSettings (const QImageEncoderSettings & settings ) |
| QList<QVideoFrame::PixelFormat> | supportedBufferFormats () const |
| QStringList | supportedImageCodecs () const |
| QList<QSize> | supportedResolutions (const QImageEncoderSettings & settings = QImageEncoderSettings(), bool * continuous = Q_NULLPTR) const |
| virtual QMediaObject * | mediaObject () const override |
| void | cancelCapture () |
| int | capture (const QString & file = QString()) |
| 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 ) |
| virtual bool | setMediaObject (QMediaObject * mediaObject ) override |
The QCameraImageCapture class is used for the recording of media content.
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();
另請參閱 QCamera .
| 常量 | 值 | 描述 |
|---|---|---|
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.
| 常量 | 值 | 描述 |
|---|---|---|
QCameraImageCapture::SingleImageCapture
|
0
|
Drive mode is capturing a single picture. |
| 常量 | 值 | 描述 |
|---|---|---|
QCameraImageCapture::NoError
|
0
|
沒有錯誤。 |
QCameraImageCapture::NotReadyError
|
1
|
The service is not ready for capture yet. |
QCameraImageCapture::ResourceError
|
2
|
設備未就緒 (或不可用)。 |
QCameraImageCapture::OutOfSpaceError
|
3
|
設備沒有剩餘空間。 |
QCameraImageCapture::NotSupportedFeatureError
|
4
|
Device does not support stillimages capture. |
QCameraImageCapture::FormatError
|
5
|
不支持當前格式。 |
This property holds whether the service is ready to capture a an image immediately.
調用
capture
() while
readyForCapture
is
false
is not permitted and results in an error.
訪問函數:
| bool | isReadyForCapture () const |
通知程序信號:
| void | readyForCaptureChanged (bool ready ) |
Constructs a media recorder which records the media produced by mediaObject .
The parent 被傳遞給 QMediaObject .
Destroys images capture object.
Returns the availability of this functionality.
Returns the buffer image capture format being used.
另請參閱 supportedBufferFormats () 和 setBufferFormat ().
[signal]
void
QCameraImageCapture::
bufferFormatChanged
(
QVideoFrame::PixelFormat
format
)
Signal emitted when the buffer format for the buffer image capture has changed.
[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 () 或 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 () 和 imageSaved () 信號。
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 () 和 imageSaved () 信號。
另請參閱 isReadyForCapture ().
Returns the image capture destination being used.
另請參閱 isCaptureDestinationSupported () 和 setCaptureDestination ().
[signal]
void
QCameraImageCapture::
captureDestinationChanged
(
QCameraImageCapture::CaptureDestinations
destination
)
Signal emitted when the capture destination 已改變。
Returns the image encoder settings being used.
另請參閱 setEncodingSettings ().
返迴當前錯誤狀態。
另請參閱 errorString ().
[signal]
void
QCameraImageCapture::
error
(
int
id
,
QCameraImageCapture::Error
error
, const
QString
&
errorString
)
Signals that the capture request id has failed with an error and errorString description.
注意: 信號 error 在此類中是重載。要使用函數指針句法連接到此信號,必須在靜態鑄造中指定信號類型,如此範例所示:
connect(cameraImageCapture, static_cast<void(QCameraImageCapture::*)(int, QCameraImageCapture::Error, const QString &)>(&QCameraImageCapture::error), [=](int id, QCameraImageCapture::Error error, const QString &errorString){ /* ... */ });
返迴描述當前錯誤狀態的字符串。
另請參閱 error ().
[signal]
void
QCameraImageCapture::
imageAvailable
(
int
id
, const
QVideoFrame
&
buffer
)
Signal emitted when the frame with request id is available as buffer .
[signal]
void
QCameraImageCapture::
imageCaptured
(
int
id
, const
QImage
&
preview
)
Signal emitted when the frame with request id was captured, but not processed and saved yet. Frame preview can be displayed to user.
返迴描述為圖像 codec .
[signal]
void
QCameraImageCapture::
imageExposed
(
int
id
)
Signal emitted when the frame with request id was exposed.
[signal]
void
QCameraImageCapture::
imageMetadataAvailable
(
int
id
, const
QString
&
key
, const
QVariant
&
value
)
Signals that a metadata for an image with request id is available. Also includes the key and value of the metadata.
This signal is emitted between imageExposed and imageSaved signals.
[signal]
void
QCameraImageCapture::
imageSaved
(
int
id
, const
QString
&
fileName
)
Signal emitted when the frame with request id was saved to fileName .
Returns true if the images capture service ready to use.
Returns true if the image capture destination is supported; otherwise returns false.
另請參閱 captureDestination () 和 setCaptureDestination ().
[override virtual]
QMediaObject
*QCameraImageCapture::
mediaObject
() const
重實現自 QMediaBindableInterface::mediaObject ().
另請參閱 setMediaObject ().
[signal]
void
QCameraImageCapture::
readyForCaptureChanged
(
bool
ready
)
Signals that a camera's ready for capture state has changed.
注意: 通知程序信號對於特性 readyForCapture .
Sets the buffer image capture format to be used.
另請參閱 bufferFormat (), supportedBufferFormats (),和 captureDestination ().
Sets the capture destination to be used.
另請參閱 isCaptureDestinationSupported () 和 captureDestination ().
設置圖像編碼 settings .
If some parameters are not specified, or null settings are passed, the encoder choose the default encoding parameters.
另請參閱 encodingSettings ().
[override virtual protected]
bool
QCameraImageCapture::
setMediaObject
(
QMediaObject
*
mediaObject
)
重實現自 QMediaBindableInterface::setMediaObject ().
另請參閱 mediaObject ().
Returns the list of supported buffer image capture formats.
另請參閱 bufferFormat () 和 setBufferFormat ().
返迴支持的圖像編解碼器列錶。
Returns a list of resolutions images can be encoded at.
若非 null 圖像 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 被設為 true,否則 * continuous 被設為 false。
另請參閱 QImageEncoderSettings::resolution ().