Pupil is a head-mounted eye tracker, which is very low price (380 Euro~) See Pupil lab: http://pupil-labs.com/pupil/
Although a good sdk for MacOS and Linux is available officially, I had a try to use this device just for capuring inside/outside views.
capture.py
import cv2
import sys
import numpy as np
import re
def init_camera(id, width, height):
u'''
Initializing a camera
'''
cap = cv2.VideoCapture(id)
cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, width)
cap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, height)
return cap
def run(ids, width=320, height=180):
u'''
Capturing images
'''
caps = [init_camera(id, width, height) for id in ids]
while(True):
# Capture frame-by-frame
for id in ids:
ret, frame = caps[id].read()
# Our operations on the frame come here
# Display the resulting frame
cv2.imshow('cam %d' % id, frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
for id in ids:
caps[id].release()
cv2.destroyAllWindows()
def parse_argvs(argvs):
if(len(argvs) == 1):
print 'Usage: python capture.py --ids [0, 1, ...] --width [width], --height [height]'
if '--width' in argvs:
width = np.int(argvs[argvs.index('--width') + 1])
else:
width = 320
if '--height' in argvs:
height = np.int(argvs[argvs.index('--height') + 1])
else:
height = 180
if '--ids' in argvs:
ids = []
idx = argvs.index('--ids') + 1
while(re.match('--.*', argvs[idx]) is None):
ids.append(np.int(argvs[idx]))
idx = idx + 1
else:
ids = [0]
return ids, width, height
if(__name__ == '__main__'):
ids, width, height = parse_argvs(sys.argv)
run(ids, width, height)
Example:
python capture.py --ids 0 1 --width 320 --height 180
![kobito.1414127169.369296.png](https://qiita-image-store.s3.amazonaws.com/0/69/9106d176-d0de-5ce1-0f2c-65d2a0e2339f.png "kobito.1414127169.369296.png ")
Recommended Posts