forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathface_detection_impl_win.h
75 lines (57 loc) · 2.62 KB
/
face_detection_impl_win.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_SHAPE_DETECTION_FACE_DETECTION_IMPL_WIN_H_
#define SERVICES_SHAPE_DETECTION_FACE_DETECTION_IMPL_WIN_H_
#include <windows.foundation.h>
#include <windows.graphics.imaging.h>
#include <windows.media.faceanalysis.h>
#include <wrl/client.h>
#include <memory>
#include <utility>
#include <vector>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "services/shape_detection/detection_utils_win.h"
#include "services/shape_detection/public/mojom/facedetection.mojom.h"
class SkBitmap;
namespace shape_detection {
using ABI::Windows::Foundation::Collections::IVector;
class FaceDetectionImplWin : public mojom::FaceDetection {
public:
using FaceDetector = ABI::Windows::Media::FaceAnalysis::FaceDetector;
using IFaceDetector = ABI::Windows::Media::FaceAnalysis::IFaceDetector;
using DetectedFace = ABI::Windows::Media::FaceAnalysis::DetectedFace;
using IDetectedFace = ABI::Windows::Media::FaceAnalysis::IDetectedFace;
using BitmapPixelFormat = ABI::Windows::Graphics::Imaging::BitmapPixelFormat;
using ISoftwareBitmapStatics =
ABI::Windows::Graphics::Imaging::ISoftwareBitmapStatics;
FaceDetectionImplWin(
Microsoft::WRL::ComPtr<IFaceDetector> face_detector,
Microsoft::WRL::ComPtr<ISoftwareBitmapStatics> bitmap_factory,
BitmapPixelFormat pixel_format);
~FaceDetectionImplWin() override;
void SetBinding(mojo::StrongBindingPtr<mojom::FaceDetection> binding) {
binding_ = std::move(binding);
}
// mojom::FaceDetection implementation.
void Detect(const SkBitmap& bitmap,
mojom::FaceDetection::DetectCallback callback) override;
private:
HRESULT BeginDetect(const SkBitmap& bitmap);
std::vector<mojom::FaceDetectionResultPtr> BuildFaceDetectionResult(
AsyncOperation<IVector<DetectedFace*>>::IAsyncOperationPtr async_op);
void OnFaceDetected(
Microsoft::WRL::ComPtr<ISoftwareBitmap> win_bitmap,
AsyncOperation<IVector<DetectedFace*>>::IAsyncOperationPtr async_op);
Microsoft::WRL::ComPtr<IFaceDetector> face_detector_;
Microsoft::WRL::ComPtr<ISoftwareBitmapStatics> bitmap_factory_;
BitmapPixelFormat pixel_format_;
DetectCallback detected_face_callback_;
mojo::StrongBindingPtr<mojom::FaceDetection> binding_;
base::WeakPtrFactory<FaceDetectionImplWin> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(FaceDetectionImplWin);
};
} // namespace shape_detection
#endif // SERVICES_SHAPE_DETECTION_FACE_DETECTION_IMPL_WIN_H_