~alanbell/+junk/camcontrol

« back to all changes in this revision

Viewing changes to camcontrol.py

  • Committer: Alan Bell
  • Date: 2012-10-31 21:01:06 UTC
  • Revision ID: alanbell@ubuntu.com-20121031210106-ptzzdc7g50ick7el
few tweaks and a template for the logindetails.py file

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
MEM_SET8=44
44
44
MEM_GO8=45
45
45
 
46
 
def camcommand(command,distance):
 
46
def camcommand(command,distance=0):
47
47
    urllib.urlopen('http://%s:%s@%s:%s/decoder_control.cgi?command=%s' % (username,password,host, port,command))
48
48
    #move the specified distance, less a fraction to allow for stopping time, so 10 short moves don't end up further than 1 long move
49
49
    #the camera is based on relative movement so this is only ever going to be approximate
50
 
    time.sleep((0.0024*distance)-0.02)#should swap this for a callback timer
51
 
    #time.sleep((0.006*distance)-0.02)#should swap this for a callback timer
52
 
    urllib.urlopen('http://%s:%s@%s:%s/decoder_control.cgi?command=%s' % (username,password,host, port,PTZ_STOP))
 
50
    if distance:
 
51
      time.sleep((0.0024*distance)-0.02)#should swap this for a callback timer
 
52
      #time.sleep((0.006*distance)-0.02)#should swap this for a callback timer
 
53
      urllib.urlopen('http://%s:%s@%s:%s/decoder_control.cgi?command=%s' % (username,password,host, port,PTZ_STOP))
53
54
 
54
 
def index(req,gox=0,goy=0):
 
55
def index(req,gox=0,goy=0,preset=0):
55
56
  #we get called with a position to go to normally
56
57
  #in pixels
 
58
  if preset:
 
59
    camcommand(preset)
 
60
 
57
61
  gox=int(gox)
58
62
  goy=int(goy)
59
63
  if gox>0:
65
69
    camcommand(TILT_UP,goy)
66
70
  elif goy<0:
67
71
    camcommand(TILT_DOWN,-goy)
68
 
  print "OK"
 
72
 
 
73
  return "OK"
69
74