与焦点和缩放相关的摄像头设置接口。 更多...
导入语句: | import QtMultimedia |
实例化: | QCamera |
The Camera element can be used within a CaptureSession 为视频录制和图像获取。
可以使用 MediaDevices 列表可用摄像头并选取要使用的摄像头。
MediaDevices { id: mediaDevices } CaptureSession { camera: Camera { cameraDevice: mediaDevices.defaultVideoInput } }
On hardware that supports it, QCamera lets you adjust the focus and zoom. This also includes functionality such as a "Macro" mode for close up work (e.g. reading barcodes, or recognizing letters), or "touch to focus" - indicating an interesting area of the image for the hardware to attempt to focus on.
Item { width: 640 height: 360 CaptureSession { camera: Camera { id: camera focusMode: Camera.FocusModeAutoNear customFocusPoint: Qt.point(0.2, 0.2) // Focus relative to top-left corner } videoOutput: videoOutput } VideoOutput { id: videoOutput anchors.fill: parent } }
minimumZoomFactor and maximumZoomFactor properties provide the range of supported zoom factors. The zoomFactor property allows changing the zoom factor.
Camera { zoomFactor: maximumZoomFactor // zoom in as much as possible }
After capturing the raw data for a camera frame, the camera hardware and software performs various image processing tasks to produce the final image. This includes compensating for ambient light color, reducing noise, as well as making some other adjustments to the image.
You can control many of these processing steps through the Camera properties. For example, you can set the white balance (or color temperature) used for processing images:
Camera { whiteBalanceMode: Camera.WhiteBalanceManual colorTemperature: 5600 }
For more information on image processing of camera frames, see 摄像头图像处理 .
见 摄像头概述 了解更多信息。
active : bool |
Describes whether the camera is currently active.
cameraDevice : CameraDevice |
Gets or sets the currently active camera device.
cameraFormat : CameraDevice |
Gets or sets the currently active camera format.
另请参阅 CameraDevice::videoFormats .
customFocusPoint : point |
This property holds the position of custom focus point, in relative frame coordinates. This means that QPointF (0,0) points to the top-left corner of the frame, and QPointF (0.5,0.5) points to the center of the frame.
Custom focus point is used only in
FocusPointCustom
focus mode.
You can check whether custom focus points are supported by querying supportedFeatures() with the Feature.CustomFocusPoint flag.
error : enumeration |
Returns the error state of the camera.
另请参阅 QCamera::Error .
errorString : string |
Returns a human readable string describing a camera's error state.
exposureMode : ExposureMode |
The exposure mode being used.
另请参阅 QCamera::ExposureMode and Camera::isExposureModeSupported() .
exposureTime : float |
Returns the Camera's exposure time in seconds.
另请参阅 manualExposureTime .
flashMode : Camera::FlashMode |
Gets or sets a certain flash mode if the camera has a flash.
另请参阅 QCamera::FlashMode , Camera::isFlashModeSupported ,和 Camera::isFlashReady .
flashReady : bool |
Indicates if the flash is charged and ready to use.
focusMode : enumeration |
This property holds the current camera focus mode.
注意: In automatic focusing modes and where supported, the focusPoint property provides information and control over the area of the image that is being focused.
常量 | 描述 |
---|---|
Camera.FocusModeAuto
|
Continuous auto focus mode. |
Camera.FocusModeAutoNear
|
Continuous auto focus, preferring objects near to the camera. |
Camera.FocusModeAutoFar
|
Continuous auto focus, preferring objects far away from the camera. |
Camera.FocusModeHyperfocal
|
Focus to hyperfocal distance, with the maximum depth of field achieved. All objects at distances from half of this distance out to infinity will be acceptably sharp. |
Camera.FocusModeInfinity
|
Focus strictly to infinity. |
Camera.FocusModeManual
|
Manual or fixed focus mode. |
If a certain focus mode is not supported, setting it will have no effect.
另请参阅 isFocusModeSupported .
focusPoint : point |
Returns the point currently used by the auto focus system to focus onto.
isoSensitivity : int |
Describes the ISO sensitivity currently used by the camera.
manualExposureTime : real |
Gets or sets a manual exposure time.
Setting this property to -1 (the default) means that the camera automatically determines the exposure time.
manualIsoSensitivity : int |
Describes a manually set ISO sensitivity
Setting this property to -1 (the default), implies that the camera automatically adjusts the ISO sensitivity.
maximumZoomFactor : real |
This property holds the maximum zoom factor supported.
This will be
1.0
on cameras that do not support zooming.
minimumZoomFactor : real |
This property holds the minimum zoom factor supported.
This will be
1.0
on cameras that do not support zooming.
supportedFeatures : 特征 |
Returns the features supported by this camera.
另请参阅 QCamera::Feature .
torchMode : Camera::TorchMode |
Gets or sets the torch mode being used.
A torch is a continuous source of light. It can be used during video recording in low light conditions. Enabling torch mode will usually override any currently set flash mode.
另请参阅 QCamera::TorchMode , Camera::isTorchModeSupported() ,和 Camera::flashMode .
whiteBalanceMode : WhiteBalanceMode |
Gets or sets the white balance mode being used.
另请参阅 QCamera::WhiteBalanceMode .
zoomFactor : real |
Gets or sets the current zoom factor. Values will be clamped between minimumZoomFactor and maximumZoomFactor .
void errorOccurred ( Camera::Error error , string errorString ) |
This signal is emitted when error state changes to error . A description of the error is provided as errorString .
注意:
相应处理程序是
onErrorOccurred
.
colorTemperature () |
Gets or sets the current color temperature.
Setting a color temperature will only have an effect if WhiteBalanceManual is supported. In this case, setting a temperature greater 0 will automatically set the white balance mode to WhiteBalanceManual. Setting the temperature to 0 will reset the white balance mode to WhiteBalanceAuto.
bool isExposureModeSupported ( ExposureMode mode ) |
Returns true if the exposure mode is supported.
bool isFlashModeSupported ( FlashMode mode ) |
Returns true if the flash mode is supported.
bool isFlashReady () |
Returns true if flash is charged.
bool isFocusModeSupported ( FocusMode mode ) |
Returns true if the focus mode is supported by the camera.
bool isTorchModeSupported ( TorchMode mode ) |
Returns true if the torch mode is supported.
bool isWhiteBalanceModeSupported ( WhiteBalanceMode mode ) |
Returns true if the white balance mode is supported.
void start () |
Starts the camera.
Same as setting the active property to true.
If the camera can't be started for some reason, the errorOccurred() 信号被发射。
void stop () |
Stops the camera. Same as setting the active property to false.
void zoomTo ( factor , rate ) |
Zooms to a zoom factor factor 使用 rate .
rate is specified in powers of two per second. At a rate of 1 it would take 2 seconds to go from a zoom factor of 1 to 4.
注意: Using a specific rate is not supported on all cameras. If not supported, zooming will happen as fast as possible.