addCalibrationPoint method

  1. @override
Future<bool> addCalibrationPoint(
  1. CalibrationPoint point
)
override

Implementation

@override
Future<bool> addCalibrationPoint(CalibrationPoint point) async {
  if (!_isCalibrating) return false;

  try {
    if (_webGazerStarted && _hasWebGazerProperty()) {
      // Add calibration point to WebGazer multiple times for better accuracy
      for (int i = 0; i < 5; i++) {
        try {
          _callWebGazerMethod(
              'recordScreenPosition', [point.x.toJS, point.y.toJS]);
        } catch (e) {
          _evalJS('webgazer.recordScreenPosition(${point.x}, ${point.y})');
        }
        await Future.delayed(const Duration(milliseconds: 100));
      }
    }
    return true;
  } catch (e) {
    return false;
  }
}