QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
FlightDisplayViewUVC.qml
Go to the documentation of this file.
1import QtQuick
2import QtMultimedia
3
4import QGroundControl
5
6Rectangle {
7 id: _root
8 width: parent.width
9 height: parent.height
10 color: Qt.rgba(0,0,0,0.75)
11 clip: true
12 anchors.centerIn: parent
13 visible: _videoManager.isUvc
14
15 property var _videoManager: QGroundControl.videoManager
16
17 function adjustAspectRatio() {
18 //-- Set aspect ratio
19 var resolution = camera.cameraFormat.resolution
20 if (resolution.height > 0 && resolution.width > 0) {
21 var aspectRatio = resolution.width / resolution.height
22 _root.height = parent.height * aspectRatio
23 }
24 }
25
26 MediaDevices {
27 id: mediaDevices
28
29 function findCameraDevice(cameraId) {
30 var videoInputs = mediaDevices.videoInputs
31 for (var i = 0; i < videoInputs.length; i++) {
32 if (videoInputs[i].description === cameraId) {
33 return videoInputs[i]
34 }
35 }
36 return mediaDevices.defaultVideoInput
37 }
38 }
39
40 CaptureSession {
41 camera: Camera {
42 id: camera
43 cameraDevice: mediaDevices.findCameraDevice(_videoManager.uvcVideoSourceID)
44 active: _videoManager.isUvc
45
46 onCameraDeviceChanged: {
47 if (active) {
48 adjustAspectRatio()
49 }
50 }
51
52 onActiveChanged: {
53 if (active) {
54 adjustAspectRatio()
55 }
56 }
57 }
58 videoOutput: videoOutput
59 }
60
61 VideoOutput {
62 id: videoOutput
63 anchors.fill: parent
64 fillMode: VideoOutput.PreserveAspectCrop
65 }
66}