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

Side by Side Diff: third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp

Issue 2502763005: ShapeDetection: Add FaceDetectorOptions for fastMode and maxDetectedFaces (Closed)
Patch Set: Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "modules/shapedetection/ShapeDetector.h" 5 #include "modules/shapedetection/ShapeDetector.h"
6 6
7 #include "core/dom/DOMException.h" 7 #include "core/dom/DOMException.h"
8 #include "core/dom/DOMRect.h" 8 #include "core/dom/DOMRect.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/fetch/ImageResource.h" 10 #include "core/fetch/ImageResource.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 resolver->reject(DOMException::create( 159 resolver->reject(DOMException::create(
160 NotSupportedError, "Shape detection service unavailable.")); 160 NotSupportedError, "Shape detection service unavailable."));
161 return promise; 161 return promise;
162 } 162 }
163 163
164 m_serviceRequests.add(resolver); 164 m_serviceRequests.add(resolver);
165 DCHECK(m_service.is_bound()); 165 DCHECK(m_service.is_bound());
166 if (detectorType == DetectorType::Face) { 166 if (detectorType == DetectorType::Face) {
167 m_service->DetectFaces( 167 m_service->DetectFaces(
168 std::move(sharedBufferHandle), img->naturalWidth(), 168 std::move(sharedBufferHandle), img->naturalWidth(),
169 img->naturalHeight(), 169 img->naturalHeight(), m_options.Clone(),
170 convertToBaseCallback(WTF::bind(&ShapeDetector::onDetectFaces, 170 convertToBaseCallback(WTF::bind(&ShapeDetector::onDetectFaces,
171 wrapPersistent(this), 171 wrapPersistent(this),
172 wrapPersistent(resolver)))); 172 wrapPersistent(resolver))));
173 } else if (detectorType == DetectorType::Barcode) { 173 } else if (detectorType == DetectorType::Barcode) {
174 m_service->DetectBarcodes( 174 m_service->DetectBarcodes(
175 std::move(sharedBufferHandle), img->naturalWidth(), 175 std::move(sharedBufferHandle), img->naturalWidth(),
176 img->naturalHeight(), 176 img->naturalHeight(),
177 convertToBaseCallback(WTF::bind(&ShapeDetector::onDetectBarcodes, 177 convertToBaseCallback(WTF::bind(&ShapeDetector::onDetectBarcodes,
178 wrapPersistent(this), 178 wrapPersistent(this),
179 wrapPersistent(resolver)))); 179 wrapPersistent(resolver))));
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 const mojo::ScopedSharedBufferMapping mappedBuffer = 299 const mojo::ScopedSharedBufferMapping mappedBuffer =
300 sharedBufferHandle->Map(size); 300 sharedBufferHandle->Map(size);
301 DCHECK(mappedBuffer.get()); 301 DCHECK(mappedBuffer.get());
302 302
303 memcpy(mappedBuffer.get(), data, size); 303 memcpy(mappedBuffer.get(), data, size);
304 304
305 m_serviceRequests.add(resolver); 305 m_serviceRequests.add(resolver);
306 DCHECK(m_service.is_bound()); 306 DCHECK(m_service.is_bound());
307 if (detectorType == DetectorType::Face) { 307 if (detectorType == DetectorType::Face) {
308 m_service->DetectFaces( 308 m_service->DetectFaces(
309 std::move(sharedBufferHandle), width, height, 309 std::move(sharedBufferHandle), width, height, m_options.Clone(),
310 convertToBaseCallback(WTF::bind(&ShapeDetector::onDetectFaces, 310 convertToBaseCallback(WTF::bind(&ShapeDetector::onDetectFaces,
311 wrapPersistent(this), 311 wrapPersistent(this),
312 wrapPersistent(resolver)))); 312 wrapPersistent(resolver))));
313 } else if (detectorType == DetectorType::Barcode) { 313 } else if (detectorType == DetectorType::Barcode) {
314 m_service->DetectBarcodes( 314 m_service->DetectBarcodes(
315 std::move(sharedBufferHandle), width, height, 315 std::move(sharedBufferHandle), width, height,
316 convertToBaseCallback(WTF::bind(&ShapeDetector::onDetectBarcodes, 316 convertToBaseCallback(WTF::bind(&ShapeDetector::onDetectBarcodes,
317 wrapPersistent(this), 317 wrapPersistent(this),
318 wrapPersistent(resolver)))); 318 wrapPersistent(resolver))));
319 } else { 319 } else {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 } 357 }
358 358
359 resolver->resolve(detectedBarcodes); 359 resolver->resolve(detectedBarcodes);
360 } 360 }
361 361
362 DEFINE_TRACE(ShapeDetector) { 362 DEFINE_TRACE(ShapeDetector) {
363 visitor->trace(m_serviceRequests); 363 visitor->trace(m_serviceRequests);
364 } 364 }
365 365
366 } // namespace blink 366 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698