~infradeveconsys/+junk/qtcam

« back to all changes in this revision

Viewing changes to qtcam/src/ub22_qml/qtcam/UVCSettings/see3cam50/uvc50.qml

  • Committer: infradeveconsys
  • Date: 2023-10-05 16:03:55 UTC
  • Revision ID: infradev@e-consystems.com-20231005160355-6004e40uvrgmiyed
Added code for Ubuntu 22.04

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * uvc50.qml -- extension settings for cu50 cameras
 
3
 * Copyright © 2015  e-con Systems India Pvt. Limited
 
4
 *
 
5
 * This file is part of Qtcam.
 
6
 *
 
7
 * Qtcam is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 3, or (at your option)
 
10
 * any later version.
 
11
 *
 
12
 * Qtcam is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with Qtcam. If not, see <http://www.gnu.org/licenses/>.
 
19
 */
 
20
 
 
21
import QtQuick 2.0
 
22
import QtQuick.Controls 1.1
 
23
import QtQuick.Controls.Styles 1.0
 
24
import QtQuick.Dialogs 1.1
 
25
import econ.camera.uvcsettings 1.0
 
26
import econ.camera.see3cam50 1.0
 
27
import econ.camera.see3camControl 1.0
 
28
import econ.camera.see3camGpioControl 1.0
 
29
import cameraenum 1.0
 
30
import econ.camera.stream 1.0
 
31
import econ.camera.property 1.0
 
