Created
          December 14, 2022 05:32 
        
      - 
      
- 
        Save Dabin22/7865a44bc4ea0e65afcc2bcceaebdb6b to your computer and use it in GitHub Desktop. 
    BlinkCallback Example code
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import 'regenerator-runtime/runtime'; | |
| // npm module | |
| import SeeSo, {InitializationErrorType,UserStatusOption} from 'seeso'; | |
| let videoStream = null; | |
| const licenseKey = 'input your key'; // Issue license key! -> https://console.seeso.io | |
| // gaze callback. | |
| function onGaze(gazeInfo) { | |
| // do something with gaze info. | |
| console.log('onGaze', gazeInfo) | |
| } | |
| function onBlink(timestamp, isBlinkLeft, isBlinkRight, isBlink, leftOpenness, rightOpenness) { | |
| console.log('Blink! ',timestamp, isBlinkLeft, isBlinkRight, isBlink, leftOpenness, rightOpenness) | |
| } | |
| async function main() { | |
| videoStream = await navigator.mediaDevices.getUserMedia({'video': true}); | |
| const seeSo = new SeeSo(); | |
| /** | |
| * set monitor size. default: 16 inch. | |
| * set face distance. default: 30 cm. | |
| * set camera position. default: | |
| * camera x: right center | |
| * cameraOnTop: true | |
| */ | |
| const option = new UserStatusOption(false, true, false); | |
| const errCode = await seeSo.initialize(licenseKey, option); // callback when init failed.) | |
| if (errCode === InitializationErrorType.ERROR_NONE) { | |
| seeSo.setMonitorSize(16); | |
| seeSo.setFaceDistance(50); | |
| seeSo.setCameraPosition(window.outerWidth / 2, true); | |
| seeSo.addGazeCallback(onGaze); | |
| seeSo.addBlinkCallback(onBlink); | |
| seeSo.startTracking(videoStream); | |
| } | |
| } | |
| (async () => { | |
| await main(); | |
| })() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment