Skip to content

Commit

Permalink
Clear calibration data on a calibration restart
Browse files Browse the repository at this point in the history
Restarting the calibration now clears the existing calibration data.
This should (finally) solve #70 (I hope).

In addition, a safety check has been built into the calibration routine,
which should prevent further pointstart and pointend requests when the
EyeTribe suddenly decides that it has been calibrated (which can happen,
for yet unknown reasons).
  • Loading branch information
esdalmaijer committed Jul 13, 2016
1 parent 42f8cf6 commit 1567fe6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 18 additions & 3 deletions pygaze/_eyetracker/libeyetribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,32 @@ def calibrate(self):
calibrated = False
calibresult = None
while not quited and not calibrated:

# Clear the existing calibration.
if self.eyetribe._tracker.get_iscalibrated():
self.eyetribe._lock.acquire(True)
self.eyetribe.calibration.clear()
self.eyetribe._lock.release()

# Wait for a bit.
clock.pause(1500)

# start a new calibration
self.eyetribe._lock.acquire(True)
self.eyetribe.calibration.start(pointcount=len(calibpoints))
self.eyetribe._lock.release()
if not self.eyetribe._tracker.get_iscalibrating():
self.eyetribe._lock.acquire(True)
self.eyetribe.calibration.start(pointcount=len(calibpoints))
self.eyetribe._lock.release()

# loop through calibration points
for cpos in calibpoints:
# Check whether the calibration is already done.
# (Not sure how or why, but for some reason some data
# can persist between calbrations, and the tracker will
# simply stop allowing further pointstart requests.)
if self.eyetribe._tracker.get_iscalibrated():
break

# Draw a calibration target.
self.draw_calibration_target(cpos[0], cpos[1])
# wait for a bit to allow participant to start looking at
# the calibration point (#TODO: space press?)
Expand Down
2 changes: 1 addition & 1 deletion pygaze/_eyetracker/pytribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ def start(self, pointcount=9, max_attempts=5):
{'pointcount':pointcount})
# return value or error
if response['statuscode'] == 200:
return
return True
self.abort()
raise Exception("Error in calibration.start: %s (code %d)" \
% (response['values']['statusmessage'],response['statuscode']))
Expand Down

0 comments on commit 1567fe6

Please sign in to comment.