![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
The QCameraDevice class provides general information about camera devices. More...
#include <qcameradevice.h>
Public Types | |
enum | Position { UnspecifiedPosition , BackFace , FrontFace } |
This enum specifies the physical position of the camera on the system hardware. More... | |
Public Member Functions | |
QCameraDevice () | |
Describes a camera device. | |
QCameraDevice (const QCameraDevice &other) | |
Constructs a copy of other. | |
QCameraDevice & | operator= (const QCameraDevice &other) |
Sets the QCameraDevice object to be equal to other. | |
~QCameraDevice () | |
Destroys the QCameraDevice. | |
bool | operator== (const QCameraDevice &other) const |
Returns true if this QCameraDevice is equal to other. | |
bool | operator!= (const QCameraDevice &other) const |
Returns true if this QCameraDevice is different from other. | |
bool | isNull () const |
Returns true if this QCameraDevice is null or invalid. | |
QByteArray | id () const |
QString | description () const |
bool | isDefault () const |
Position | position () const |
QList< QSize > | photoResolutions () const |
Returns a list of resolutions that the camera can use to capture still images. | |
QList< QCameraFormat > | videoFormats () const |
QtVideo::Rotation | correctionAngle () const |
Properties | |
QByteArray | id |
\qmlproperty string QtMultimedia::cameraDevice::id | |
QString | description |
\qmlproperty string QtMultimedia::cameraDevice::description | |
bool | isDefault |
\qmlproperty bool QtMultimedia::cameraDevice::isDefault | |
Position | position |
\qmlproperty enumeration QtMultimedia::cameraDevice::position | |
QList< QCameraFormat > | videoFormats |
\qmlproperty CameraFormat QtMultimedia::cameraDevice::videoFormats | |
QtVideo::Rotation | correctionAngle |
Friends | |
class | QCameraDevicePrivate |
The QCameraDevice class provides general information about camera devices.
\inmodule QtMultimedia
QCameraDevice represents a physical camera device and its properties.
You can discover what cameras are available on a system using the availableCameras() and defaultCamera() functions. These are contained within QtMultimedia::MediaDevices.
The QCameraDevice instance retains its properties throughout its lifetime, even if the corresponding physical device is disconnected or its settings are modified. To keep track of updated properties, the user should load new instances of QCameraDevice from \l{QMediaDevices} when the relevant signals are fired.
This example prints the name of all available cameras:
A QCameraDevice can be used to construct a QCamera. The following example instantiates a QCamera whose camera device is named {mycamera}
:
You can also use QCameraDevice to get general information about a camera device such as description and physical position on the system.
Definition at line 45 of file qcameradevice.h.
This enum specifies the physical position of the camera on the system hardware.
\value UnspecifiedPosition The camera position is unspecified or unknown. \value BackFace The camera is on the back face of the system hardware. For example on a mobile device, it means it is on the opposite side to that of the screen. \value FrontFace The camera is on the front face of the system hardware. For example on a mobile device, it means it is on the same side as that of the screen. Front-facing cameras generate video frames with the property \l QVideoFrame::mirrored set to true
. This means that the presentation of these frames is flipped around the vertical axis to display the video output as a mirror, whereas recording only considers the transformations of the surface specified in \l QVideoFrame::surfaceFormat.
Enumerator | |
---|---|
UnspecifiedPosition | |
BackFace | |
FrontFace |
Definition at line 74 of file qcameradevice.h.
|
default |
Describes a camera device.
\qmlvaluetype cameraDevice \ingroup qmlvaluetypes \inqmlmodule QtMultimedia \since 6.2
! \nativetype QCameraDevice
The cameraDevice value type describes the properties of a camera device that is connected to the system.
The cameraDevice instance retains its properties throughout its lifetime, even if the corresponding physical device is disconnected or its settings are modified. To keep track of updated properties, the user should load new instances of cameraDevice from \l{MediaDevices} when the relevant signals are fired.
The list of camera devices can be queried from the \l{MediaDevices} type. To select a certain camera device set it as the device on \l{Camera}.
\qml CaptureSession { camera: Camera { cameraDevice: mediaDevices.defaultVideoInput } } MediaDevices { id: mediaDevices } \endqml
Constructs a null camera device
|
default |
Constructs a copy of other.
|
default |
Destroys the QCameraDevice.
QtVideo::Rotation QCameraDevice::correctionAngle | ( | ) | const |
Definition at line 360 of file qcameradevice.cpp.
QString QCameraDevice::description | ( | ) | const |
Definition at line 380 of file qcameradevice.cpp.
QByteArray QCameraDevice::id | ( | ) | const |
Definition at line 312 of file qcameradevice.cpp.
bool QCameraDevice::isDefault | ( | ) | const |
Definition at line 328 of file qcameradevice.cpp.
bool QCameraDevice::isNull | ( | ) | const |
Returns true if this QCameraDevice is null or invalid.
Definition at line 292 of file qcameradevice.cpp.
|
inline |
Returns true if this QCameraDevice is different from other.
Definition at line 96 of file qcameradevice.h.
|
default |
Sets the QCameraDevice object to be equal to other.
bool QCameraDevice::operator== | ( | const QCameraDevice & | other | ) | const |
Returns true if this QCameraDevice is equal to other.
Definition at line 276 of file qcameradevice.cpp.
Returns a list of resolutions that the camera can use to capture still images.
Definition at line 437 of file qcameradevice.cpp.
QCameraDevice::Position QCameraDevice::position | ( | ) | const |
Definition at line 426 of file qcameradevice.cpp.
QList< QCameraFormat > QCameraDevice::videoFormats | ( | ) | const |
Definition at line 453 of file qcameradevice.cpp.
|
friend |
Definition at line 91 of file qcameradevice.h.
|
read |
Returns the rotation angle needed to compensate for the physical camera rotation of the camera compared to its native orientation. In other words, the property represents the clockwise angle through which the output image needs to be rotated to be upright on the device screen in its native orientation. Since correctionAngle is relative to the native orientation, this value does not change with altering the device orientation (portrait/landscape). The correction angle may be non-zero mostly on Android, where native and camera orientations are defined by the manufacturer.
Example with 90 degrees correctionAngle
Returns the rotation angle needed to compensate for the physical camera rotation of the camera compared to its native orientation. In other words, the property represents the clockwise angle through which the output image needs to be rotated to be upright on the device screen in its native orientation. Since correctionAngle is relative to the native orientation, this value does not change with altering the device orientation (portrait/landscape). The correction angle may be non-zero mostly on Android, where native and camera orientations are defined by the manufacturer.
Example with 90 degrees correctionAngle
Definition at line 53 of file qcameradevice.h.
|
read |
\qmlproperty string QtMultimedia::cameraDevice::description
Holds a human readable name of the camera.
Use this string to present the device to the user.
Returns the human-readable description of the camera.
Use this string to present the device to the user.
Definition at line 49 of file qcameradevice.h.
|
read |
\qmlproperty string QtMultimedia::cameraDevice::id
Holds he device id of the camera
This is a unique ID to identify the camera and may not be human-readable.
Returns the device id of the camera
This is a unique ID to identify the camera and may not be human-readable.
Definition at line 48 of file qcameradevice.h.
|
read |
\qmlproperty bool QtMultimedia::cameraDevice::isDefault
Is true if this is the default camera device.
Returns true if this is the default camera device.
Definition at line 50 of file qcameradevice.h.
|
read |
\qmlproperty enumeration QtMultimedia::cameraDevice::position
Returns the physical position of the camera on the hardware system.
The returned value can be one of the following:
\value cameraDevice.UnspecifiedPosition The camera position is unspecified or unknown. \value cameraDevice.BackFace The camera is on the back face of the system hardware. For example on a mobile device, it means it is on the opposite side to that of the screen. \value cameraDevice.FrontFace The camera is on the front face of the system hardware. For example on a mobile device, it means it is on the same side as that of the screen. Preview of front-facing cameras is flipped around the vertical axis to display the video output as a mirror, whereas this flipping is not performed during recording.
Returns the physical position of the camera on the hardware system.
Definition at line 51 of file qcameradevice.h.
|
read |
\qmlproperty CameraFormat QtMultimedia::cameraDevice::videoFormats
Holds the video formats supported by the camera.
Returns the video formats supported by the camera.
Definition at line 52 of file qcameradevice.h.