Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. const Diagnostics = require('Diagnostics');
  2.  
  3. const FaceGestures = require('FaceGestures');
  4. const FaceTracking = require('FaceTracking');
  5. const Reactive = require('Reactive');
  6. const Scene = require('Scene');
  7. const Patches = require('Patches');
  8.  
  9. var Left_Score = Patches.getScalarValue("Left_Num");
  10. var Right_Score = Patches.getScalarValue("Right_Num");
  11.  
  12.  
  13. // Locate the Left Number in the Scene
  14. const left_Number = Scene.root.find('Left_Num');
  15.  
  16. // Locate the Right Number in the Scene
  17. const right_Number = Scene.root.find('Right_Num');
  18.  
  19. // Store a reference to a detected face
  20. const face = FaceTracking.face(0);
  21.  
  22. // Store references for when the left and right eye are closed
  23. const hasLeftEyeClosed = FaceGestures.hasLeftEyeClosed(face);
  24. const hasRightEyeClosed = FaceGestures.hasRightEyeClosed(face);
  25.  
  26. // Register a blink event
  27. const winkingLeft = hasLeftEyeClosed;
  28. const winkingRight = hasRightEyeClosed;
  29.  
  30. let Left_Eye_Num = 0;
  31.  
  32. Patches.getScalarValue("Left_Num").monitor().subscribe(()=>{
  33. Scene.root.find(Patches.getStringValue("Left_Blink").pinLastValue()).text = Left_Score.toString();
  34. if(winkingLeft){
  35. Diagnostics.log("left face");
  36. }
  37. });
  38.  
  39. Patches.getScalarValue("Right_Num").monitor().subscribe(()=>{
  40. Scene.root.find(Patches.getStringValue("Right_Blink").pinLastValue()).text = Right_Score.toString();
  41. if(winkingRight){
  42. Diagnostics.log("right face");
  43. }
  44. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement