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.

96 lines
3.6 KiB

1 year ago
  1. #pragma once
  2. #include <fsdk/IObject.h>
  3. #include <fsdk/FSDKError.h>
  4. #include <fsdk/Optional.h>
  5. #include <fsdk/Types.h>
  6. namespace fsdk {
  7. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  8. DECLARE_SMARTPTR(ILivenessOneShotRGBEstimator);
  9. #endif
  10. /**
  11. * @brief Liveness OneShotRGB estimation structure.
  12. * @note estimation score normalized between 0.0 and 1.0,
  13. * where 1.0 equals to 100% confidence that person on image is alive, and 0.0 equals to 0%.
  14. * */
  15. struct LivenessOneShotRGBEstimation {
  16. enum class State {
  17. Alive = 0, //!< The person on image is real
  18. Fake, //!< The person on image is fake (photo, printed image)
  19. Unknown //!< The liveness status of person on image is Unknown
  20. };
  21. float score; //!< Estimation score
  22. State state; //!< Liveness status
  23. float qualityScore; //!< Liveness quality score
  24. };
  25. /**
  26. * @brief OneShot RGB Liveness estimator interface.
  27. * @note This estimator is designed for liveness detection.
  28. * */
  29. struct ILivenessOneShotRGBEstimator : IRefCounted {
  30. /**
  31. * @brief OneShot RGB Liveness estimation.
  32. * @param [in] image source image.
  33. * @param [in] detection detection coordinates in image space;
  34. * @param [in] landmarks5 Landmarks5 for the detection;
  35. * @param [out] estimation estimation results.
  36. * @param [in] qualityThreshold quality threshold;
  37. * @return Result with error code.
  38. * @see Detection, LivenessOneShotRGBEstimation, Landmarks, Image, Result and FSDKError for details.
  39. * @note image format must be R8G8B8, @see Format.
  40. */
  41. virtual Result<FSDKError> estimate(
  42. const Image& image,
  43. const Detection& detection,
  44. const Landmarks5& landmarks5,
  45. LivenessOneShotRGBEstimation& estimation,
  46. const float qualityThreshold = -1.f) const noexcept = 0;
  47. /**
  48. * @brief OneShot RGB Liveness estimation.
  49. * @param [in] images span of source images;
  50. * @param [in] detections span of detection coordinates in corresponding source images space;
  51. * @param [in] landmarks5 span of Landmarks5;
  52. * @param [out] estimations span of estimations;
  53. * @param [in] qualityThreshold quality threshold;
  54. * @param [out] aggregation aggregated value based on estimations;
  55. * @return Result with error code.
  56. * @see Span, Detection, LivenessOneShotRGBEstimation, Landmarks, Image, Result and FSDKError for details.
  57. * @note images format must be R8G8B8, @see Format.
  58. * @note all spans should be based on user owned continuous collections.
  59. * @note all spans should be equal size.
  60. * */
  61. virtual Result<FSDKError> estimate(
  62. Span<const Image> images,
  63. Span<const Detection> detections,
  64. Span<const Landmarks5> landmarks5,
  65. Span<LivenessOneShotRGBEstimation> estimations,
  66. const float qualityThreshold = -1.f,
  67. LivenessOneShotRGBEstimation* aggregation = nullptr) const noexcept = 0;
  68. /**
  69. * @brief Validate input of multiple frames in a single function call.
  70. * @param [in] images span of source images.
  71. * @param [in] detections span of detection coordinates in corresponding source images space.
  72. * @param [in] landmarks5 span of landmarks
  73. * @param [out] errors output span of errors for each image.
  74. * @return Result with error code.
  75. * @see Span, Landmarks, Image, Result and FSDKError for details.
  76. * @note images format must be R8G8B8, @see Format.
  77. * @note all spans should be based on user owned continuous collections.
  78. * @note all spans should be equal size.
  79. * */
  80. virtual Result<FSDKError>
  81. validate(
  82. Span<const Image> images,
  83. Span<const Detection> detections,
  84. Span<const Landmarks5> landmarks5,
  85. Span<Result<FSDKError>> errors) const noexcept = 0;
  86. };
  87. } // namespace fsdk