32
Item {
 
33
    width:268
 
34
    height:720
 
35
    property bool outputPinFlag
 
36
    property var frameToSkip  
 
37
    property variant uniqueSerialNumber
 
38
    property int value_ret
 
39
    id: see3CAM_cu50Camera
 
40
 
 
41
    Connections
 
42
    {
 
43
        target: root
 
44
        function onTakeScreenShot()
 
45
        {
 
46
            root.imageCapture(CommonEnums.SNAP_SHOT);
 
47
        }
 
48
        function onGetVideoPinStatus()
 
49
        {
 
50
            root.enableVideoPin(true);
 
51
        }
 
52
        function onGetStillImageFormats()
 
53
        {
 
54
            var stillImageFormat = []
 
55
            stillImageFormat.push("jpg")
 
56
            stillImageFormat.push("bmp")
 
57
            stillImageFormat.push("raw")
 
58
            stillImageFormat.push("png")
 
59
            root.insertStillImageFormat(stillImageFormat);
 
60
        }
 
61
    }
 
62
 
 
63
    Action {
 
64
        id: gpiStatus
 
65
        onTriggered: {
 
66
            getGpiStatus()
 
67
        }
 
68
    }
 
69
 
 
70
    Action {
 
71
        id: serialNumber
 
72
        onTriggered: {
 
73
            getSerialNumber()
 
74
        }
 
75
    }
 
76
 
 
77
    Action {
 
78
        id: firmwareVersion
 
79
        onTriggered: {
 
80
            getFirmwareVersion()
 
81
        }
 
82
    }
 
83
 
 
84
    Text {
 
85
        id: gpio_controlsCU50
 
86
        text: "--- GPIO Controls ---"
 
87
        font.pixelSize: 14
 
88
        font.family: "Ubuntu"
 
89
        color: "#ffffff"
 
90
        smooth: true
 
91
        x: 73
 
92
        y: 205.5
 
93
        opacity: 0.50196078431373
 
94
    }
 
95
 
 
96
    Text {
 
97
        id: gpo_number
 
98
        text: "GP0 Number :"
 
99
        font.pixelSize: 14
 
100
        font.family: "Ubuntu"
 
101
        color: "#ffffff"
 
102
        smooth: true
 
103
        x: 6
 
104
        y: 254.5
 
105
        opacity: 1
 
106
    }
 
107
 
 
108
    ComboBox {
 
109
        id: gpioOutputBox
 
110
        model: ListModel {
 
111
            id: cbItems
 
112
            ListElement { text: "1"  }
 
113
            ListElement { text: "2"  }
 
114
        }
 
115
        x: 104
 
116
        y: 251
 
117
        opacity: 1
 
118
        activeFocusOnPress : true
 
119
        style: ComboBoxStyle {
 
120
            background: Image {
 
121
                id: gpobox
 
122
                source: "images/gpo_no_box.png"
 
123
                Rectangle {
 
124
                    width: gpobox.sourceSize.width - 28
 
125
                    height: gpobox.sourceSize.height
 
126
                    color: "#222021"
 
127
                    border.color: "white"
 
128
                    border.width: control.activeFocus ? 3 : 1
 
129
                    radius: control.activeFocus ? 5 : 0
 
130
                }
 
131
            }
 
132
            label: Text {
 
133
                color: "#ffffff"
 
134
                text: control.currentText
 
135
                elide: Text.ElideRight
 
136
                verticalAlignment: Text.AlignVCenter
 
137
            }
 
138
        }
 
139
        onCurrentIndexChanged: {
 
140
            outputPinFlag = true
 
141
            if(currentIndex == 0)
 
142
                see3camGpio.getGpioLevel(See3CamGpio.OUT1)
 
143
            else
 
144
                see3camGpio.getGpioLevel(See3CamGpio.OUT2)
 
145
        }
 
146
    }
 
147
 
 
148
    Image {
 
149
        id: gpo_no_drowdown
 
150
        source: "images/gpo_no_drowdown.png"
 
151
        x: 231
 
152
        y: 253
 
153
        opacity: 1
 
154
    }
 
155
 
 
156
    Text {
 
157
        id: gpo_levelCU50
 
158
        text: "GPO Level :"
 
159
        font.pixelSize: 14
 
160
        font.family: "Ubuntu"
 
161
        color: "#ffffff"
 
162
        smooth: true
 
163
        x: 8
 
164
        y: 318.5
 
165
        opacity: 1
 
166
    }
 
167
 
 
168
    Row {
 
169
        x: 100
 
170
        y: 319.5
 
171
        spacing: 15
 
172
        ExclusiveGroup { id: group }
 
173
        RadioButton {
 
174
            exclusiveGroup: group
 
175
            id: radioHighcu50
 
176
            style: RadioButtonStyle {
 
177
                label: Text {
 
178
                    text: "High"
 
179
                    font.pixelSize: 14
 
180
                    font.family: "Ubuntu"
 
181
                    color: "#ffffff"
 
182
                    smooth: true
 
183
                    opacity: 1
 
184
                }
 
185
                background: Rectangle {
 
186
                    color: "#222021"
 
187
                    border.color: control.activeFocus ? "#ffffff" : "#222021"
 
188
                }
 
189
            }
 
190
            onClicked: {
 
191
                outputPinFlag = true
 
192
                if(gpioOutputBox.currentIndex == 0)
 
193
                    see3camGpio.setGpioLevel(See3CamGpio.OUT1,See3CamGpio.High)//Pin Number & Value
 
194
                else
 
195
                    see3camGpio.setGpioLevel(See3CamGpio.OUT2,See3CamGpio.High)//Pin Number & Value
 
196
            }
 
197
            Keys.onReturnPressed: {
 
198
                checked = true
 
199
                outputPinFlag = true
 
200
                if(gpioOutputBox.currentIndex == 0)
 
201
                    see3camGpio.setGpioLevel(See3CamGpio.OUT1,See3CamGpio.High)//Pin Number & Value
 
202
                else
 
203
                    see3camGpio.setGpioLevel(See3CamGpio.OUT2,See3CamGpio.High)//Pin Number & Value
 
204
 
 
205
            }
 
206
        }
 
207
        RadioButton {
 
208
            exclusiveGroup: group
 
209
            id: radioLowcu50
 
210
            style: RadioButtonStyle {
 
211
                label: Text {
 
212
                    text: "Low"
 
213
                    font.pixelSize: 14
 
214
                    font.family: "Ubuntu"
 
215
                    color: "#ffffff"
 
216
                    smooth: true
 
217
                    opacity: 1
 
218
                }
 
219
                background: Rectangle {
 
220
                    color: "#222021"
 
221
                    border.color: control.activeFocus ? "#ffffff" : "#222021"
 
222
                }
 
223
            }
 
224
            onClicked: {
 
225
                outputPinFlag = true
 
226
                if(gpioOutputBox.currentIndex == 0)
 
227
                    see3camGpio.setGpioLevel(See3CamGpio.OUT1,See3CamGpio.Low);//Pin Number & Value
 
228
                else
 
229
                    see3camGpio.setGpioLevel(See3CamGpio.OUT2,See3CamGpio.Low);//Pin Number & Value
 
230
            }
 
231
            Keys.onReturnPressed: {
 
232
                checked = true
 
233
                outputPinFlag = true
 
234
                if(gpioOutputBox.currentIndex == 0)
 
235
                    see3camGpio.setGpioLevel(See3CamGpio.OUT1,See3CamGpio.Low);//Pin Number & Value
 
236
                else
 
237
                    see3camGpio.setGpioLevel(See3CamGpio.OUT2,See3CamGpio.Low);//Pin Number & Value
 
238
            }
 
239
        }
 
240
    }
 
241
 
 
242
    Text {
 
243
        id: gpi_numberCU50
 
244
        text: "GPI Number :"
 
245
        font.pixelSize: 14
 
246
        font.family: "Ubuntu"
 
247
        color: "#ffffff"
 
248
        smooth: true
 
249
        x: 7
 
250
        y: 372.5
 
251
        opacity: 1
 
252
    }
 
253
 
 
254
    ComboBox {
 
255
        model: ListModel {
 
256
            id: cbItemsgpi
 
257
            ListElement { text: "1" }
 
258
            ListElement { text: "2" }
 
259
        }
 
260
        id: gpi_no_boxCU50
 
261
        x: 104
 
262
        y: 369
 
263
        opacity: 1
 
264
        activeFocusOnPress : true
 
265
        style: ComboBoxStyle {
 
266
            background: Image {
 
267
                id: gpiboxImg
 
268
                source: "images/gpi_no_box.png"
 
269
                Rectangle {
 
270
                    width: gpiboxImg.sourceSize.width - 28
 
271
                    height: gpiboxImg.sourceSize.height
 
272
                    color: "#222021"
 
273
                    border.color: "white"
 
274
                    border.width: control.activeFocus ? 3 : 1
 
275
                    radius: control.activeFocus ? 5 : 0
 
276
                }
 
277
            }
 
278
            label: Text {
 
279
                color: "#ffffff"
 
280
                text: control.currentText
 
281
                elide: Text.ElideRight
 
282
                verticalAlignment: Text.AlignVCenter
 
283
            }
 
284
        }
 
285
        onCurrentIndexChanged: {
 
286
            gpi_level_high.text = "GPI Level : "
 
287
        }
 
288
    }
 
289
    Text {
 
290
        id: gpi_level_high
 
291
        text: "GPI Level :"
 
292
        font.pixelSize: 14
 
293
        font.family: "Ubuntu"
 
294
        color: "#ffffff"
 
295
        smooth: true
 
296
        x: 8
 
297
        y: 426.5
 
298
        opacity: 1
 
299
    }
 
300
 
 
301
    Button {
 
302
        id: get_gpi_selected
 
303
        x: 132
 
304
        y: 422
 
305
        opacity: 1
 
306
        action: gpiStatus
 
307
        activeFocusOnPress : true
 
308
        tooltip: "Get the status of Input PIN"
 
309
        style: ButtonStyle {
 
310
            background: Rectangle {
 
311
                border.width: control.activeFocus ? 3 :0
 
312
                color: "#222021"
 
313
                border.color: control.activeFocus ? "#ffffff" : "#222021"
 
314
                radius: 5
 
315
            }
 
316
            label: Image {
 
317
                source: "images/get_gpi_selected.png"
 
318
            }
 
319
        }
 
320
        Keys.onReturnPressed: {
 
321
            getGpiStatus()
 
322
        }
 
323
    }
 
324
 
 
325
    Image {
 
326
        id: gpi_no_dropdown
 
327
        source: "images/gpi_no_dropdown.png"
 
328
        x: 231
 
329
        y: 371
 
330
        opacity: 1
 
331
    }
 
332
 
 
333
    Text {
 
334
        id: torch_controlsCU50
 
335
        text: "--- Torch Control ---"
 
336
        font.pixelSize: 14
 
337
        font.family: "Ubuntu"
 
338
        color: "#ffffff"
 
339
        smooth: true
 
340
        x: 73
 
341
        y: 472.5
 
342
        opacity: 0.50196078431373
 
343
    }
 
344
    Row {
 
345
        x: 55
 
346
        y: 504.5
 
347
        spacing: 50
 
348
 
 
349
        CheckBox {
 
350
            id: torch_ctrl
 
351
            activeFocusOnPress : true
 
352
            style: CheckBoxStyle {
 
353
                label: Text {
 
354
                    text: "Torch"
 
355
                    font.pixelSize: 14
 
356
                    font.family: "Ubuntu"
 
357
                    color: "#ffffff"
 
358
                    smooth: true
 
359
                    opacity: 1
 
360
                } background: Rectangle {
 
361
                    border.width: control.activeFocus ? 1 :0
 
362
                    color: "#222021"
 
363
                    border.color: control.activeFocus ? "#ffffff" : "#222021"
 
364
                }
 
365
            }
 
366
            onClicked: {
 
367
                see3camctrl.setTorchControlState(checked)
 
368
            }
 
369
            Keys.onReturnPressed: {
 
370
                if(checked)
 
371
                    checked = false
 
372
                else
 
373
                    checked = true
 
374
                see3camctrl.setTorchControlState(checked)
 
375
            }
 
376
        }
 
377
    }
 
378
    Text {
 
379
        id: other_optionsCU50
 
380
        text: "--- Other Options ---"
 
381
        font.pixelSize: 14
 
382
        font.family: "Ubuntu"
 
383
        color: "#ffffff"
 
384
        smooth: true
 
385
        x: 72
 
386
        y: 549.5
 
387
        opacity: 0.50196078431373
 
388
    }
 
389
 
 
390
    Button {
 
391
        id: serial_no_selected
 
392
        x: 85
 
393
        y: 582
 
394
        opacity: 1
 
395
        action: serialNumber
 
396
        activeFocusOnPress : true
 
397
        tooltip: "Click to view the Serial Number"
 
398
        style: ButtonStyle {
 
399
            background: Rectangle {
 
400
                border.width: control.activeFocus ? 3 :0
 
401
                color: "#222021"
 
402
                border.color: control.activeFocus ? "#ffffff" : "#222021"
 
403
                radius: 5
 
404
            }
 
405
            label: Image {
 
406
                source: "images/serial_no_selected.png"
 
407
            }
 
408
        }
 
409
        Keys.onReturnPressed: {
 
410
            getSerialNumber()
 
411
        }
 
412
    }
 
413
 
 
414
    Button {
 
415
        id: f_wversion_selectedCU50
 
416
        x: 85
 
417
        y: 637
 
418
        opacity: 1
 
419
        action: firmwareVersion
 
420
        activeFocusOnPress : true
 
421
        tooltip: "Click to view the firmware version of the camera"
 
422
        style: ButtonStyle {
 
423
            background: Rectangle {
 
424
                border.width: control.activeFocus ? 3 :0
 
425
                color: "#222021"
 
426
                border.color: control.activeFocus ? "#ffffff" : "#222021"
 
427
                radius: 5
 
428
            }
 
429
            label: Image {
 
430
                source: "images/f_wversion_selected.png"
 
431
            }
 
432
        }
 
433
        Keys.onReturnPressed: {
 
434
            getFirmwareVersion()
 
435
        }
 
436
    }
 
437
 
 
438
    MessageDialog {
 
439
        id: messageDialog
 
440
        icon: StandardIcon.Information
 
441
        width: 200
 
442
        onAccepted: {
 
443
            close()
 
444
        }
 
445
        Component.onCompleted:{
 
446
            close()
 
447
        }
 
448
    }
 
449
 
 
450
    Camproperty{
 
451
        id:camproperty
 
452
 
 
453
    }
 
454
 
 
455
    Uvccamera {
 
456
        id: uvccamera
 
457
        onTitleTextChanged: {
 
458
            messageDialog.title = _title.toString()
 
459
            messageDialog.text = _text.toString()
 
460
            messageDialog.open()
 
461
        }
 
462
        onSerialNumber:{
 
463
            messageDialog.title = qsTr("Serial Number")
 
464
            messageDialog.text = serialNumber;
 
465
        }
 
466
    }
 
467
 
 
468
    See3Cam50 {
 
469
        id: seecam50
 
470
        onUpdateTorchCheckBox: {
 
471
            if(torch_Check_state === "1") {
 
472
                torch_ctrl.checked = true;
 
473
            }
 
474
            else {
 
475
                torch_ctrl.checked =  false;
 
476
            }
 
477
        }
 
478
       
 
479
     }
 
480
 
 
481
    See3CamCtrl {
 
482
        id: see3camctrl
 
483
        onDeviceStatus:{
 
484
            messageDialog.title = title.toString()
 
485
            messageDialog.text = message.toString()
 
486
            messageDialog.open()
 
487
        }
 
488
    }
 
489
 
 
490
    See3CamGpio {
 
491
        id: see3camGpio
 
492
        onDeviceStatus:{
 
493
            messageDialog.title = title.toString()
 
494
            messageDialog.text = message.toString()
 
495
            messageDialog.open()
 
496
        }
 
497
        onGpioLevel:{
 
498
            if(level === 0) {
 
499
                if(outputPinFlag)
 
500
                    radioLowcu50.checked = true
 
501
                else
 
502
                    gpi_level_high.text = "GPI Level : <b>Low</b>"
 
503
            } else {
 
504
                if(outputPinFlag)
 
505
                    radioHighcu50.checked = true
 
506
                else
 
507
                    gpi_level_high.text = "GPI Level : <b>High</b>"
 
508
            }
 
509
        }
 
510
    }
 
511
 
 
512
    function getGpiStatus() {
 
513
        outputPinFlag = false
 
514
        if(gpi_no_boxCU50.currentIndex == 0){
 
515
            see3camGpio.getGpioLevel(See3CamGpio.IN1)  //PIN Number
 
516
        } else {
 
517
            see3camGpio.getGpioLevel(See3CamGpio.IN2)  //PIN Number
 
518
        }
 
519
    }
 
520
 
 
521
    function getSerialNumber() {
 
522
        uvccamera.getSerialNumber()
 
523
        messageDialog.open()
 
524
    }
 
525
 
 
526
    function getFirmwareVersion() {
 
527
        uvccamera.getFirmWareVersion()
 
528
        messageDialog.open()
 
529
    }
 
530
 
 
531
    Component.onCompleted:{
 
532
        gpioOutputBox.forceActiveFocus()
 
533
        
 
534
        seecam50.getTorchLevel()
 
535
        outputPinFlag = true
 
536
        see3camGpio.getGpioLevel(See3CamGpio.OUT1)
 
537
        uniqueSerialNumber = uvccamera.retrieveSerialNumber()
 
538
 
 
539
         // Added by Navya : 07 May 2019 - To get usbspeed and assign skipframes accordingly
 
540
        value_ret=camproperty.getUsbSpeed(uniqueSerialNumber)
 
541
        if(value_ret > 0){
 
542
            if(value_ret == 1)
 
543
                frameToSkip = 8
 
544
            else
 
545
                frameToSkip = 5
 
546
            root.updateFrametoSkip(frameToSkip);
 
547
        }
 
548
    }
 
549
 
 
550
    Component.onDestruction:{
 
551
        frameToSkip = 3
 
552
        root.updateFrametoSkip(frameToSkip);
 
553
    }
 
554
}