wipe, loop, include ptz
This commit is contained in:
parent
d711133b86
commit
0883f50f25
22
camera.py
22
camera.py
|
@ -99,6 +99,19 @@ class Camera:
|
||||||
self.channel = channel
|
self.channel = channel
|
||||||
self.auth = HTTPDigestAuth(self.username, self.password)
|
self.auth = HTTPDigestAuth(self.username, self.password)
|
||||||
|
|
||||||
|
def put_aux(self, cmd):
|
||||||
|
data = PTZData(cmd, root='PTZAux')
|
||||||
|
r = self.put('auxcontrols/1', data)
|
||||||
|
return r
|
||||||
|
|
||||||
|
def wipe(self):
|
||||||
|
cmd = {
|
||||||
|
'id': '1',
|
||||||
|
'type': 'WIPER',
|
||||||
|
'status': 'on'
|
||||||
|
}
|
||||||
|
r = self.put_aux(cmd)
|
||||||
|
|
||||||
def url(self, method):
|
def url(self, method):
|
||||||
return 'http://{}/ISAPI/PTZCtrl/channels/{}/{}'.format(self.ip, self.channel, method)
|
return 'http://{}/ISAPI/PTZCtrl/channels/{}/{}'.format(self.ip, self.channel, method)
|
||||||
|
|
||||||
|
@ -155,11 +168,14 @@ class Camera:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print('presets loaded')
|
print('presets loaded')
|
||||||
|
|
||||||
def sequence(self, steps=[], speed=12, goto_first=True):
|
def sequence(self, steps=[], speed=12, goto_first=True, loop=False):
|
||||||
self.sequence_start = 0
|
self.sequence_start = 0
|
||||||
if goto_first:
|
if goto_first:
|
||||||
#self.goto_preset(steps[0], pan=100, tilt=100, zoom=100)
|
#self.goto_preset(steps[0], pan=100, tilt=100, zoom=100)
|
||||||
first = steps[0]
|
first = steps[0]
|
||||||
|
steps = steps[1:]
|
||||||
|
while True:
|
||||||
|
if goto_first:
|
||||||
if isinstance(first, dict):
|
if isinstance(first, dict):
|
||||||
if 'seqid' in first and first['seqid'] not in self.segment_times:
|
if 'seqid' in first and first['seqid'] not in self.segment_times:
|
||||||
self.segment_times[first['seqid']] = 0
|
self.segment_times[first['seqid']] = 0
|
||||||
|
@ -169,7 +185,6 @@ class Camera:
|
||||||
if self.abort:
|
if self.abort:
|
||||||
return
|
return
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
steps = steps[1:]
|
|
||||||
self.sequence_start = t0 = time.time()
|
self.sequence_start = t0 = time.time()
|
||||||
for step in steps:
|
for step in steps:
|
||||||
self.next_target = step
|
self.next_target = step
|
||||||
|
@ -202,6 +217,8 @@ class Camera:
|
||||||
self.segment_times[step['seqid']] = segment_time
|
self.segment_times[step['seqid']] = segment_time
|
||||||
self.sequence_time = time.time() - t0
|
self.sequence_time = time.time() - t0
|
||||||
self.next_target = None
|
self.next_target = None
|
||||||
|
if not loop:
|
||||||
|
break
|
||||||
|
|
||||||
def fast_preset(self, id, wait=False):
|
def fast_preset(self, id, wait=False):
|
||||||
self.put('presets/%s/goto' % id, None)
|
self.put('presets/%s/goto' % id, None)
|
||||||
|
@ -382,3 +399,4 @@ class Camera:
|
||||||
preset['position'] = preset.pop('AbsoluteHigh')
|
preset['position'] = preset.pop('AbsoluteHigh')
|
||||||
preset['name'] = preset.pop('presetName')
|
preset['name'] = preset.pop('presetName')
|
||||||
return presets
|
return presets
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,11 @@ class API(object):
|
||||||
result['sequence'] = state['sequence']
|
result['sequence'] = state['sequence']
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def wipe(self, **data):
|
||||||
|
result = {}
|
||||||
|
ctl.camera.wipe()
|
||||||
|
return result
|
||||||
|
|
||||||
#@run_async
|
#@run_async
|
||||||
def api_task(request, callback):
|
def api_task(request, callback):
|
||||||
api = API()
|
api = API()
|
||||||
|
|
|
@ -83,6 +83,7 @@
|
||||||
<h2>CAMP cam canal:</h2>
|
<h2>CAMP cam canal:</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<li><button class="run">run</button></li>
|
<li><button class="run">run</button></li>
|
||||||
|
<li><button class="loop">loop</button></li>
|
||||||
<li><button class="goto">go to selected</button></li>
|
<li><button class="goto">go to selected</button></li>
|
||||||
<li><button class="run_from">run from selected</button></li>
|
<li><button class="run_from">run from selected</button></li>
|
||||||
<li><button class="continue_from">continue to selected</button></li>
|
<li><button class="continue_from">continue to selected</button></li>
|
||||||
|
@ -106,6 +107,8 @@
|
||||||
<li><input class="import_sequence" type="file">import sequence</input></li>
|
<li><input class="import_sequence" type="file">import sequence</input></li>
|
||||||
<li><input class="import_presets" type="file">import presets</input></li>
|
<li><input class="import_presets" type="file">import presets</input></li>
|
||||||
<li><button class="shift_presets">shift presets</button></li>
|
<li><button class="shift_presets">shift presets</button></li>
|
||||||
|
<h2>PTZ:</h2>
|
||||||
|
<iframe src="/static/ptz.html" width="100%" height="300px" frameborder=0></iframe>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -456,6 +456,19 @@ $('button.run').on({click: function() {
|
||||||
//console.log(response)
|
//console.log(response)
|
||||||
})
|
})
|
||||||
}})
|
}})
|
||||||
|
$('button.loop').on({click: function() {
|
||||||
|
data.forEach(function(seq) {
|
||||||
|
if (!seq.seqid) {
|
||||||
|
seq.seqid = uuidv4()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
api('run', {
|
||||||
|
'steps': data,
|
||||||
|
'loop': true
|
||||||
|
}, function(response) {
|
||||||
|
//console.log(response)
|
||||||
|
})
|
||||||
|
}})
|
||||||
$('button.run_from').on({click: function() {
|
$('button.run_from').on({click: function() {
|
||||||
var selected = grid.getSelectedRows()[0];
|
var selected = grid.getSelectedRows()[0];
|
||||||
api('run', {
|
api('run', {
|
||||||
|
|
|
@ -50,11 +50,20 @@
|
||||||
Speed: <input name="speed" value="1" style="width:30px"></input>
|
Speed: <input name="speed" value="1" style="width:30px"></input>
|
||||||
Duration: <input name="duration" value="4" style="width:30px"></input>
|
Duration: <input name="duration" value="4" style="width:30px"></input>
|
||||||
<br>
|
<br>
|
||||||
|
<br>
|
||||||
|
<li><button class="wipe">wipe</button></li>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(function () {
|
$(function () {
|
||||||
init_ptz()
|
init_ptz()
|
||||||
|
|
||||||
|
document.querySelector('button.wipe').addEventListener('click', () => {
|
||||||
|
api('wipe', {
|
||||||
|
}, function(response) {
|
||||||
|
console.log(response)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user