You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
6.7 KiB

1 year ago
  1. #pragma once
  2. #include "ITrackCallbacks.h"
  3. #include <fsdk/IObject.h>
  4. #include <fsdk/Types/Image.h>
  5. namespace tsdk {
  6. struct IStream : fsdk::IRefCounted {
  7. /** @brief Stream statistics
  8. */
  9. struct Statistics {
  10. //! total pushed frames count (count of frames, that were tried to push via pushFrame)
  11. size_t totalFramesCount = 0;
  12. //! count of frames, that were successfully added to the processing queue (that frames, for which pushFrame returned true)
  13. size_t pushedFramesCount = 0;
  14. //! count of frames, that were used only to update frg (w/o tracks processing)
  15. size_t onlyFRGUpdateFramesCount = 0;
  16. //! count of frames, that were used to process tracks
  17. size_t tracksProcessingFramesCount = 0;
  18. //! count of frames, that were successfully processed (must be equal to pushedFramesCount after stream has been finished)
  19. size_t processedFramesCount = 0;
  20. //! fps for last second
  21. uint32_t fps = 0;
  22. };
  23. /** @brief Pushes a single frame to the buffer.
  24. * @note You should pass consequent frames for reasonble results
  25. * (thing video frames).
  26. * Call face detector and tracker, then triggers the callback for
  27. * processed faces.
  28. * @param frame input frame image. Supported image formats: R8G8B8 OR R8G8B8X8 for both MemoryCPU/MemoryGPU.
  29. For MemoryGPU also YUV_NV12 and YUV_NV21 are supported.
  30. * @param frameId unique identifier for frames sequence.
  31. * @param data is any additional data that a developer wants to receive in callbacks-realization.
  32. * Do not use the delete-operator. The garbage collector is implemented inside TrackEngine for this param.
  33. * @return true if frame was appended to the queue for processing,
  34. * false otherwise - frame was skipped because of full queue.
  35. */
  36. TRACK_ENGINE_API virtual bool pushFrame(
  37. const fsdk::Image &frame,
  38. uint32_t frameId,
  39. tsdk::AdditionalFrameData *data) = 0;
  40. /** @brief Pushes a single user defined custom frame to the buffer.
  41. * @note see ICustomFrame for details
  42. * @param frame custom frame
  43. * @param frameId unique identifier for frames sequence.
  44. * @param data is any additional data that a developer wants to receive in callbacks-realization.
  45. * @note Now the feature is supported only for CPU memory residence!
  46. * Do not use the delete-operator. The garbage collector is implemented inside TrackEngine for this param.
  47. * @return true if frame was appended to the queue for processing,
  48. * false otherwise - frame was skipped because of full queue.
  49. */
  50. TRACK_ENGINE_API virtual bool pushCustomFrame(
  51. fsdk::Ref<tsdk::ICustomFrame> frame,
  52. uint32_t frameId,
  53. tsdk::AdditionalFrameData *data) = 0;
  54. /** @brief Pushes a single frame to the buffer with timeout.
  55. * @note You should pass consequent frames for reasonble results
  56. * (thing video frames).
  57. * Call face detector and tracker, then triggers the callback for
  58. * processed faces.
  59. * This function may block for longer than timeMs due to
  60. * scheduling, resource contention delays or changing system clock
  61. * @param frame input frame image. Format must be R8G8B8.
  62. * @param frameId unique identifier for frames sequence.
  63. * @param data is any additional data that a developer wants to receive in callbacks-realization.
  64. * @note Now the feature is supported only for CPU memory residence!
  65. * Do not use the delete-operator. The garbage collector is implemented inside TrackEngine for this param.
  66. * @param timeMs the maximum time in milliseconds to spend waiting for execution.
  67. * if timeMs is zero, then function's behavior is equal to pushFrame
  68. * @return true if frame was appended to the queue for processing,
  69. * false otherwise - frame was skipped because of full queue (after waiting timeMs milliseconds).
  70. */
  71. TRACK_ENGINE_API virtual bool pushFrameWaitFor(
  72. const fsdk::Image &frame,
  73. uint32_t frameId,
  74. tsdk::AdditionalFrameData *data,
  75. uint32_t timeMs) = 0;
  76. /** @brief Pushes a single user defined custom frame to the buffer.
  77. * @note @see 'pushCustomFrame', 'pushFrameWaitFor' for details
  78. */
  79. TRACK_ENGINE_API virtual bool pushCustomFrameWaitFor(
  80. fsdk::Ref<tsdk::ICustomFrame> frame,
  81. uint32_t frameId,
  82. tsdk::AdditionalFrameData *data,
  83. uint32_t timeMs) = 0;
  84. /** @brief Sets a best shot observer for this Stream
  85. * @param observer pointer to the observer object, @see IBestShotObserver
  86. */
  87. TRACK_ENGINE_API virtual void
  88. TSDK_DEPRECATED("This call is deprecated. Consider "
  89. "ITrackEngine::setBatchBestShotObserver(tsdk::IBatchBestShotObserver *observer) call\n")
  90. setBestShotObserver(tsdk::IBestShotObserver* observer) = 0;
  91. /** @brief Sets a visual observer for this Stream
  92. * @param observer pointer to the observer object, @see IVisualObserver
  93. */
  94. TRACK_ENGINE_API virtual void
  95. TSDK_DEPRECATED("This call is deprecated. Consider "
  96. "ITrackEngine::setBatchVisualObserver(tsdk::IBatchVisualObserver *observer) call\n")
  97. setVisualObserver(tsdk::IVisualObserver* observer) = 0;
  98. /** @brief Sets a debug observer for this Stream
  99. * @param observer pointer to the observer object, @see IDebugObserver
  100. */
  101. TRACK_ENGINE_API virtual void
  102. TSDK_DEPRECATED("This call is deprecated. Consider "
  103. "ITrackEngine::setBatchDebugObserver(tsdk::IBatchDebugObserver *observer) call\n")
  104. setDebugObserver(tsdk::IDebugObserver* observer) = 0;
  105. /** @brief Sets a best shot predicate for this Stream
  106. * @param predicate best shot predicate, @see IBestShotPredicate
  107. */
  108. TRACK_ENGINE_API virtual void setBestShotPredicate(
  109. tsdk::IBestShotPredicate* predicate) = 0;
  110. /** @brief Sets a visual predicate for this Stream
  111. * @param predicate visual predicate, @see IVisualPredicate
  112. */
  113. TRACK_ENGINE_API virtual void setVisualPredicate(
  114. tsdk::IVisualPredicate *predicate) = 0;
  115. /** @brief Enables or disables observer
  116. * @param type observer type
  117. * @param enabled enable observer if true, disable otherwise
  118. */
  119. TRACK_ENGINE_API virtual void setObserverEnabled(
  120. tsdk::StreamObserverType type, bool enabled) = 0;
  121. /** @brief Blocks current thread until all frames in this Stream will be handled
  122. * and all callbacks will be executed.
  123. * @note Stream could not be used after join.
  124. * @see setBestShotObserver, setVisualObserver, setDebugObserver and
  125. * setBestShotPredicate
  126. */
  127. TRACK_ENGINE_API virtual void join() = 0;
  128. /** @brief Get stream statistics (see above: struct Statistics)
  129. * @return stream statistics
  130. */
  131. TRACK_ENGINE_API virtual Statistics getStatistics() const = 0;
  132. /** @brief Get stream id
  133. * @return stream Id
  134. */
  135. TRACK_ENGINE_API virtual const StreamId& getId() const = 0;
  136. /** @brief Get stream parameters, @see ITrackEngine::createStream and StreamParams for details
  137. * @return stream parameters
  138. */
  139. TRACK_ENGINE_API virtual StreamParams getParams() const = 0;
  140. };
  141. }