PySide6.QtMultimedia.QCameraDevice¶
- class QCameraDevice¶
The
QCameraDevice
class provides general information about camera devices. More…Synopsis¶
Properties¶
Methods¶
def
__init__()
def
description()
def
id()
def
isDefault()
def
isNull()
def
__ne__()
def
__eq__()
def
position()
def
videoFormats()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
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:
cameras = QMediaDevices.videoInputs() for cameraDevice in cameras: print(cameraDevice.description())
A
QCameraDevice
can be used to construct aQCamera
. The following example instantiates aQCamera
whose camera device is namedmycamera
:cameras = QMediaDevices.videoInputs() for cameraDevice in cameras: if cameraDevice.description() == "mycamera": camera = QCamera(cameraDevice)
You can also use
QCameraDevice
to get general information about a camera device such as description and physical position on the system.myCamera = QCamera() cameraDevice = camera.cameraDevice() if cameraDevice.position() == QCameraDevice.FrontFace: print("The camera is on the front face of the hardware system.") elif cameraDevice.position() == QCameraDevice.BackFace: print("The camera is on the back face of the hardware system.")
See also
- class Position¶
This enum specifies the physical position of the camera on the system hardware.
Constant
Description
QCameraDevice.UnspecifiedPosition
The camera position is unspecified or unknown.
QCameraDevice.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.
QCameraDevice.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
mirrored
set totrue
. 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 insurfaceFormat
.See also
Added in version 6.1.
Note
Properties can be used directly when
from __feature__ import true_property
is used or via accessor functions otherwise.- property correctionAngleᅟ: 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.- Access functions:
- property descriptionᅟ: str¶
Returns the human-readable description of the camera.
Use this string to present the device to the user.
- Access functions:
- property idᅟ: 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:
- property isDefaultᅟ: bool¶
Returns true if this is the default camera device.
- Access functions:
- property positionᅟ: QCameraDevice.Position¶
Returns the physical position of the camera on the hardware system.
- Access functions:
- property videoFormatsᅟ: list of QCameraFormat¶
Returns the video formats supported by the camera.
- Access functions:
- __init__()¶
Constructs a null camera device
- __init__(other)
- Parameters:
other –
QCameraDevice
Constructs a copy of
other
.Getter of property
correctionAngleᅟ
.- description()¶
- Return type:
str
Getter of property
descriptionᅟ
.- id()¶
- Return type:
Getter of property
idᅟ
.- isDefault()¶
- Return type:
bool
Getter of property
isDefaultᅟ
.- isNull()¶
- Return type:
bool
Returns true if this
QCameraDevice
is null or invalid.- __ne__(other)¶
- Parameters:
other –
QCameraDevice
- Return type:
bool
Returns true if this
QCameraDevice
is different fromother
.- __eq__(other)¶
- Parameters:
other –
QCameraDevice
- Return type:
bool
Returns true if this
QCameraDevice
is equal toother
.Returns a list of resolutions that the camera can use to capture still images.
See also
Getter of property
positionᅟ
.- videoFormats()¶
- Return type:
.list of QCameraFormat
Getter of property
videoFormatsᅟ
.