QCameraDevice Class▲
-
Header: QCameraDevice
-
CMake:
find_package(Qt6 REQUIRED COMPONENTS Multimedia)
target_link_libraries(mytarget PRIVATE Qt6::Multimedia)
-
qmake: QT += multimedia
-
Inherited By:
-
Group: QCameraDevice is part of multimedia, multimedia_camera
Detailed Description▲
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.
This example prints the name of all available cameras:
const
QList&
lt;QCameraDevice&
gt; cameras =
QMediaDevices::
videoInputs();
for
(const
QCameraDevice &
amp;cameraDevice : cameras)
qDebug() &
lt;&
lt; cameraDevice.description();
A QCameraDevice can be used to construct a QCamera. The following example instantiates a QCamera whose camera device is named mycamera:
const
QList&
lt;QCameraDevice&
gt; cameras =
QMediaDevices::
videoInputs();
for
(const
QCameraDevice &
amp;cameraDevice : cameras) {
if
(cameraDevice.description() ==
"mycamera"
)
camera =
new
QCamera(cameraDevice);
}
You can also use QCameraDevice to get general information about a camera device such as description and physical position on the system.
QCamera myCamera;
QCameraDevice cameraDevice =
camera-&
gt;cameraDevice();
if
(cameraDevice.position() ==
QCameraDevice::
FrontFace)
qDebug() &
lt;&
lt; "The camera is on the front face of the hardware system."
;
else
if
(cameraDevice.position() ==
QCameraDevice::
BackFace)
qDebug() &
lt;&
lt; "The camera is on the back face of the hardware system."
;
See Also▲
See also QCamera
Member Type Documentation▲
enum QCameraDevice::Position▲
This enum specifies the physical position of the camera on the system hardware.
Constant |
Value |
Description |
---|---|---|
QCameraDevice::UnspecifiedPosition |
0 |
The camera position is unspecified or unknown. |
QCameraDevice::BackFace |
1 |
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. |
QCameraDevice::FrontFace |
2 |
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. |
See Also▲
See also position()
Property Documentation▲
[read-only, since 6.7] correctionAngle : const QtVideo::Rotation▲
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.
This property was introduced in Qt 6.7.
Access functions:
-
correctionAngle() const
[read-only] description : const QString▲
Returns the human-readable description of the camera.
Use this string to present the device to the user.
Access functions:
-
description() const
[read-only] id : const QByteArray▲
Returns the device id of the camera
This is a unique ID to identify the camera and may not be human-readable.
Access functions:
-
id() const
[read-only] isDefault : const bool▲
Returns true if this is the default camera device.
Access functions:
-
bool isDefault() const
[read-only] position : const Position▲
Returns the physical position of the camera on the hardware system.
Access functions:
-
position() const
[read-only] videoFormats : const QList<QCameraFormat>▲
Returns the video formats supported by the camera.
Access functions:
-
<> videoFormats() const
Member Function Documentation▲
QCameraDevice::QCameraDevice()▲
Constructs a null camera device
QCameraDevice::QCameraDevice(const QCameraDevice &other)▲
Constructs a copy of other.
QCameraDevice::~QCameraDevice()▲
Destroys the QCameraDevice.
bool QCameraDevice::isNull() const▲
Returns true if this QCameraDevice is null or invalid.
QList<QSize> QCameraDevice::photoResolutions() const▲
Returns a list of resolutions that the camera can use to capture still images.
See Also▲
See also QImageCapture
bool QCameraDevice::operator!=(const QCameraDevice &other) const▲
Returns true if this QCameraDevice is different from other.
QCameraDevice &QCameraDevice::operator=(const QCameraDevice &other)▲
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.