Created
July 11, 2020 15:32
-
-
Save samirsogay/4e05779aa0a95fa10c6ac22d097514f0 to your computer and use it in GitHub Desktop.
Pan Tilt code for Motioneye
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
down_2 | |
#!/usr/bin/env python | |
from __future__ import division | |
import time | |
import subprocess | |
with open('/etc/motioneye/vert_pos_2', 'r') as f: | |
vert_pos_2 = int(f.readline()) | |
print vert_pos_2 | |
f.close() | |
vert_pos_2 += 15 | |
if vert_pos_2>180: | |
vert_pos_2=180 | |
subprocess.call('curl -X GET --connect-timeout 5 http://192.168.100.159/arduino/tilt/' + str(vert_pos_2) + ' > /dev/null', shell=True) | |
with open('/etc/motioneye/vert_pos_2', 'w') as f: | |
f.write(str(vert_pos_2)) | |
f.close() | |
raise SystemExit | |
down_3 | |
#!/usr/bin/env python | |
from __future__ import division | |
import time | |
import subprocess | |
with open('/etc/motioneye/vert_pos_3', 'r') as f: | |
vert_pos_3 = int(f.readline()) | |
print vert_pos_3 | |
f.close() | |
vert_pos_3 += 15 | |
if vert_pos_3>180: | |
vert_pos_3=180 | |
subprocess.call('curl -X GET --connect-timeout 5 http://192.168.100.114:9595/api/tilt/' + str(vert_pos_3) + ' > /dev/null', shell=True) | |
with open('/etc/motioneye/vert_pos_3', 'w') as f: | |
f.write(str(vert_pos_3)) | |
f.close() | |
raise SystemExit | |
left_2 | |
#!/usr/bin/env python | |
from __future__ import division | |
import time | |
import subprocess | |
with open('/etc/motioneye/horz_pos_2', 'r') as f: | |
horz_pos_2 = int(f.readline()) | |
print horz_pos_2 | |
f.close() | |
horz_pos_2 -= 15 | |
if horz_pos_2<0: | |
horz_pos_2=0 | |
subprocess.call('curl -X GET --connect-timeout 5 http://192.168.100.159/arduino/pan/' + str(horz_pos_2) + ' > /dev/null', shell=True) | |
with open('/etc/motioneye/horz_pos_2', 'w') as f: | |
f.write(str(horz_pos_2)) | |
f.close() | |
raise SystemExit | |
left_3 | |
#!/usr/bin/env python | |
from __future__ import division | |
import time | |
import subprocess | |
with open('/etc/motioneye/horz_pos_3', 'r') as f: | |
horz_pos_3 = int(f.readline()) | |
print horz_pos_3 | |
f.close() | |
horz_pos_3 += 15 | |
if horz_pos_3>180: | |
horz_pos_3=180 | |
subprocess.call('curl -X GET --connect-timeout 5 http://192.168.100.114:9595/api/pan/' + str(horz_pos_3) + ' > /dev/null', shell=True) | |
with open('/etc/motioneye/horz_pos_3', 'w') as f: | |
f.write(str(horz_pos_3)) | |
f.close() | |
raise SystemExit | |
preset1_2 | |
#!/bin/bash | |
URL1="http://192.168.100.159/arduino/pan/90" | |
URL2="http://192.168.100.159/arduino/tilt/90" | |
METHOD="POST" | |
TIMEOUT="5" | |
curl -X $METHOD --connect-timeout $TIMEOUT "$URL1" > /dev/null | |
curl -X $METHOD --connect-timeout $TIMEOUT "$URL2" > /dev/null | |
preset1_3 | |
#!/bin/bash | |
URL1="http://192.168.100.114:9595/api/pan/90" | |
URL2="http://192.168.100.114:9595/api/tilt/120" | |
METHOD="GET" | |
TIMEOUT="5" | |
curl -X $METHOD --connect-timeout $TIMEOUT "$URL1" > /dev/null | |
curl -X $METHOD --connect-timeout $TIMEOUT "$URL2" > /dev/null | |
right_2 | |
#!/usr/bin/env python | |
from __future__ import division | |
import time | |
import subprocess | |
with open('/etc/motioneye/horz_pos_2', 'r') as f: | |
horz_pos_2 = int(f.readline()) | |
print horz_pos_2 | |
f.close() | |
horz_pos_2 += 15 | |
if horz_pos_2>180: | |
horz_pos_2=180 | |
subprocess.call('curl -X GET --connect-timeout 5 http://192.168.100.159/arduino/pan/' + str(horz_pos_2) + ' > /dev/null', shell=True) | |
with open('/etc/motioneye/horz_pos_2', 'w') as f: | |
f.write(str(horz_pos_2)) | |
f.close() | |
raise SystemExit | |
right_3 | |
#!/usr/bin/env python | |
from __future__ import division | |
import time | |
import subprocess | |
with open('/etc/motioneye/horz_pos_3', 'r') as f: | |
horz_pos_3 = int(f.readline()) | |
print horz_pos_3 | |
f.close() | |
horz_pos_3 -= 15 | |
if horz_pos_3<0: | |
horz_pos_3=0 | |
subprocess.call('curl -X GET --connect-timeout 5 http://192.168.100.114:9595/api/pan/' + str(horz_pos_3) + ' > /dev/null', shell=True) | |
with open('/etc/motioneye/horz_pos_3', 'w') as f: | |
f.write(str(horz_pos_3)) | |
f.close() | |
raise SystemExit | |
up_2 | |
#!/usr/bin/env python | |
from __future__ import division | |
import time | |
import subprocess | |
with open('/etc/motioneye/vert_pos_2', 'r') as f: | |
vert_pos_2 = int(f.readline()) | |
print vert_pos_2 | |
f.close() | |
vert_pos_2 -= 15 | |
if vert_pos_2<0: | |
vert_pos_2=0 | |
subprocess.call('curl -X GET --connect-timeout 5 http://192.168.100.159/arduino/tilt/' + str(vert_pos_2) + ' > /dev/null', shell=True) | |
with open('/etc/motioneye/vert_pos_2', 'w') as f: | |
f.write(str(vert_pos_2)) | |
f.close() | |
raise SystemExit | |
up_3 | |
#!/usr/bin/env python | |
from __future__ import division | |
import time | |
import subprocess | |
with open('/etc/motioneye/vert_pos_3', 'r') as f: | |
vert_pos_3 = int(f.readline()) | |
print vert_pos_3 | |
f.close() | |
vert_pos_3 -= 15 | |
if vert_pos_3<0: | |
vert_pos_3=0 | |
subprocess.call('curl -X GET --connect-timeout 5 http://192.168.100.114:9595/api/tilt/' + str(vert_pos_3) + ' > /dev/null', shell=True) | |
with open('/etc/motioneye/vert_pos_3', 'w') as f: | |
f.write(str(vert_pos_3)) | |
f.close() | |
raise SystemExit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment