QCameraInfo 类

The QCameraInfo class provides general information about camera devices. 更多...

头: #include <QCameraInfo>
qmake: QT += multimedia
Since: Qt 5.3

公共函数

QCameraInfo (const QByteArray & name = QByteArray())
QCameraInfo (const QCamera & camera )
QCameraInfo (const QCameraInfo & other )
~QCameraInfo ()
QString description () const
QString deviceName () const
bool isNull () const
int orientation () const
QCamera::Position position () const
bool operator!= (const QCameraInfo & other ) const
QCameraInfo & operator= (const QCameraInfo & other )
bool operator== (const QCameraInfo & other ) const

静态公共成员

QList<QCameraInfo> availableCameras (QCamera::Position position = QCamera::UnspecifiedPosition)
QCameraInfo defaultCamera ()

详细描述

The QCameraInfo class provides general information about camera devices.

QCameraInfo lets you query for camera devices that are currently available on the system.

静态函数 defaultCamera () 和 availableCameras () provide you a list of all available cameras.

This example prints the name of all available cameras:

QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
foreach (const QCameraInfo &cameraInfo, cameras)
    qDebug() << cameraInfo.deviceName();
					

A QCameraInfo can be used to construct a QCamera . The following example instantiates a QCamera whose camera device is named 'mycamera':

QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
foreach (const QCameraInfo &cameraInfo, cameras) {
    if (cameraInfo.deviceName() == "mycamera")
        camera = new QCamera(cameraInfo);
}
					

还可以使用 QCameraInfo to get general information about a camera device such as description, physical position on the system, or camera sensor orientation.

QCamera myCamera;
QCameraInfo cameraInfo(myCamera);
if (cameraInfo.position() == QCamera::FrontFace)
    qDebug() << "The camera is on the front face of the hardware system.";
else if (cameraInfo.position() == QCamera::BackFace)
    qDebug() << "The camera is on the back face of the hardware system.";
qDebug() << "The camera sensor orientation is " << cameraInfo.orientation() << " degrees.";
					

另请参阅 QCamera .

成员函数文档编制

QCameraInfo:: QCameraInfo (const QByteArray & name = QByteArray())

Constructs a camera info object from a camera device name .

If no such device exists, the QCameraInfo object will be invalid and isNull () will return true.

QCameraInfo:: QCameraInfo (const QCamera & camera )

Constructs a camera info object for camera .

You can use it to query information about the camera object passed as argument.

camera is invalid, for example when no camera device is available on the system, the QCameraInfo object will be invalid and isNull () will return true.

QCameraInfo:: QCameraInfo (const QCameraInfo & other )

构造副本为 other .

QCameraInfo:: ~QCameraInfo ()

销毁 QCameraInfo .

[static] QList < QCameraInfo > QCameraInfo:: availableCameras ( QCamera::Position position = QCamera::UnspecifiedPosition)

Returns a list of available cameras on the system which are located at position .

position is not specified or if the value is QCamera::UnspecifiedPosition , a list of all available cameras will be returned.

[static] QCameraInfo QCameraInfo:: defaultCamera ()

Returns the default camera on the system.

The returned object should be checked using isNull () before being used, in case there is no default camera or no cameras at all.

另请参阅 availableCameras ().

QString QCameraInfo:: description () const

Returns the human-readable description of the camera.

QString QCameraInfo:: deviceName () const

Returns the device name of the camera

This is a unique ID to identify the camera and may not be human-readable.

bool QCameraInfo:: isNull () const

返回 true,若此 QCameraInfo is null or invalid.

int QCameraInfo:: orientation () const

Returns the physical orientation of the camera sensor.

The value is the orientation angle (clockwise, in steps of 90 degrees) of the camera sensor in relation to the display in its natural orientation.

You can show the camera image in the correct orientation by rotating it by this value in the anti-clockwise direction.

For example, suppose a mobile device which is naturally in portrait orientation. The back-facing camera is mounted in landscape. If the top side of the camera sensor is aligned with the right edge of the screen in natural orientation, the value should be 270. If the top side of a front-facing camera sensor is aligned with the right of the screen, the value should be 90.

QCamera::Position QCameraInfo:: position () const

Returns the physical position of the camera on the hardware system.

bool QCameraInfo:: operator!= (const QCameraInfo & other ) const

返回 true,若此 QCameraInfo is different from other .

QCameraInfo &QCameraInfo:: operator= (const QCameraInfo & other )

设置 QCameraInfo 对象等于 other .

bool QCameraInfo:: operator== (const QCameraInfo & other ) const

返回 true,若此 QCameraInfo 等于 other .