=== added file 'camcontrol.py' --- camcontrol.py 1970-01-01 00:00:00 +0000 +++ camcontrol.py 2012-10-12 09:53:22 +0000 @@ -0,0 +1,69 @@ +#!/usr/env python +import urllib +import time +from logindetails import username,password,host,port +#bunch of constants for commands we can set to decoder_control +PTZ_STOP=1; +TILT_UP=0; +TILT_UP_STOP=1; +TILT_DOWN=2; +TILT_DOWN_STOP=3; +PAN_LEFT=4; +PAN_LEFT_STOP=5; +PAN_RIGHT=6; +PAN_RIGHT_STOP=7; +PTZ_LEFT_UP=90; +PTZ_RIGHT_UP=91; +PTZ_LEFT_DOWN=92; +PTZ_RIGHT_DOWN=93; +PTZ_CENTER=25; +PTZ_VPATROL=26; +PTZ_VPATROL_STOP=27; +PTZ_HPATROL=28; +PTZ_HPATROL_STOP=29; +PTZ_PELCO_D_HPATROL=20; +TZ_PELCO_D_HPATROL_STOP=21; +IO_ON=94; +IO_OFF=95; + +MEM_SET1=30 +MEM_GO1=31 +MEM_SET2=32 +MEM_GO2=33 +MEM_SET3=34 +MEM_GO3=35 +MEM_SET4=36 +MEM_GO4=37 +MEM_SET5=38 +MEM_GO5=39 +MEM_SET6=40 +MEM_GO6=41 +MEM_SET7=42 +MEM_GO7=43 +MEM_SET8=44 +MEM_GO8=45 + +def camcommand(command,distance): + urllib.urlopen('http://%s:%s@%s:%s/decoder_control.cgi?command=%s' % (username,password,host, port,command)) + #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 + #the camera is based on relative movement so this is only ever going to be approximate + time.sleep((0.0024*distance)-0.02)#should swap this for a callback timer + #time.sleep((0.006*distance)-0.02)#should swap this for a callback timer + urllib.urlopen('http://%s:%s@%s:%s/decoder_control.cgi?command=%s' % (username,password,host, port,PTZ_STOP)) + +def index(req,gox=0,goy=0): + #we get called with a position to go to normally + #in pixels + gox=int(gox) + goy=int(goy) + if gox>0: + camcommand(PAN_RIGHT,gox) + elif gox<0: + camcommand(PAN_LEFT,-gox) + + if goy>0: + camcommand(TILT_UP,goy) + elif goy<0: + camcommand(TILT_DOWN,-goy) + print "OK" + === added file 'index.html' --- index.html 1970-01-01 00:00:00 +0000 +++ index.html 2012-10-12 09:53:22 +0000 @@ -0,0 +1,233 @@ + + + + + + + + +

Camera Control

+

Click anywhere on the image to centre (roughly) that bit of the image.

+
The thing I bought (with evil affiliate code)
+ + + + +

This is based on a £35 wireless pan and tilt camera, but with a bit of python running on a separate web server +to control it. The mjpeg video stream is direct from the camera and it has a clickable imagemap overlay +which chops up the image into 40px squares. Clicking a square requests a simple web service running on +a computer close to the camera which starts the camera moving and stops it again after a fraction of a second +multiplied by the number of pixels it needs to move. The camera itself has no absolute or relative positioning, +it is just done by careful timing of the start and stop signals.

+

The camera can move in diagonal directions, it would be nice to get it to smoothly move to a new location smoothly +first by panning and tilting, then the rest of the way on one axis. Might be nice to have something round the +outside of the image to allow you to move double the distance, at the moment you can move a half frame in one click +would be nice to be able to go a whole frame away.

+

The camera stream has a maximum of 4 concurrent viewers, a few more if I +drop the resolution to 320x200. For lots of viewers I would use ffmpeg to reencode from mjpeg to something else +on the fly and possibly pass it to a streaming server of some kind, the overlay control should work +just as it is over a multicast video stream. In reality, if you are expecting more than a couple of concurrent +viewers they are going to argue over control too much.

