Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

reducer.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { ReducerRegistry } from '../base/redux';
  2. import {
  3. START_FACE_RECOGNITION,
  4. STOP_FACE_RECOGNITION,
  5. UPDATE_FACE_COORDINATES
  6. } from './actionTypes';
  7. /**
  8. * The default state object.
  9. */
  10. const defaultState = {
  11. /**
  12. * Map of participant ids containing their respective facebox in the shape of a left, right, bottom, top percentages
  13. * The percentages indicate the distance of the detected face starting edge (top or left) to the corresponding edge.
  14. *
  15. * Examples:
  16. * 70% left indicates a 70% distance from the left edge of the video to the left edge of the detected face.
  17. * 70% right indicates a 70% distance from the right edge of the video to the left edge of the detected face.
  18. * 30% top indicates a 30% distance from the top edge of the video to the top edge of the detected face.
  19. * 30% bottom indicates a 30% distance from the bottom edge of the video to the top edge of the detected face.
  20. */
  21. faceBoxes: {},
  22. /**
  23. * Flag indicating whether face recognition is currently running.
  24. */
  25. recognitionActive: false
  26. };
  27. ReducerRegistry.register('features/face-centering', (state = defaultState, action) => {
  28. switch (action.type) {
  29. case UPDATE_FACE_COORDINATES: {
  30. return {
  31. ...state,
  32. faceBoxes: {
  33. ...state.faceBoxes,
  34. [action.id]: action.faceBox
  35. }
  36. };
  37. }
  38. case START_FACE_RECOGNITION: {
  39. return {
  40. ...state,
  41. recognitionActive: true
  42. };
  43. }
  44. case STOP_FACE_RECOGNITION: {
  45. return defaultState;
  46. }
  47. }
  48. return state;
  49. });