Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QCameraDevice Class Reference

The QCameraDevice class provides general information about camera devices. More...

#include <qcameradevice.h>

+ Inheritance diagram for QCameraDevice:
+ Collaboration diagram for QCameraDevice:

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.
 
QCameraDeviceoperator= (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< QSizephotoResolutions () const
 Returns a list of resolutions that the camera can use to capture still images.
 
QList< QCameraFormatvideoFormats () 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< QCameraFormatvideoFormats
 \qmlproperty CameraFormat QtMultimedia::cameraDevice::videoFormats
 
QtVideo::Rotation correctionAngle
 

Friends

class QCameraDevicePrivate
 

Detailed Description

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.

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.

See also
QCamera

Definition at line 45 of file qcameradevice.h.

Member Enumeration Documentation

◆ Position

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.

See also
position()
Enumerator
UnspecifiedPosition 
BackFace 
FrontFace 

Definition at line 74 of file qcameradevice.h.

Constructor & Destructor Documentation

◆ QCameraDevice() [1/2]

QCameraDevice::QCameraDevice ( )
default

Describes a camera device.

\qmlvaluetype cameraDevice
\ingroup qmlvaluetypes
\inqmlmodule QtMultimedia
\since 6.2

! \instantiates QCameraDevice

The cameraDevice value type describes the properties of a camera device that is connected to the system.

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

◆ QCameraDevice() [2/2]

QCameraDevice::QCameraDevice ( const QCameraDevice & other)
default

Constructs a copy of other.

◆ ~QCameraDevice()

QCameraDevice::~QCameraDevice ( )
default

Destroys the QCameraDevice.

Member Function Documentation

◆ correctionAngle()

QtVideo::Rotation QCameraDevice::correctionAngle ( ) const

Definition at line 350 of file qcameradevice.cpp.

References QtVideo::None, and QCameraDevicePrivate::orientation.

◆ description()

QString QCameraDevice::description ( ) const

Definition at line 370 of file qcameradevice.cpp.

References QCameraDevicePrivate::description.

◆ id()

QByteArray QCameraDevice::id ( ) const

Definition at line 302 of file qcameradevice.cpp.

References QCameraDevicePrivate::id, and QByteArray().

+ Here is the call graph for this function:

◆ isDefault()

bool QCameraDevice::isDefault ( ) const

Definition at line 318 of file qcameradevice.cpp.

References QCameraDevicePrivate::isDefault.

◆ isNull()

bool QCameraDevice::isNull ( ) const

Returns true if this QCameraDevice is null or invalid.

Definition at line 282 of file qcameradevice.cpp.

Referenced by QCameraPrivate::init(), QWindowsImageCapture::isReadyForCapture(), AVFCamera::setActive(), QAVFCameraBase::setActive(), AVFCameraSession::setActive(), QV4L2Camera::setActive(), QWindowsCamera::setActive(), QGstreamerCamera::setActive(), and AVFCameraSession::updateVideoInput().

+ Here is the caller graph for this function:

◆ operator!=()

bool QCameraDevice::operator!= ( const QCameraDevice & other) const
inline

Returns true if this QCameraDevice is different from other.

Definition at line 96 of file qcameradevice.h.

References operator==(), and other().

+ Here is the call graph for this function:

◆ operator=()

QCameraDevice & QCameraDevice::operator= ( const QCameraDevice & other)
default

Sets the QCameraDevice object to be equal to other.

◆ operator==()

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

Returns true if this QCameraDevice is equal to other.

Definition at line 266 of file qcameradevice.cpp.

References QCameraDevicePrivate::description, QCameraDevicePrivate::id, other(), and QCameraDevicePrivate::position.

Referenced by operator!=().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ photoResolutions()

QList< QSize > QCameraDevice::photoResolutions ( ) const

Returns a list of resolutions that the camera can use to capture still images.

See also
QImageCapture

Definition at line 419 of file qcameradevice.cpp.

References QCameraDevicePrivate::photoResolutions.

◆ position()

QCameraDevice::Position QCameraDevice::position ( ) const

Definition at line 408 of file qcameradevice.cpp.

References QCameraDevicePrivate::position, and UnspecifiedPosition.

◆ videoFormats()

QList< QCameraFormat > QCameraDevice::videoFormats ( ) const

Definition at line 435 of file qcameradevice.cpp.

References QCameraDevicePrivate::videoFormats.

Friends And Related Symbol Documentation

◆ QCameraDevicePrivate

friend class QCameraDevicePrivate
friend

Definition at line 91 of file qcameradevice.h.

Property Documentation

◆ correctionAngle

QCameraDevice::correctionAngle
read
Since
6.7 \qmlproperty QtVideo::Rotation QtMultimedia::cameraDevice::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

Since
6.7

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.

◆ description

QCameraDevice::description
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.

Referenced by QAndroidCamera::onCameraError(), and QAndroidCamera::onCaptureSessionFailed().

◆ id

QCameraDevice::id
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.

Referenced by QAVFCameraBase::device(), QWindowsMediaDeviceSession::setActive(), and QWasmCamera::setCamera().

◆ isDefault

QCameraDevice::isDefault
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.

◆ position

QCameraDevice::position
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.

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

Definition at line 51 of file qcameradevice.h.

Referenced by camera_info(), QAndroidCamera::frameAvailable(), and overview_viewfinder_orientation().

◆ videoFormats

QCameraDevice::videoFormats
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.

Referenced by AVFCamera::setCameraFormat(), QAVFCameraBase::setCameraFormat(), QV4L2Camera::setCameraFormat(), and QGstreamerCamera::setCameraFormat().


The documentation for this class was generated from the following files: