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.

187 lines
7.7 KiB

1 year ago
  1. #pragma once
  2. #include "FSDKError.h"
  3. #include "IHumanDetectionBatch.h"
  4. #include "IObject.h"
  5. #include "Types/Human.h"
  6. namespace fsdk {
  7. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  8. DECLARE_SMARTPTR(IHumanDetector);
  9. #endif
  10. /**
  11. * @defgroup DetectorGroup Human detector.
  12. * @brief Human detector public interfaces and related types and structures.
  13. * @{
  14. * */
  15. /**
  16. * @brief Human detection type enumeration.
  17. * */
  18. enum HumanDetectionType {
  19. HDT_BOX = 0, //!< Get bounding boxes of human bodies.
  20. HDT_POINTS = 1<<0, //!< Get 17 keypoints of human, with score for each one.
  21. HDT_ALL = 0xffff //!< Get all supported parameters.
  22. };
  23. inline HumanDetectionType operator | (HumanDetectionType a, HumanDetectionType b) {
  24. return static_cast<HumanDetectionType>(static_cast<int>(a) | static_cast<int>(b));
  25. }
  26. /**
  27. * @brief human body detector interface.
  28. * */
  29. struct IHumanDetector : IRefCounted {
  30. /**
  31. * @brief Batched detect of human bodies.
  32. * @param [in] images span of source images.
  33. * @param [in] rects span of input rectangles of interest.
  34. * @param [in] detectionPerImageNum max number of detections per input image.
  35. * @param [in] type Human detection type.
  36. * @return ResultValue with error code and IHumanDetectionBatch object.
  37. * @see Ref, Span, Image, Rect, IHumanDetectionBatch, HumanDetectionType, ResultValue and FSDKError for details.
  38. * @note images format must be R8G8B8, @see Format.
  39. * @note all spans should be based on user owned continuous collections.
  40. * @note all spans should be equal size.
  41. */
  42. virtual ResultValue<FSDKError, Ref<IHumanDetectionBatch>>
  43. detect(
  44. Span<const Image> images,
  45. Span<const Rect> rects,
  46. uint32_t detectionPerImageNum,
  47. HumanDetectionType type = HDT_BOX) const noexcept = 0;
  48. /**
  49. * @brief Detect one person on input image.
  50. * @param [in] image source image.
  51. * @param [in] rect rectangle of interest in the image.
  52. * @param [in] type Human detection type.
  53. * @return ResultValue with ErrorCode and Human (invalid - if detection not found).
  54. * @see Image, Rect, Human, HumanDetectionType, ResultValue and FSDKError for details.
  55. * @note image format must be R8G8B8, @see Format.
  56. */
  57. virtual ResultValue<FSDKError, Human>
  58. detectOne(
  59. const Image& image,
  60. const Rect& rect,
  61. HumanDetectionType type = HDT_BOX) const noexcept = 0;
  62. /**
  63. * @brief redetect one person from input image.
  64. * @param [in] image source image.
  65. * @param [in] detection span of detection coordinates in corresponding source images space to make a redetect.
  66. * @param [in] type Human detection type.
  67. * @return ResultValue with ErrorCode and Human (invalid - if detection not found).
  68. * @see Image, Detection, Human, HumanDetectionType, ResultValue and FSDKError for details.
  69. * @note image format must be R8G8B8, @see Format.
  70. **/
  71. virtual ResultValue<FSDKError, Human>
  72. redetectOne(
  73. const Image& image,
  74. const Detection& detection,
  75. HumanDetectionType type = HDT_BOX) const noexcept = 0;
  76. /**
  77. * @brief Batched redetect humans on multiple images
  78. * based on the detection results for the previous frames.
  79. * @param [in] images span of source images.
  80. * @param [in] detectionBatch result of detection on the previous frames -
  81. * Ref with an IHumanDetectionBatch object.
  82. * @param [in] type type of redetection.
  83. * @return ResultValue with error code and IHumanDetectionBatch object.
  84. * @see Ref, Span, Image, IHumanDetectionBatch, HumanDetectionType, ResultValue and FSDKError for details.
  85. * @note images format must be R8G8B8, @see Format.
  86. * @note all spans should be based on user owned continuous collections.
  87. * @note images span should be the same size with detectionBatch size.
  88. * @note In case if some human from the input detectionBatch was not found
  89. * the corresponding detection in the output IHumanDetectionBatch object
  90. * will be invalid.
  91. */
  92. virtual ResultValue<FSDKError, IHumanDetectionBatchPtr>
  93. redetect(
  94. Span<const Image> images,
  95. Ref<IHumanDetectionBatch> detectionBatch,
  96. HumanDetectionType type = HDT_BOX) const noexcept = 0;
  97. /**
  98. * @brief Batched redetect humans on multiple images
  99. * based on the detection results for the previous frames.
  100. * @param [in] images span of source images.
  101. * @param [in] detections span of detection coordinates in corresponding source images space
  102. * from the previous frames. It is a two dimensional Span. There is one Span of the rectangles for each image.
  103. * @param [in] type type of redetection.
  104. * @return ResultValue with error code and IHumanDetectionBatch object.
  105. * @see Span, Image, Detection, IHumanDetectionBatch, HumanDetectionType, ResultValue and FSDKError for details.
  106. * @note images format must be R8G8B8, @see Format.
  107. * @note all spans should be based on user owned continuous collections.
  108. * @note all spans should be equal size.
  109. * @note If for some of the input detections the redetected human will not be found the
  110. * appropriate detection in the IHumanDetectionBatch object will be invalid.
  111. */
  112. virtual ResultValue<FSDKError, IHumanDetectionBatchPtr>
  113. redetect(
  114. Span<const Image> images,
  115. Span<Span<const Detection>> detections,
  116. HumanDetectionType type = HDT_BOX) const noexcept = 0;
  117. /**
  118. * @brief Validate input of multiple frames in a single function call.
  119. * @param [in] images span of source images.
  120. * @param [in] rects span of rectangle coordinates of corresponding source images.
  121. * @param [in] detectionPerImageNum max number of detections per input image.
  122. * @param [out] errors output span of errors for each image.
  123. * @return Result with error code.
  124. * @see Span, Image, Rect, Result and FSDKError for details.
  125. * @note images format must be R8G8B8, @see Format.
  126. * @note all spans should be based on user owned continuous collections.
  127. * @note all spans should be equal size.
  128. * */
  129. virtual Result<FSDKError>
  130. validate(
  131. Span<const Image> images,
  132. Span<const Rect> rects,
  133. uint32_t detectionPerImageNum,
  134. Span<Result<FSDKError>> errors) const noexcept = 0;
  135. /**
  136. * @brief Validate input of multiple frames in a single function call.
  137. * @param [in] images span of source images.
  138. * @param [in] detectionBatch result of detection on the previous frames -
  139. * Ref with an IHumanDetectionBatch object.
  140. * @param [out] errors output span of errors for each image.
  141. * @return Result with error code.
  142. * @see Ref, Span, Image, IHumanDetectionBatch, Result and FSDKError for details.
  143. * @note images format must be R8G8B8, @see Format.
  144. * @note all spans should be based on user owned continuous collections.
  145. * @note all spans should be equal size.
  146. * */
  147. virtual Result<FSDKError> validate(
  148. Span<const Image> images,
  149. Ref<IHumanDetectionBatch> detectionBatch,
  150. Span<Result<FSDKError>> errors) const noexcept = 0;
  151. /**
  152. * @brief Validate input of multiple frames in a single function call.
  153. * @param [in] images span of source images.
  154. * @param [in] detections span of detection coordinates in corresponding source images space
  155. * from the previous frames. It is a two dimensional Span. There is one Span of the Detections for each image.
  156. * @param [out] errors output span of errors for each image.
  157. * It is a two dimensional Span. There is one Span of the errors for each image.
  158. * @return Result with error code.
  159. * @see Span, Image, Detection, Result and FSDKError for details.
  160. * @note images format must be R8G8B8, @see Format.
  161. * @note all spans should be based on user owned continuous collections.
  162. * @note all spans should be equal size.
  163. * */
  164. virtual Result<FSDKError>
  165. validate(
  166. Span<const Image> images,
  167. Span<Span<const Detection>> detections,
  168. Span<Span<Result<FSDKError>>> errors) const noexcept = 0;
  169. };
  170. /** @} */
  171. }