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 implicitWidth: videoOutput.implicitWidth
11 implicitHeight: videoOutput.implicitHeight
12 color: Qt.rgba(0,0,0,0.75)
13 clip: true
14 anchors.centerIn: parent
15 visible: _videoManager.isUvc
16
17 property var _videoManager: QGroundControl.videoManager
18
19 function adjustAspectRatio() {
20 //-- Set aspect ratio
21 var resolution = camera.cameraFormat.resolution
22 if (resolution.height > 0 && resolution.width > 0) {
23 var aspectRatio = resolution.width / resolution.height
24 _root.height = parent.height * aspectRatio
25 }
26 }
27
28 MediaDevices {
29 id: mediaDevices
30
31 function findCameraDevice(cameraId) {
32 var videoInputs = mediaDevices.videoInputs
33 for (var i = 0; i < videoInputs.length; i++) {
34 if (videoInputs[i].description === cameraId) {
35 return videoInputs[i]
36 }
37 }
38 return mediaDevices.defaultVideoInput
39 }
40 }
41
42 CaptureSession {
43 camera: Camera {
44 id: camera
45 cameraDevice: mediaDevices.findCameraDevice(_videoManager.uvcVideoSourceID)
46 active: _videoManager.isUvc
47
48 onCameraDeviceChanged: {
49 if (active) {
50 adjustAspectRatio()
51 }
52 }
53
54 onActiveChanged: {
55 if (active) {
56 adjustAspectRatio()
57 }
58 }
59 }
60 videoOutput: videoOutput
61 }
62
63 VideoOutput {
64 id: videoOutput
65 anchors.fill: parent
66 fillMode: VideoOutput.PreserveAspectCrop
67 }
68}