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

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

Issue 2575943002: Barcode Detection: Add |cornerPoints| to DetectedBarcode.idl (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/BarcodeDetector.h" 5 #include "modules/shapedetection/BarcodeDetector.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/frame/LocalDOMWindow.h" 9 #include "core/frame/LocalDOMWindow.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
11 #include "core/html/canvas/CanvasImageSource.h" 11 #include "core/html/canvas/CanvasImageSource.h"
12 #include "modules/imagecapture/Point2D.h"
12 #include "modules/shapedetection/DetectedBarcode.h" 13 #include "modules/shapedetection/DetectedBarcode.h"
13 #include "public/platform/InterfaceProvider.h" 14 #include "public/platform/InterfaceProvider.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 BarcodeDetector* BarcodeDetector::create(Document& document) { 18 BarcodeDetector* BarcodeDetector::create(Document& document) {
18 return new BarcodeDetector(*document.frame()); 19 return new BarcodeDetector(*document.frame());
19 } 20 }
20 21
21 BarcodeDetector::BarcodeDetector(LocalFrame& frame) : ShapeDetector(frame) { 22 BarcodeDetector::BarcodeDetector(LocalFrame& frame) : ShapeDetector(frame) {
(...skipping 24 matching lines...) Expand all
46 } 47 }
47 48
48 void BarcodeDetector::onDetectBarcodes( 49 void BarcodeDetector::onDetectBarcodes(
49 ScriptPromiseResolver* resolver, 50 ScriptPromiseResolver* resolver,
50 Vector<mojom::blink::BarcodeDetectionResultPtr> barcodeDetectionResults) { 51 Vector<mojom::blink::BarcodeDetectionResultPtr> barcodeDetectionResults) {
51 DCHECK(m_barcodeServiceRequests.contains(resolver)); 52 DCHECK(m_barcodeServiceRequests.contains(resolver));
52 m_barcodeServiceRequests.remove(resolver); 53 m_barcodeServiceRequests.remove(resolver);
53 54
54 HeapVector<Member<DetectedBarcode>> detectedBarcodes; 55 HeapVector<Member<DetectedBarcode>> detectedBarcodes;
55 for (const auto& barcode : barcodeDetectionResults) { 56 for (const auto& barcode : barcodeDetectionResults) {
57 HeapVector<Point2D> cornerPoints;
58 for (int i = 0; i < 4; i++) {
59 Point2D point;
60 point.setX((barcode->corner_points)[i]->x);
61 point.setY((barcode->corner_points)[i]->y);
62 cornerPoints.append(point);
63 }
mcasas 2016/12/15 19:01:58 for (const auto& point: barcode->corner_points) {
xianglu 2016/12/16 00:01:25 Done.
56 detectedBarcodes.append(DetectedBarcode::create( 64 detectedBarcodes.append(DetectedBarcode::create(
57 barcode->raw_value, 65 barcode->raw_value,
58 DOMRect::create(barcode->bounding_box->x, barcode->bounding_box->y, 66 DOMRect::create(barcode->bounding_box->x, barcode->bounding_box->y,
59 barcode->bounding_box->width, 67 barcode->bounding_box->width,
60 barcode->bounding_box->height))); 68 barcode->bounding_box->height),
69 cornerPoints));
61 } 70 }
62 71
63 resolver->resolve(detectedBarcodes); 72 resolver->resolve(detectedBarcodes);
64 } 73 }
65 74
66 void BarcodeDetector::onBarcodeServiceConnectionError() { 75 void BarcodeDetector::onBarcodeServiceConnectionError() {
67 for (const auto& request : m_barcodeServiceRequests) { 76 for (const auto& request : m_barcodeServiceRequests) {
68 request->reject(DOMException::create(NotSupportedError, 77 request->reject(DOMException::create(NotSupportedError,
69 "Barcode Detection not implemented.")); 78 "Barcode Detection not implemented."));
70 } 79 }
71 m_barcodeServiceRequests.clear(); 80 m_barcodeServiceRequests.clear();
72 m_barcodeService.reset(); 81 m_barcodeService.reset();
73 } 82 }
74 83
75 DEFINE_TRACE(BarcodeDetector) { 84 DEFINE_TRACE(BarcodeDetector) {
76 ShapeDetector::trace(visitor); 85 ShapeDetector::trace(visitor);
77 visitor->trace(m_barcodeServiceRequests); 86 visitor->trace(m_barcodeServiceRequests);
78 } 87 }
79 88
80 } // namespace blink 89 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698