+ + + + -320,-240 + -320,-200 + -320,-160 + -320,-120 + -320,-80 + -320,-40 + -320,0 + -320,40 + -320,80 + -320,120 + -320,160 + -320,200 + -280,-240 + -280,-200 + -280,-160 + -280,-120 + -280,-80 + -280,-40 + -280,0 + -280,40 + -280,80 + -280,120 + -280,160 + -280,200 + -240,-240 + -240,-200 + -240,-160 + -240,-120 + -240,-80 + -240,-40 + -240,0 + -240,40 + -240,80 + -240,120 + -240,160 + -240,200 + -200,-240 + -200,-200 + -200,-160 + -200,-120 + -200,-80 + -200,-40 + -200,0 + -200,40 + -200,80 + -200,120 + -200,160 + -200,200 + -160,-240 + -160,-200 + -160,-160 + -160,-120 + -160,-80 + -160,-40 + -160,0 + -160,40 + -160,80 + -160,120 + -160,160 + -160,200 + -120,-240 + -120,-200 + -120,-160 + -120,-120 + -120,-80 + -120,-40 + -120,0 + -120,40 + -120,80 + -120,120 + -120,160 + -120,200 + -80,-240 + -80,-200 + -80,-160 + -80,-120 + -80,-80 + -80,-40 + -80,0 + -80,40 + -80,80 + -80,120 + -80,160 + -80,200 + -40,-240 + -40,-200 + -40,-160 + -40,-120 + -40,-80 + -40,-40 + -40,0 + -40,40 + -40,80 + -40,120 + -40,160 + -40,200 + 0,-240 + 0,-200 + 0,-160 + 0,-120 + 0,-80 + 0,-40 + 0,0 + 0,40 + 0,80 + 0,120 + 0,160 + 0,200 + 40,-240 + 40,-200 + 40,-160 + 40,-120 + 40,-80 + 40,-40 + 40,0 + 40,40 + 40,80 + 40,120 + 40,160 + 40,200 + 80,-240 + 80,-200 + 80,-160 + 80,-120 + 80,-80 + 80,-40 + 80,0 + 80,40 + 80,80 + 80,120 + 80,160 + 80,200 + 120,-240 + 120,-200 + 120,-160 + 120,-120 + 120,-80 + 120,-40 + 120,0 + 120,40 + 120,80 + 120,120 + 120,160 + 120,200 + 160,-240 + 160,-200 + 160,-160 + 160,-120 + 160,-80 + 160,-40 + 160,0 + 160,40 + 160,80 + 160,120 + 160,160 + 160,200 + 200,-240 + 200,-200 + 200,-160 + 200,-120 + 200,-80 + 200,-40 + 200,0 + 200,40 + 200,80 + 200,120 + 200,160 + 200,200 + 240,-240 + 240,-200 + 240,-160 + 240,-120 + 240,-80 + 240,-40 + 240,0 + 240,40 + 240,80 + 240,120 + 240,160 + 240,200 + 280,-240 + 280,-200 + 280,-160 + 280,-120 + 280,-80 + 280,-40 + 280,0 + 280,40 + 280,80 + 280,120 + 280,160 + 280,200 + + + === added file 'map.py' --- map.py 1970-01-01 00:00:00 +0000 +++ map.py 2012-10-12 09:53:22 +0000 @@ -0,0 +1,53 @@ +#!/usr/bin/python +# -*- coding:utf-8 -*- +#printing out stuff like: +# North West + +print """ + + + + + + + +

Camera Control

+

Click anywhere on the image to centre (roughly) that bit of the image.

+
The thing I bought (with evil affiliate code)
+ + + + +

This is based on a £35 wireless pan and tilt camera, but with a bit of python running on a separate web server +to control it. The mjpeg video stream is direct from the camera and it has a clickable imagemap overlay +which chops up the image into 40px squares. Clicking a square requests a simple web service running on +a computer close to the camera which starts the camera moving and stops it again after a fraction of a second +multiplied by the number of pixels it needs to move. The camera itself has no absolute or relative positioning, +it is just done by careful timing of the start and stop signals.

+

The camera can move in diagonal directions, it would be nice to get it to smoothly move to a new location smoothly +first by panning and tilting, then the rest of the way on one axis. Might be nice to have something round the +outside of the image to allow you to move double the distance, at the moment you can move a half frame in one click +would be nice to be able to go a whole frame away.

+

The camera stream has a maximum of 4 concurrent viewers, a few more if I +drop the resolution to 320x200. For lots of viewers I would use ffmpeg to reencode from mjpeg to something else +on the fly and possibly pass it to a streaming server of some kind, the overlay control should work +just as it is over a multicast video stream. In reality, if you are expecting more than a couple of concurrent +viewers they are going to argue over control too much.

+ + +""" + +for x in range(0,640,40): + for y in range(0,480,40): + print ' %d,%d' % (x-320,y-240,x-320,y-240,x,y,x+40,y+40,x-320,240-y) + + +print """ + +""" +