PySide6.QtMultimedia.QCameraDevice¶
- class QCameraDevice¶
QCameraDevice
类提供了关于相机设备的一般信息。更多…概要¶
属性¶
方法¶
def
__init__()
def
description()
def
id()
def
isDefault()
def
isNull()
def
__ne__()
def
__eq__()
def
position()
def
videoFormats()
注意
本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。
详细描述¶
警告
本节包含从C++自动翻译到Python的代码片段,可能包含错误。
QCameraDevice
表示一个物理相机设备及其属性。您可以使用 availableCameras() 和 defaultCamera() 函数来发现系统上可用的摄像头。这些函数包含在 QtMultimedia::MediaDevices 中。
此示例打印所有可用摄像头的名称:
cameras = QMediaDevices.videoInputs() for cameraDevice in cameras: print(cameraDevice.description())
一个
QCameraDevice
可以用来构建一个QCamera
。以下示例实例化了一个QCamera
,其相机设备名为mycamera
:cameras = QMediaDevices.videoInputs() for cameraDevice in cameras: if cameraDevice.description() == "mycamera": camera = QCamera(cameraDevice)
你也可以使用
QCameraDevice
来获取关于相机设备的一般信息,例如描述和系统上的物理位置。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.")
另请参阅
- class Position¶
此枚举指定了相机在系统硬件上的物理位置。
常量
描述
QCameraDevice.UnspecifiedPosition
相机位置未指定或未知。
QCameraDevice.BackFace
相机位于系统硬件的背面。例如,在移动设备上,这意味着它位于屏幕的相反侧。
QCameraDevice.FrontFace
摄像头位于系统硬件的正面。例如,在移动设备上,这意味着它与屏幕在同一侧。前置摄像头生成的视频帧具有
mirrored
属性设置为true
。这意味着这些帧的显示会围绕垂直轴翻转,以镜像方式显示视频输出,而录制仅考虑surfaceFormat
中指定的表面变换。另请参阅
在版本6.1中添加。
注意
当使用
from __feature__ import true_property
时,属性可以直接使用,否则通过访问器函数使用。- property correctionAngleᅟ: QtVideo.Rotation¶
返回与相机原生方向相比,补偿相机物理旋转所需的旋转角度。换句话说,该属性表示输出图像需要顺时针旋转的角度,以便在设备屏幕上以原生方向直立显示。由于
correctionAngle
是相对于原生方向的,因此该值不会随着设备方向(纵向/横向)的改变而改变。校正角度在Android设备上可能不为零,因为原生方向和相机方向由制造商定义。- Access functions:
- property descriptionᅟ: str¶
返回相机的可读描述。
使用此字符串向用户展示设备。
- Access functions:
- property idᅟ: QByteArray¶
返回相机的设备ID
这是一个用于识别相机的唯一ID,可能不易于人类阅读。
- Access functions:
- property isDefaultᅟ: bool¶
如果这是默认的摄像头设备,则返回 true。
- Access functions:
- property positionᅟ: QCameraDevice.Position¶
返回相机在硬件系统上的物理位置。
- Access functions:
- property videoFormatsᅟ: list of QCameraFormat¶
返回相机支持的视频格式。
- Access functions:
- __init__()¶
构造一个空的相机设备
- __init__(other)
- Parameters:
其他 –
QCameraDevice
构造
other
的副本。属性
correctionAngleᅟ
的获取器。- description()¶
- Return type:
字符串
属性
descriptionᅟ
的获取器。- id()¶
- Return type:
属性
idᅟ
的获取器。- isDefault()¶
- Return type:
布尔
属性
isDefaultᅟ
的获取器。- isNull()¶
- Return type:
布尔
如果此
QCameraDevice
为空或无效,则返回true。- __ne__(other)¶
- Parameters:
其他 –
QCameraDevice
- Return type:
布尔
如果这个
QCameraDevice
与other
不同,则返回true。- __eq__(other)¶
- Parameters:
其他 –
QCameraDevice
- Return type:
布尔
如果这个
QCameraDevice
等于other
,则返回true。返回相机可用于拍摄静态图像的解析度列表。
另请参阅
属性
positionᅟ
的获取器。- videoFormats()¶
- Return type:
QCameraFormat 的列表
属性
videoFormatsᅟ
的获取器。