QImageCapture 类用于媒体内容的录制。 更多...
头: | #include <QImageCapture> |
CMake: |
find_package(Qt6 COMPONENTS Multimedia REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Multimedia) |
qmake: | QT += multimedia |
继承: | QObject |
enum | Error { NoError, NotReadyError, ResourceError, OutOfSpaceError, NotSupportedFeatureError, FormatError } |
enum | Quality { VeryLowQuality, LowQuality, NormalQuality, HighQuality, VeryHighQuality } |
QImageCapture (QObject * parent = nullptr) | |
virtual | ~QImageCapture () |
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 | imageSaved (int id , const QString & fileName ) |
void | metaDataChanged () |
void | qualityChanged () |
void | readyForCaptureChanged (bool ready ) |
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); QVideoWidget *preview = new QVideoWidget(); preview->show(); captureSession.setVideoOutput(preview); imageCapture = new QImageCapture(camera); captureSession.setImageCapture(imageCapture); camera->start(); //on shutter button pressed imageCapture->capture();
另请参阅 QCamera .
常量 | 值 | 描述 |
---|---|---|
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
|
不支持当前格式。 |
枚举品质编码级别。
常量 | 值 |
---|---|
QImageCapture::VeryLowQuality
|
0
|
QImageCapture::LowQuality
|
1
|
QImageCapture::NormalQuality
|
2
|
QImageCapture::HighQuality
|
3
|
QImageCapture::VeryHighQuality
|
4
|
[read-only]
fileFormat
: const
FileFormat
This property holds the image format.
访问函数:
QImageCapture::FileFormat | fileFormat () const |
通知程序信号:
void | fileFormatChanged () |
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 () |
[read-only]
quality
: const
Quality
This property holds the image encoding quality.
访问函数:
QImageCapture::Quality | quality () const |
通知程序信号:
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 ) |
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.
[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 ().
[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.
[signal]
void
QImageCapture::
imageAvailable
(
int
id
, const
QVideoFrame
&
frame
)
Signal emitted when QImageCapture::CaptureToBuffer is set and 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::
imageSaved
(
int
id
, const
QString
&
fileName
)
Signal emitted when QImageCapture::CaptureToFile is set and the frame with request id was saved to fileName .
[signal]
void
QImageCapture::
readyForCaptureChanged
(
bool
ready
)
Signals that a camera's ready for capture state has changed.
注意: 通知程序信号对于特性 readyForCapture .
[虚拟]
QImageCapture::
~QImageCapture
()
Destroys images capture object.
Adds additional metaData to any existing meta data, that is embedded into the captured image.
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.
返回当前错误状态。
注意: getter 函数对于特性 error。
另请参阅 errorString ().
返回描述当前错误状态的字符串。
注意: Getter function for property errorString.
另请参阅 error ().
Returns true if the images capture service ready to use.
返回编码图像的分辨率。
另请参阅 setResolution ().
设置图像 format .
另请参阅 fileFormat ().
Replaces any existing meta data, to be embedded into the captured image, with a set of metaData .
注意: setter 函数对于特性 metaData .
另请参阅 metaData ().
设置图像编码 quality .
另请参阅 quality ().
设置 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 ().
设置 width and height of the resolution of the encoded image.
这是重载函数。