face_detection_impl_mac_vision.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef SERVICES_SHAPE_DETECTION_FACE_DETECTION_IMPL_MAC_VISION_H_
  5. #define SERVICES_SHAPE_DETECTION_FACE_DETECTION_IMPL_MAC_VISION_H_
  6. #include <os/availability.h>
  7. #include <memory>
  8. #include <utility>
  9. #include "base/memory/weak_ptr.h"
  10. #include "mojo/public/cpp/bindings/self_owned_receiver.h"
  11. #include "services/shape_detection/detection_utils_mac.h"
  12. #include "services/shape_detection/public/mojom/facedetection.mojom.h"
  13. class SkBitmap;
  14. namespace shape_detection {
  15. // The FaceDetectionImplMacVision class is the implementation of Face Detection
  16. // based on Mac OS Vision framework.
  17. class FaceDetectionImplMacVision : public mojom::FaceDetection {
  18. public:
  19. FaceDetectionImplMacVision();
  20. FaceDetectionImplMacVision(const FaceDetectionImplMacVision&) = delete;
  21. FaceDetectionImplMacVision& operator=(const FaceDetectionImplMacVision&) =
  22. delete;
  23. ~FaceDetectionImplMacVision() override;
  24. void Detect(const SkBitmap& bitmap,
  25. mojom::FaceDetection::DetectCallback callback) override;
  26. void SetReceiver(mojo::SelfOwnedReceiverRef<mojom::FaceDetection> receiver) {
  27. receiver_ = std::move(receiver);
  28. }
  29. private:
  30. void OnFacesDetected(VNRequest* request, NSError* error);
  31. CGSize image_size_;
  32. std::unique_ptr<VisionAPIAsyncRequestMac> landmarks_async_request_;
  33. DetectCallback detected_callback_;
  34. mojo::SelfOwnedReceiverRef<mojom::FaceDetection> receiver_;
  35. base::WeakPtrFactory<FaceDetectionImplMacVision> weak_factory_;
  36. };
  37. } // namespace shape_detection
  38. #endif // SERVICES_SHAPE_DETECTION_FACE_DETECTION_IMPL_MAC_VISION_H_