| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "services/shape_detection/face_detection_impl_mac.h" | 5 #include "services/shape_detection/face_detection_impl_mac.h" |
| 6 | 6 |
| 7 #import <QuartzCore/QuartzCore.h> | |
| 8 | |
| 9 #include "base/mac/scoped_cftyperef.h" | 7 #include "base/mac/scoped_cftyperef.h" |
| 10 #include "media/capture/video/scoped_result_callback.h" | 8 #include "media/capture/video/scoped_result_callback.h" |
| 11 #include "mojo/public/cpp/bindings/strong_binding.h" | 9 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 12 #include "services/shape_detection/detection_utils_mac.h" | 10 #include "services/shape_detection/detection_utils_mac.h" |
| 13 #include "services/shape_detection/face_detection_provider_impl.h" | 11 #include "services/shape_detection/face_detection_provider_impl.h" |
| 14 | 12 |
| 15 namespace shape_detection { | 13 namespace shape_detection { |
| 16 | 14 |
| 17 namespace { | 15 namespace { |
| 18 | 16 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 32 void FaceDetectionProviderImpl::CreateFaceDetection( | 30 void FaceDetectionProviderImpl::CreateFaceDetection( |
| 33 shape_detection::mojom::FaceDetectionRequest request, | 31 shape_detection::mojom::FaceDetectionRequest request, |
| 34 shape_detection::mojom::FaceDetectorOptionsPtr options) { | 32 shape_detection::mojom::FaceDetectorOptionsPtr options) { |
| 35 mojo::MakeStrongBinding( | 33 mojo::MakeStrongBinding( |
| 36 base::MakeUnique<FaceDetectionImplMac>(std::move(options)), | 34 base::MakeUnique<FaceDetectionImplMac>(std::move(options)), |
| 37 std::move(request)); | 35 std::move(request)); |
| 38 } | 36 } |
| 39 | 37 |
| 40 FaceDetectionImplMac::FaceDetectionImplMac( | 38 FaceDetectionImplMac::FaceDetectionImplMac( |
| 41 shape_detection::mojom::FaceDetectorOptionsPtr options) { | 39 shape_detection::mojom::FaceDetectorOptionsPtr options) { |
| 42 NSDictionary* const opts = @{CIDetectorAccuracy : CIDetectorAccuracyHigh}; | 40 NSString* const accuracy = |
| 41 options->fast_mode ? CIDetectorAccuracyHigh : CIDetectorAccuracyLow; |
| 42 NSDictionary* const detector_options = @{CIDetectorAccuracy : accuracy}; |
| 43 detector_.reset([[CIDetector detectorOfType:CIDetectorTypeFace | 43 detector_.reset([[CIDetector detectorOfType:CIDetectorTypeFace |
| 44 context:nil | 44 context:nil |
| 45 options:opts] retain]); | 45 options:detector_options] retain]); |
| 46 } | 46 } |
| 47 | 47 |
| 48 FaceDetectionImplMac::~FaceDetectionImplMac() {} | 48 FaceDetectionImplMac::~FaceDetectionImplMac() {} |
| 49 | 49 |
| 50 void FaceDetectionImplMac::Detect(mojo::ScopedSharedBufferHandle frame_data, | 50 void FaceDetectionImplMac::Detect(mojo::ScopedSharedBufferHandle frame_data, |
| 51 uint32_t width, | 51 uint32_t width, |
| 52 uint32_t height, | 52 uint32_t height, |
| 53 const DetectCallback& callback) { | 53 const DetectCallback& callback) { |
| 54 media::ScopedResultCallback<DetectCallback> scoped_callback( | 54 media::ScopedResultCallback<DetectCallback> scoped_callback( |
| 55 base::Bind(&RunCallbackWithFaces, callback), | 55 base::Bind(&RunCallbackWithFaces, callback), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 70 // We need to adjust |y| coordinate of bounding box before sending it. | 70 // We need to adjust |y| coordinate of bounding box before sending it. |
| 71 gfx::RectF boundingbox(f.bounds.origin.x, | 71 gfx::RectF boundingbox(f.bounds.origin.x, |
| 72 height - f.bounds.origin.y - f.bounds.size.height, | 72 height - f.bounds.origin.y - f.bounds.size.height, |
| 73 f.bounds.size.width, f.bounds.size.height); | 73 f.bounds.size.width, f.bounds.size.height); |
| 74 faces->bounding_boxes.push_back(boundingbox); | 74 faces->bounding_boxes.push_back(boundingbox); |
| 75 } | 75 } |
| 76 scoped_callback.Run(std::move(faces)); | 76 scoped_callback.Run(std::move(faces)); |
| 77 } | 77 } |
| 78 | 78 |
| 79 } // namespace shape_detection | 79 } // namespace shape_detection |
| OLD | NEW |