您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

tracker.ts 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * MARTINS.js
  3. * GPU-accelerated Augmented Reality for the web
  4. * Copyright (C) 2022-2024 Alexandre Martins <alemartf(at)gmail.com>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published
  8. * by the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. *
  19. * tracker.ts
  20. * Abstract Tracker
  21. */
  22. import { Session } from '../core/session';
  23. import { SpeedyPromise } from 'speedy-vision/types/core/speedy-promise';
  24. import { SpeedyMedia } from 'speedy-vision/types/core/speedy-media';
  25. /**
  26. * A Trackable is something that can be tracked
  27. */
  28. export interface Trackable
  29. {
  30. }
  31. /**
  32. * The result of a Tracker in a particular frame of a session. Such result is
  33. * meant to be consumed by the user/application.
  34. */
  35. export interface TrackerResult
  36. {
  37. /** the tracker that generated this result */
  38. readonly tracker: Tracker;
  39. /** an array of trackables (possibly empty) */
  40. readonly trackables: Trackable[];
  41. }
  42. /**
  43. * The output generated by a Tracker in a particular Frame of a Session
  44. */
  45. export interface TrackerOutput
  46. {
  47. /** tracker result to be consumed by the user */
  48. readonly exports?: TrackerResult;
  49. /** optional image for testing */
  50. readonly image?: SpeedyMedia;
  51. }
  52. /**
  53. * A Tracker is an AR subsystem attached to a Session
  54. */
  55. export interface Tracker
  56. {
  57. /** a string that identifies the type of the tracker */
  58. readonly type: string;
  59. /** initialize tracker @internal */
  60. _init: (session: Session) => SpeedyPromise<void>;
  61. /** release resources @internal */
  62. _release: () => SpeedyPromise<void>;
  63. /** update cycle @internal */
  64. _update: () => SpeedyPromise<void>;
  65. /** output of the last frame @internal */
  66. readonly _output: TrackerOutput;
  67. /** stats related to this tracker @internal */
  68. readonly _stats: string;
  69. }