QImageCapture 類

QImageCapture 類用於媒體內容的錄製。 更多...

頭: #include <QImageCapture>
CMake: find_package(Qt6 REQUIRED COMPONENTS Multimedia)
target_link_libraries(mytarget PRIVATE Qt6::Multimedia)
qmake: QT += multimedia
繼承: QObject

公共類型

enum Error { NoError, NotReadyError, ResourceError, OutOfSpaceError, NotSupportedFeatureError, FormatError }
enum FileFormat { UnspecifiedFormat, JPEG, PNG, WebP, Tiff }
enum Quality { VeryLowQuality, LowQuality, NormalQuality, HighQuality, VeryHighQuality }

特性

公共函數

QImageCapture (QObject * parent = nullptr)
virtual ~QImageCapture () override
void addMetaData (const QMediaMetaData & metaData )
QMediaCaptureSession * captureSession () const
QImageCapture::Error error () const
QString errorString () const
QImageCapture::FileFormat fileFormat () const
bool isAvailable () const
bool isReadyForCapture () const
QMediaMetaData metaData () const
QImageCapture::Quality quality () const
QSize resolution () const
void setFileFormat (QImageCapture::FileFormat format )
void setMetaData (const QMediaMetaData & metaData )
void setQuality (QImageCapture::Quality quality )
void setResolution (const QSize & resolution )
void setResolution (int width , int height )

公共槽

int capture ()
int captureToFile (const QString & file = QString())

信號

void errorChanged ()
void errorOccurred (int id , QImageCapture::Error error , const QString & errorString )
void fileFormatChanged ()
void imageAvailable (int id , const QVideoFrame & frame )
void imageCaptured (int id , const QImage & preview )
void imageExposed (int id )
void imageMetadataAvailable (int id , const QMediaMetaData & metaData )
void imageSaved (int id , const QString & fileName )
void metaDataChanged ()
void qualityChanged ()
void readyForCaptureChanged (bool ready )
void resolutionChanged ()

靜態公共成員

QString fileFormatDescription (QImageCapture::FileFormat f )
QString fileFormatName (QImageCapture::FileFormat f )
QList<QImageCapture::FileFormat> supportedFormats ()

詳細描述

The QImageCapture 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 .

QMediaCaptureSession captureSession;
camera = new QCamera;
captureSession.setCamera(camera);
viewfinder = new QVideoWidget();
viewfinder->show();
captureSession.setVideoOutput(viewfinder);
imageCapture = new QImageCapture(camera);
captureSession.setImageCapture(imageCapture);
camera->start();
//on shutter button pressed
imageCapture->capture();
					

另請參閱 QCamera .

成員類型文檔編製

enum QImageCapture:: Error

常量 描述
QImageCapture::NoError 0 沒有錯誤。
QImageCapture::NotReadyError 1 The service is not ready for capture yet.
QImageCapture::ResourceError 2 設備未就緒 (或不可用)。
QImageCapture::OutOfSpaceError 3 設備沒有剩餘空間。
QImageCapture::NotSupportedFeatureError 4 Device does not support stillimages capture.
QImageCapture::FormatError 5 不支持當前格式。

enum QImageCapture:: FileFormat

Choose one of the following image formats:

常量 描述
QImageCapture::UnspecifiedFormat 0 No format specified
QImageCapture::JPEG 1 .jpg or .jpeg format
QImageCapture::PNG 2 .png format
QImageCapture::WebP 3 .webp format
QImageCapture::Tiff 4 .tiff format

enum QImageCapture:: Quality

枚舉品質編碼級彆。

常量
QImageCapture::VeryLowQuality 0
QImageCapture::LowQuality 1
QImageCapture::NormalQuality 2
QImageCapture::HighQuality 3
QImageCapture::VeryHighQuality 4

特性文檔編製

[read-only] error : const Error

返迴當前錯誤狀態。

訪問函數:

QImageCapture::Error error () const

通知程序信號:

void errorChanged ()

另請參閱 errorString ().

[read-only] errorString : const QString

返迴描述當前錯誤狀態的字符串。

訪問函數:

QString errorString () const

通知程序信號:

void errorChanged ()

另請參閱 error ().

fileFormat : FileFormat

This property holds the image format.

訪問函數:

QImageCapture::FileFormat fileFormat () const
void setFileFormat (QImageCapture::FileFormat format )

通知程序信號:

void fileFormatChanged ()

metaData : QMediaMetaData

This property holds the meta data that will get embedded into the image.

注意: Additional fields such as a time stamp or location may get added by the camera back end.

訪問函數:

QMediaMetaData metaData () const
void setMetaData (const QMediaMetaData & metaData )

通知程序信號:

void metaDataChanged ()

quality : Quality

This property holds the image encoding quality.

