Esempio n. 1
0
from ipcamera2 import CCamera

STEP = 10
DELAY = 0.1
FILE = 'servo_map.data'
RES = (736, 480)

p = Pointer()
c = CCamera(resolution=RES)
q = deque()
visited = set()
datamap = {}

pan = sys.argv[1] if len(sys.argv)>1 else 1700
tilt = sys.argv[2] if len(sys.argv)>2 else 1700
p.position(pan, tilt)

time.sleep(3) # warmup
if c.detect_pointer():
	q.append((pan, tilt))
else:
	raise Exception("Cannot detect laser pointer at initial pan={} tilt={}".format(pan, tilt))

print("starting from {}".format((pan, tilt)))
while q:
	print("enqued: {}, visited: {}, collected: {}".format(len(q), len(visited), len(datamap)))
	(pan, tilt) = q.pop()
	if (pan, tilt) in visited:
		continue

	visited.add((pan, tilt))
import time
import random
from pointer import Pointer

print("Starting")
def randpan():
    return random.randrange(1400, 1600)

def randtilt():
    return random.randrange(1800, 2000)

def randsleep():
    time.sleep(random.uniform(0.5, 3))

pointer = Pointer()
try:
    while True:
        pointer.position(randpan(), randtilt())
        randsleep()
except KeyboardInterrupt:
    pass # it's ok
finally:
    print("Clean up and exit.")
    pointer.cleanup()

print("Done")