-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
executable file
·558 lines (457 loc) · 24.9 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
#!/usr/bin/python3
import os
import signal
import sys
import copy
import socket
import time
import binascii
from PyQt5 import uic
from PyQt5.QtGui import QImage, QPixmap
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import (QCoreApplication, QObject, QRunnable, QThread,
QThreadPool, pyqtSignal, pyqtSlot)
from PyQt5.uic.properties import QtCore
signal.signal(signal.SIGINT, signal.SIG_DFL)
class Command:
data = []
arg_lambda = None
def __init__(self, data, argument_lambda=None):
self.data = data
self.arg_lambda = argument_lambda
def get_command(self, args):
if self.arg_lambda is not None:
return self.arg_lambda(self, args)
return self.data
def preset(self, args):
self.data[5] = args
return self.data
def pan_relative_lambda(self, args):
data = copy.deepcopy(self.data)
# 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF
# VV WW 0Y 0Y 0Y 0Y 0Z 0Z 0Z 0Z FF
speed_pan = int(args["speed"] * 0x17) + 1
speed_tilt = int(args["speed"] * 0x13) + 1
data.extend([speed_pan, speed_tilt]) # half speed | between 0x01 and 0x18, 0x01 and 0x14
data.extend([0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0xFF])
return data
def oneshot_ptz_lambda(self, args):
data = copy.deepcopy(self.data)
# 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF
# VV WW 0Y 0Y 0Y 0Y 0Z 0Z 0Z 0Z FF
speed_pan = int(args["speed"] * 0x17) + 1
speed_tilt = int(args["speed"] * 0x13) + 1
data.extend([speed_pan, speed_tilt]) # half speed | between 0x01 and 0x18, 0x01 and 0x14
data.extend(args["postfix"])
return data
def zoom_tele_variable(self, args):
speed = int(args["speed"] * 6) + 1
self.data[4] = 0x20 + speed
return self.data
def zoom_wide_variable(self, args):
speed = int(args["speed"] * 6) + 1
self.data[4] = 0x30 + speed
return self.data
def exposure_command(self, args):
data = copy.deepcopy(self.data)
data[6] = int(args / 16)
data[7] = args & 0x0F
return data
def ae_mode_lambda(self, args):
modes = {
"Full Auto": 0x00,
"Manual": 0x03,
"Tv": 0x0A,
"Av": 0x0B,
"Brightness": 0x0D
}
new_data = copy.deepcopy(self.data)
new_data[4] = modes[args]
return new_data
def wb_mode_lambda(self, args):
modes = {
"Auto": 0x00,
"Indoor": 0x01,
"Outdoor": 0x02,
"One Push": 0x03, # Mode Set
"Auto Tracking": 0x04,
"Manual": 0x05
}
new_data = copy.deepcopy(self.data)
new_data[4] = modes[args]
return new_data
class Camera(QRunnable):
address = "192.168.0.100"
port = 52381
current_sequence_number = 0
sequence_callback = None
ui = None
receive_socket = None
commands = dict()
commands["backlight on"] = Command([0x81, 0x01, 0x04, 0x33, 0x03, 0xFF])
commands["backlight off"] = Command([0x81, 0x01, 0x04, 0x33, 0x02, 0xFF])
commands["set preset x"] = Command([0x81, 0x01, 0x04, 0x3F, 0x01, 0x00, 0xFF], argument_lambda=preset)
commands["recall preset x"] = Command([0x81, 0x01, 0x04, 0x3F, 0x02, 0x00, 0xFF], argument_lambda=preset)
commands["home"] = Command([0x81, 0x01, 0x06, 0x04, 0xFF])
commands["pan relative position"] = Command(
[0x81, 0x01, 0x06, 0x03], argument_lambda=pan_relative_lambda)
commands["move"] = Command([0x81, 0x01, 0x06, 0x01], argument_lambda=oneshot_ptz_lambda)
commands["stop"] = Command([0x81, 0x01, 0x06, 0x01, 0x01, 0x01, 0x03, 0x03, 0xFF])
commands["osd on"] = Command([0x81, 0x01, 0x7E, 0x01, 0x18, 0x02, 0xFF])
commands["osd off"] = Command([0x81, 0x01, 0x7E, 0x01, 0x18, 0x03, 0xFF])
commands["low latency on"] = Command([0x81, 0x01, 0x7E, 0x01, 0x5A, 0x02, 0xFF])
commands["low latency off"] = Command([0x81, 0x01, 0x7E, 0x01, 0x5A, 0x03, 0xFF])
commands["zoom stop"] = Command([0x81, 0x01, 0x04, 0x07, 0x00, 0xFF])
commands["digital zoom on"] = Command([0x81, 0x01, 0x04, 0x06, 0x02, 0xFF])
commands["digital zoom off"] = Command([0x81, 0x01, 0x04, 0x06, 0x03, 0xFF])
commands["zoom tele std"] = Command([0x81, 0x01, 0x04, 0x07, 0x02, 0xFF])
commands["zoom wide std"] = Command([0x81, 0x01, 0x04, 0x07, 0x03, 0xFF])
commands["zoom tele var"] = Command([0x81, 0x01, 0x04, 0x07, 0x00, 0xFF], argument_lambda=zoom_tele_variable)
commands["zoom wide var"] = Command([0x81, 0x01, 0x04, 0x07, 0x00, 0xFF], argument_lambda=zoom_wide_variable)
commands["ae mode"] = Command([0x81, 0x01, 0x04, 0x39, 0x00, 0xFF],
argument_lambda=ae_mode_lambda)
commands["brighter"] = Command([0x81, 0x01, 0x04, 0x0D, 0x02, 0xFF])
commands["darker"] = Command([0x81, 0x01, 0x04, 0x0D, 0x03, 0xFF])
commands["af mode auto"] = Command([0x81, 0x01, 0x04, 0x38, 0x02, 0xFF])
commands["af mode manual"] = Command([0x81, 0x01, 0x04, 0x38, 0x03, 0xFF])
commands["af mode auto/manual"] = Command([0x81, 0x01, 0x04, 0x38, 0x10, 0xFF])
commands["af mode one push trigger"] = Command([0x81, 0x01, 0x04, 0x18, 0x01, 0xFF])
commands["focus far var"] = Command([0x81, 0x01, 0x04, 0x08, 0x00, 0xFF], argument_lambda=zoom_tele_variable)
commands["focus near var"] = Command([0x81, 0x01, 0x04, 0x08, 0x00, 0xFF], argument_lambda=zoom_wide_variable)
commands["focus stop"] = Command([0x81, 0x01, 0x04, 0x08, 0x00, 0xFF])
commands["wb mode"] = Command([0x81, 0x01, 0x04, 0x35, 0x00, 0xFF], argument_lambda=wb_mode_lambda)
commands["wb mode trigger"] = Command([0x81, 0x01, 0x04, 0x10, 0x05, 0xFF])
commands["red gain up"] = Command([0x81, 0x01, 0x04, 0x03, 0x02, 0xFF])
commands["red gain down"] = Command([0x81, 0x01, 0x04, 0x03, 0x03, 0xFF])
commands["red gain reset"] = Command([0x81, 0x01, 0x04, 0x03, 0x00, 0xFF])
commands["blue gain up"] = Command([0x81, 0x01, 0x04, 0x04, 0x02, 0xFF])
commands["blue gain down"] = Command([0x81, 0x01, 0x04, 0x04, 0x03, 0xFF])
commands["blue gain reset"] = Command([0x81, 0x01, 0x04, 0x04, 0x00, 0xFF])
commands["gain set"] = Command([0x81, 0x01, 0x04, 0x4C, 0x00, 0x00, 0x00, 0x00, 0xFF],
argument_lambda=exposure_command)
commands["shutter set"] = Command([0x81, 0x01, 0x04, 0x4A, 0x00, 0x00, 0x00, 0x00, 0xFF],
argument_lambda=exposure_command)
commands["fstop set"] = Command([0x81, 0x01, 0x04, 0x4B, 0x00, 0x00, 0x00, 0x00, 0xFF],
argument_lambda=exposure_command)
commands["ex_ae_comp set"] = Command([0x81, 0x01, 0x04, 0x4E, 0x00, 0x00, 0x00, 0x00, 0xFF],
argument_lambda=exposure_command)
commands["ex ae comp on"] = Command([0x81, 0x01, 0x04, 0x03E, 0x02, 0xFF])
commands["ex ae comp off"] = Command([0x81, 0x01, 0x04, 0x3E, 0x03, 0xFF])
# ex_ae_comp
# gain 8x 01 04 4C 00 00 0p 0q FF
# shutter 8x 01 04 4A 00 00 0p 0q FF
# fstop 8x 01 04 4B 00 00 0p 0q FF
def __init__(self, address="192.168.0.100", port=52381, sequence_callback=None):
super(Camera, self).__init__()
self.address = address
self.port = port
self.sequence_callback = sequence_callback
self.receive_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.receive_socket.bind(("0.0.0.0", self.port))
# self.send_command([0x01], prep_cmd=[0x02, 0x01])
# socket.socket(socket.AF_INET, socket.SOCK_DGRAM).sendto(bytes(prep_cmd), (self.address, self.port))
self.reset()
def reset(self):
self.current_sequence_number = 0
self.send_control_command([0x01])
self.current_sequence_number = 0
def increment_sequence(self):
self.current_sequence_number = self.current_sequence_number + 1
if self.sequence_callback is not None:
self.sequence_callback(self.current_sequence_number)
# self.current_sequence_number = 0xFFFFFFFF
def send_control_command(self, cmd):
buffy = bytearray([0x02, 0x00])
buffy.extend(bytearray(len(cmd).to_bytes(length=2, byteorder="little", signed=False)))
self.current_sequence_number = (self.current_sequence_number + 1) % 0xFFFFFFFF
buffy.extend(bytearray(self.current_sequence_number.to_bytes(length=4, byteorder="little", signed=False)))
buffy.extend(bytearray(cmd))
socket.socket(socket.AF_INET, socket.SOCK_DGRAM).sendto(bytes(buffy), (self.address, self.port))
def send_command(self, command, header=[0x01, 0x00]):
self.increment_sequence()
prep_cmd = copy.deepcopy(header)
prep_cmd.extend(bytearray([0x00, int(len(command))])) # payload type (2), followed by command length
prep_cmd.extend(bytearray(self.current_sequence_number.to_bytes(length=4, byteorder="little", signed=False)))
prep_cmd.extend(command)
socket.socket(socket.AF_INET, socket.SOCK_DGRAM).sendto(bytes(prep_cmd), (self.address, self.port))
def run(self):
while True:
data, addr = self.receive_socket.recvfrom(1024)
# bad command response 0200 0002ba 0000000f01
# good cmmand response 0111 0003d3 0000009041ff
data = bytearray(data)
curr_seq_num = int.from_bytes(data[2:5], "big", signed=False)
print("SEQ " + str(curr_seq_num))
print(binascii.hexlify(data[2:5]))
# self.current_sequence_number = curr_seq_num
print(binascii.hexlify(data))
print(self.current_sequence_number)
time.sleep(0.1)
class App(QApplication):
def __init__(self):
super(App, self).__init__([])
self.ui = uic.loadUi("main.ui")
cam = Camera()
self.cam = cam
def event(self, event):
print(event.type())
if event.type() == 20:
os._exit(0)
return False
def main(self):
ui = self.ui
ui = self.ui
cam = self.cam
cam.ui = ui
# QThreadPool.globalInstance().setMaxThreadCount(50)
QThreadPool.globalInstance().start(cam)
# Presets
ui.setzero.clicked.connect(lambda: cam.send_command(cam.commands["set preset x"].get_command(0)))
ui.getzero.clicked.connect(lambda: cam.send_command(cam.commands["recall preset x"].get_command(0)))
ui.setone.clicked.connect(lambda: cam.send_command(cam.commands["set preset x"].get_command(1)))
ui.getone.clicked.connect(lambda: cam.send_command(cam.commands["recall preset x"].get_command(1)))
ui.settwo.clicked.connect(lambda: cam.send_command(cam.commands["set preset x"].get_command(2)))
ui.gettwo.clicked.connect(lambda: cam.send_command(cam.commands["recall preset x"].get_command(2)))
ui.setthree.clicked.connect(lambda: cam.send_command(cam.commands["set preset x"].get_command(3)))
ui.getthree.clicked.connect(lambda: cam.send_command(cam.commands["recall preset x"].get_command(3)))
ui.setfour.clicked.connect(lambda: cam.send_command(cam.commands["set preset x"].get_command(4)))
ui.getfour.clicked.connect(lambda: cam.send_command(cam.commands["recall preset x"].get_command(4)))
ui.setfive.clicked.connect(lambda: cam.send_command(cam.commands["set preset x"].get_command(5)))
ui.getfive.clicked.connect(lambda: cam.send_command(cam.commands["recall preset x"].get_command(5)))
ui.setsix.clicked.connect(lambda: cam.send_command(cam.commands["set preset x"].get_command(6)))
ui.getsix.clicked.connect(lambda: cam.send_command(cam.commands["recall preset x"].get_command(6)))
ui.setseven.clicked.connect(lambda: cam.send_command(cam.commands["set preset x"].get_command(7)))
ui.getseven.clicked.connect(lambda: cam.send_command(cam.commands["recall preset x"].get_command(7)))
ui.seteight.clicked.connect(lambda: cam.send_command(cam.commands["set preset x"].get_command(8)))
ui.geteight.clicked.connect(lambda: cam.send_command(cam.commands["recall preset x"].get_command(8)))
ui.setnine.clicked.connect(lambda: cam.send_command(cam.commands["set preset x"].get_command(9)))
ui.getnine.clicked.connect(lambda: cam.send_command(cam.commands["recall preset x"].get_command(9)))
ui.setten.clicked.connect(lambda: cam.send_command(cam.commands["set preset x"].get_command(10)))
ui.getten.clicked.connect(lambda: cam.send_command(cam.commands["recall preset x"].get_command(10)))
ui.seteleven.clicked.connect(lambda: cam.send_command(cam.commands["set preset x"].get_command(11)))
ui.geteleven.clicked.connect(lambda: cam.send_command(cam.commands["recall preset x"].get_command(11)))
ui.settwelve.clicked.connect(lambda: cam.send_command(cam.commands["set preset x"].get_command(12)))
ui.gettwelve.clicked.connect(lambda: cam.send_command(cam.commands["recall preset x"].get_command(12)))
ui.setthirteen.clicked.connect(lambda: cam.send_command(cam.commands["set preset x"].get_command(13)))
ui.getthirteen.clicked.connect(lambda: cam.send_command(cam.commands["recall preset x"].get_command(13)))
ui.setfourteen.clicked.connect(lambda: cam.send_command(cam.commands["set preset x"].get_command(14)))
ui.getfourteen.clicked.connect(lambda: cam.send_command(cam.commands["recall preset x"].get_command(14)))
ui.setfifteen.clicked.connect(lambda: cam.send_command(cam.commands["set preset x"].get_command(15)))
ui.getfifteen.clicked.connect(lambda: cam.send_command(cam.commands["recall preset x"].get_command(15)))
ui.ae_mode.currentTextChanged.connect(
lambda: cam.send_command(cam.commands["ae mode"].get_command(ui.ae_mode.currentText())))
ui.brighter.clicked.connect(lambda: cam.send_command(cam.commands["brighter"].get_command(None)))
ui.darker.clicked.connect(lambda: cam.send_command(cam.commands["darker"].get_command(None)))
ui.wb_trigger.clicked.connect(lambda: cam.send_command(cam.commands["wb mode trigger"].get_command(None)))
ui.wb_mode.currentTextChanged.connect(
lambda: cam.send_command(cam.commands["wb mode"].get_command(ui.wb_mode.currentText())))
ui.red_gain_more.clicked.connect(lambda: cam.send_command(cam.commands["red gain up"].get_command(None)))
ui.red_gain_less.clicked.connect(lambda: cam.send_command(cam.commands["red gain down"].get_command(None)))
ui.red_gain_reset.clicked.connect(lambda: cam.send_command(cam.commands["red gain reset"].get_command(None)))
ui.blue_gain_more.clicked.connect(lambda: cam.send_command(cam.commands["blue gain up"].get_command(None)))
ui.blue_gain_less.clicked.connect(lambda: cam.send_command(cam.commands["blue gain down"].get_command(None)))
ui.blue_gain_reset.clicked.connect(lambda: cam.send_command(cam.commands["blue gain reset"].get_command(None)))
def af_mode():
modeFuncs = {
"On": cam.commands["af mode auto"].get_command(None),
"Manual": cam.commands["af mode manual"].get_command(None),
"Auto/Manual": cam.commands["af mode auto/manual"].get_command(None),
"One Push Trigger": cam.commands["af mode one push trigger"].get_command(None)
}
cam.send_command(modeFuncs[ui.af_mode.currentText()])
ui.af_mode.currentTextChanged.connect(af_mode)
fstop = {
"f/1.8": cam.commands["fstop set"].get_command(0x11),
"f/2.0": cam.commands["fstop set"].get_command(0x10),
"f/2.4": cam.commands["fstop set"].get_command(0x0F),
"f/2.8": cam.commands["fstop set"].get_command(0x0E),
"f/3.4": cam.commands["fstop set"].get_command(0x0D),
"f/4.0": cam.commands["fstop set"].get_command(0x0C),
"f/4.8": cam.commands["fstop set"].get_command(0x0B),
"f/5.6": cam.commands["fstop set"].get_command(0x0A),
"f/6.8": cam.commands["fstop set"].get_command(0x09),
"f/8.0": cam.commands["fstop set"].get_command(0x08),
"f/9.6": cam.commands["fstop set"].get_command(0x07),
"f/11.0": cam.commands["fstop set"].get_command(0x06),
"f/14.0": cam.commands["fstop set"].get_command(0x05),
"Closed": cam.commands["fstop set"].get_command(0x00),
}
ui.fstop.clear()
ui.fstop.addItems(fstop.keys())
ui.fstop.currentTextChanged.connect(lambda: cam.send_command(fstop[ui.fstop.currentText()]))
shutter = {
"1/250 | 1/215": cam.commands["shutter set"].get_command(0x0B),
"1/180 | 1/150": cam.commands["shutter set"].get_command(0x0A),
"1/125 | 1/120": cam.commands["shutter set"].get_command(0x09),
"1/100 | 1/100": cam.commands["shutter set"].get_command(0x08),
"1/90 | 1/75": cam.commands["shutter set"].get_command(0x07),
"1/60 | 1/50": cam.commands["shutter set"].get_command(0x06),
"1/30 | 1/25": cam.commands["shutter set"].get_command(0x05),
}
ui.shutter.clear()
ui.shutter.addItems(shutter.keys())
ui.shutter.currentTextChanged.connect(lambda: cam.send_command(shutter[ui.shutter.currentText()]))
ex_gain = {
"0dB": cam.commands["gain set"].get_command(0x01),
"3dB": cam.commands["gain set"].get_command(0x02),
"6dB": cam.commands["gain set"].get_command(0x03),
"9dB": cam.commands["gain set"].get_command(0x04),
"12dB": cam.commands["gain set"].get_command(0x05),
"15dB": cam.commands["gain set"].get_command(0x06),
"18dB": cam.commands["gain set"].get_command(0x07),
"21dB": cam.commands["gain set"].get_command(0x08),
"24dB": cam.commands["gain set"].get_command(0x09),
"27dB": cam.commands["gain set"].get_command(0x0A),
"30dB": cam.commands["gain set"].get_command(0x0B),
"33dB": cam.commands["gain set"].get_command(0x0C),
"36dB": cam.commands["gain set"].get_command(0x0D),
"39dB": cam.commands["gain set"].get_command(0x0E),
"43dB": cam.commands["gain set"].get_command(0x0F),
}
ui.gain.clear()
ui.gain.addItems(ex_gain.keys())
ui.gain.currentTextChanged.connect(lambda: cam.send_command(ex_gain[ui.gain.currentText()]))
ex_ae_comps = {
"-10.5dB": cam.commands["ex_ae_comp set"].get_command(0x00),
"-9dB": cam.commands["ex_ae_comp set"].get_command(0x01),
"-7.5dB": cam.commands["ex_ae_comp set"].get_command(0x02),
"-6dB": cam.commands["ex_ae_comp set"].get_command(0x03),
"-4.5dB": cam.commands["ex_ae_comp set"].get_command(0x04),
"-3dB": cam.commands["ex_ae_comp set"].get_command(0x05),
"-1.5dB": cam.commands["ex_ae_comp set"].get_command(0x06),
"0dB": cam.commands["ex_ae_comp set"].get_command(0x07),
"+1.5dB": cam.commands["ex_ae_comp set"].get_command(0x08),
"+3dB": cam.commands["ex_ae_comp set"].get_command(0x09),
"+4.5dB": cam.commands["ex_ae_comp set"].get_command(0x0A),
"+6dB": cam.commands["ex_ae_comp set"].get_command(0x0B),
"+7.5dB": cam.commands["ex_ae_comp set"].get_command(0x0C),
"+9dB": cam.commands["ex_ae_comp set"].get_command(0x0D),
"+10.5dB": cam.commands["ex_ae_comp set"].get_command(0x0E),
}
ui.ex_comp.clear()
ui.ex_comp.addItems(ex_ae_comps.keys())
ui.ex_comp.currentTextChanged.connect(lambda: cam.send_command(ex_ae_comps[ui.ex_comp.currentText()]))
def seq_callback(seq):
ui.seq_number.display(seq)
cam.sequence_callback = seq_callback
def osd_func():
if ui.osd.checkState():
cam.send_command(cam.commands["osd on"].get_command(None))
else:
cam.send_command(cam.commands["osd off"].get_command(None))
ui.osd.clicked.connect(osd_func)
def ex_ae_enabled_func():
if ui.ex_ae_comp_on.checkState():
cam.send_command(cam.commands["ex ae comp on"].get_command(None))
else:
cam.send_command(cam.commands["ex ae comp off"].get_command(None))
ui.ex_ae_comp_on.clicked.connect(ex_ae_enabled_func)
def digital_zoom_func():
if ui.digital_zoom.checkState():
cam.send_command(cam.commands["digital zoom on"].get_command(None))
else:
cam.send_command(cam.commands["digital zoom off"].get_command(None))
ui.digital_zoom.clicked.connect(digital_zoom_func)
def low_latency_func():
if ui.low_latency.checkState():
cam.send_command(cam.commands["low latency on"].get_command(None))
else:
cam.send_command(cam.commands["low latency off"].get_command(None))
ui.low_latency.clicked.connect(low_latency_func)
ui.up.clicked.connect(
lambda: cam.send_command(cam.commands["move"].get_command(
{
"speed": ui.speed_bar.value() / 100,
"postfix": [0x03, 0x01, 0xFF],
}
)))
ui.down.clicked.connect(
lambda: cam.send_command(cam.commands["move"].get_command(
{
"speed": ui.speed_bar.value() / 100,
"postfix": [0x03, 0x02, 0xFF],
}
)))
ui.left.clicked.connect(
lambda: cam.send_command(cam.commands["move"].get_command(
{
"speed": ui.speed_bar.value() / 100,
"postfix": [0x01, 0x03, 0xFF],
}
)))
ui.right.clicked.connect(
lambda: cam.send_command(cam.commands["move"].get_command(
{
"speed": ui.speed_bar.value() / 100,
"postfix": [0x02, 0x03, 0xFF],
}
)))
ui.ul.clicked.connect(
lambda: cam.send_command(cam.commands["move"].get_command(
{
"speed": ui.speed_bar.value() / 100,
"postfix": [0x01, 0x01, 0xFF],
}
)))
ui.ur.clicked.connect(
lambda: cam.send_command(cam.commands["move"].get_command(
{
"speed": ui.speed_bar.value() / 100,
"postfix": [0x02, 0x01, 0xFF],
}
)))
ui.dl.clicked.connect(
lambda: cam.send_command(cam.commands["move"].get_command(
{
"speed": ui.speed_bar.value() / 100,
"postfix": [0x01, 0x02, 0xFF],
}
)))
ui.dr.clicked.connect(
lambda: cam.send_command(cam.commands["move"].get_command(
{
"speed": ui.speed_bar.value() / 100,
"postfix": [0x02, 0x02, 0xFF],
}
)))
ui.focus_far.clicked.connect(
lambda: cam.send_command(cam.commands["focus far var"].get_command(
{
"speed": ui.focus_speed.value() / 100,
}
)))
ui.focus_near.clicked.connect(
lambda: cam.send_command(cam.commands["focus near var"].get_command(
{
"speed": ui.focus_speed.value() / 100,
}
)))
ui.focus_stop.clicked.connect(lambda: cam.send_command(cam.commands["focus stop"].get_command(None)))
ui.trigger_af.clicked.connect(
lambda: cam.send_command(cam.commands["af mode one push trigger"].get_command(None)))
ui.tele_var.clicked.connect(
lambda: cam.send_command(cam.commands["zoom tele var"].get_command(
{
"speed": ui.zoom_bar.value() / 100,
}
)))
ui.wide_var.clicked.connect(
lambda: cam.send_command(cam.commands["zoom wide var"].get_command(
{
"speed": ui.zoom_bar.value() / 100,
}
)))
ui.zoom_stop.clicked.connect(lambda: cam.send_command(cam.commands["zoom stop"].get_command(None)))
ui.tele_std.clicked.connect(lambda: cam.send_command(cam.commands["zoom tele std"].get_command(None)))
ui.wide_std.clicked.connect(lambda: cam.send_command(cam.commands["zoom wide std"].get_command(None)))
ui.home.clicked.connect(lambda: cam.send_command(cam.commands["home"].get_command(None)))
ui.stop.clicked.connect(lambda: cam.send_command(cam.commands["stop"].get_command(None)))
ui.speed_plus.clicked.connect(lambda: ui.speed_bar.setValue(ui.speed_bar.value() + 1))
ui.speed_minus.clicked.connect(lambda: ui.speed_bar.setValue(ui.speed_bar.value() - 1))
ui.speed_reset.clicked.connect(lambda: ui.speed_bar.setValue(50))
ui.show()
sys.exit(self.exec_())
if __name__ == '__main__':
# app = QApplication(sys.argv)
ex = App()
ex.main()