訪問函數:

QImageCapture::Quality quality () const
void setQuality (QImageCapture::Quality quality )

通知程序信號:

void qualityChanged ()

[read-only] readyForCapture : const bool

保持 true if the camera is ready to capture an image immediately. Calling capture () while readyForCapture is false is not permitted and results in an error.

訪問函數:

bool isReadyForCapture () const

通知程序信號:

void readyForCaptureChanged (bool ready )

成員函數文檔編製

[explicit] QImageCapture:: QImageCapture ( QObject * parent = nullptr)

Constructs a image capture object, from a parent , that can capture individual still images produced by a camera.

You must connect both an image capture object and a QCamera to a capture session to capture images.

[override virtual noexcept] QImageCapture:: ~QImageCapture ()

Destroys images capture object.

void QImageCapture:: addMetaData (const QMediaMetaData & metaData )

Adds additional metaData to any existing meta data, that is embedded into the captured image.

[slot] int QImageCapture:: capture ()

Capture the image and make it available as a QImage . This operation is asynchronous in majority of cases, followed by signals QImageCapture::imageExposed (), QImageCapture::imageCaptured () 或 QImageCapture::error ().

QImageCapture::capture returns the capture Id parameter, used with imageExposed (), imageCaptured () 和 imageSaved () 信號。

另請參閱 isReadyForCapture ().

QMediaCaptureSession *QImageCapture:: captureSession () const

Returns the capture session this camera is connected to, or a nullptr if the camera is not connected to a capture session.

使用 QMediaCaptureSession::setImageCapture () to connect the image capture to a session.

[slot] int QImageCapture:: captureToFile (const QString & file = QString())

Capture the image and save it to file . This operation is asynchronous in majority of cases, followed by signals QImageCapture::imageExposed (), QImageCapture::imageCaptured (), QImageCapture::imageSaved () 或 QImageCapture::error ().

If an empty file is passed, the camera back end 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 () 和 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.

QImageCapture::capture returns the capture Id parameter, used with imageExposed (), imageCaptured () 和 imageSaved () 信號。

另請參閱 isReadyForCapture ().

[signal] void QImageCapture:: errorOccurred ( int id , QImageCapture::Error error , const QString & errorString )

Signals that the capture request id has failed with an error and errorString description.

[static] QString QImageCapture:: fileFormatDescription ( QImageCapture::FileFormat f )

Returns the description of the given file format, f .

[static] QString QImageCapture:: fileFormatName ( QImageCapture::FileFormat f )

Returns the name of the given format, f .

[signal] void QImageCapture:: imageAvailable ( int id , const QVideoFrame & frame )

Signal emitted when the frame with request id 可用。

[signal] void QImageCapture:: 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.

[signal] void QImageCapture:: imageExposed ( int id )

Signal emitted when the frame with request id was exposed.

[signal] void QImageCapture:: imageMetadataAvailable ( int id , const QMediaMetaData & metaData )

Signals that an image identified by id has metaData .

[signal] void QImageCapture:: imageSaved ( int id , const QString & fileName )

Signal emitted when QImageCapture::CaptureToFile is set and the frame with request id was saved to fileName .

bool QImageCapture:: isAvailable () const

Returns true if the images capture service ready to use.

[signal] void QImageCapture:: readyForCaptureChanged ( bool ready )

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

注意: 通知程序信號對於特性 readyForCapture .

QSize QImageCapture:: resolution () const

返迴編碼圖像的分辨率。

另請參閱 setResolution ().

[signal] void QImageCapture:: resolutionChanged ()

Signals when the image resolution changes.

void QImageCapture:: setFileFormat ( QImageCapture::FileFormat format )

設置圖像 format .

Assigning an unsupported FileFormat 不起作用。

注意: setter 函數對於特性 fileFormat .

另請參閱 fileFormat () 和 supportedFormats .

void QImageCapture:: setMetaData (const QMediaMetaData & metaData )

Replaces any existing meta data, to be embedded into the captured image, with a set of metaData .

注意: setter 函數對於特性 metaData .

另請參閱 metaData ().

void QImageCapture:: setQuality ( QImageCapture::Quality quality )

設置圖像編碼 quality .

注意: setter 函數對於特性 quality .

另請參閱 quality ().

void QImageCapture:: setResolution (const QSize & resolution )

設置 resolution 為編碼圖像。

QSize indicates the encoder should make an optimal choice based on what is available from the image source and the limitations of the codec.

另請參閱 resolution ().

void QImageCapture:: setResolution ( int width , int height )

設置 width and height of the resolution of the encoded image.

這是重載函數。

[static] QList < QImageCapture::FileFormat > QImageCapture:: supportedFormats ()

Returns a list of supported file formats.

另請參閱 FileFormat .