Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: services/shape_detection/face_detection_impl_mac.mm

Issue 2681913003: RELAND: ShapeDetection: use mojom::Bitmap for mojo interface. (Closed)
Patch Set: Fix the issue of failing to fetch bitmap module Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "base/mac/scoped_cftyperef.h" 7 #include "base/mac/scoped_cftyperef.h"
8 #include "media/capture/video/scoped_result_callback.h" 8 #include "media/capture/video/scoped_result_callback.h"
9 #include "mojo/public/cpp/bindings/strong_binding.h" 9 #include "mojo/public/cpp/bindings/strong_binding.h"
10 #include "services/shape_detection/detection_utils_mac.h" 10 #include "services/shape_detection/detection_utils_mac.h"
(...skipping 29 matching lines...) Expand all
40 NSString* const accuracy = 40 NSString* const accuracy =
41 options->fast_mode ? CIDetectorAccuracyHigh : CIDetectorAccuracyLow; 41 options->fast_mode ? CIDetectorAccuracyHigh : CIDetectorAccuracyLow;
42 NSDictionary* const detector_options = @{CIDetectorAccuracy : accuracy}; 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:detector_options] 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(const SkBitmap& bitmap,
51 uint32_t width,
52 uint32_t height,
53 const DetectCallback& callback) { 51 const DetectCallback& callback) {
54 media::ScopedResultCallback<DetectCallback> scoped_callback( 52 media::ScopedResultCallback<DetectCallback> scoped_callback(
55 base::Bind(&RunCallbackWithFaces, callback), 53 base::Bind(&RunCallbackWithFaces, callback),
56 base::Bind(&RunCallbackWithNoFaces)); 54 base::Bind(&RunCallbackWithNoFaces));
57 55
58 base::scoped_nsobject<CIImage> ci_image = 56 base::scoped_nsobject<CIImage> ci_image = CreateCIImageFromSkBitmap(bitmap);
59 CreateCIImageFromSharedMemory(std::move(frame_data), width, height);
60 if (!ci_image) 57 if (!ci_image)
61 return; 58 return;
62 59
63 NSArray* const features = [detector_ featuresInImage:ci_image]; 60 NSArray* const features = [detector_ featuresInImage:ci_image];
64 61
62 const int height = bitmap.height();
65 shape_detection::mojom::FaceDetectionResultPtr faces = 63 shape_detection::mojom::FaceDetectionResultPtr faces =
66 shape_detection::mojom::FaceDetectionResult::New(); 64 shape_detection::mojom::FaceDetectionResult::New();
67 for (CIFaceFeature* const f in features) { 65 for (CIFaceFeature* const f in features) {
68 // In the default Core Graphics coordinate space, the origin is located 66 // In the default Core Graphics coordinate space, the origin is located
69 // in the lower-left corner, and thus |ci_image| is flipped vertically. 67 // in the lower-left corner, and thus |ci_image| is flipped vertically.
70 // We need to adjust |y| coordinate of bounding box before sending it. 68 // We need to adjust |y| coordinate of bounding box before sending it.
71 gfx::RectF boundingbox(f.bounds.origin.x, 69 gfx::RectF boundingbox(f.bounds.origin.x,
72 height - f.bounds.origin.y - f.bounds.size.height, 70 height - f.bounds.origin.y - f.bounds.size.height,
73 f.bounds.size.width, f.bounds.size.height); 71 f.bounds.size.width, f.bounds.size.height);
74 faces->bounding_boxes.push_back(boundingbox); 72 faces->bounding_boxes.push_back(boundingbox);
75 } 73 }
76 scoped_callback.Run(std::move(faces)); 74 scoped_callback.Run(std::move(faces));
77 } 75 }
78 76
79 } // namespace shape_detection 77 } // namespace shape_detection
OLDNEW
« no previous file with comments | « services/shape_detection/face_detection_impl_mac.h ('k') | services/shape_detection/face_detection_impl_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698