OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 // Original code is licensed as follows: | 6 // Original code is licensed as follows: |
7 /* | 7 /* |
8 * Copyright 2008 ZXing authors | 8 * Copyright 2008 ZXing authors |
9 * | 9 * |
10 * Licensed under the Apache License, Version 2.0 (the "License"); | 10 * Licensed under the Apache License, Version 2.0 (the "License"); |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 const int32_t CBC_DataMatrixDetector::INTEGERS[5] = {0, 1, 2, 3, 4}; | 34 const int32_t CBC_DataMatrixDetector::INTEGERS[5] = {0, 1, 2, 3, 4}; |
35 CBC_DataMatrixDetector::CBC_DataMatrixDetector(CBC_CommonBitMatrix* image) | 35 CBC_DataMatrixDetector::CBC_DataMatrixDetector(CBC_CommonBitMatrix* image) |
36 : m_image(image), m_rectangleDetector(NULL) {} | 36 : m_image(image), m_rectangleDetector(NULL) {} |
37 void CBC_DataMatrixDetector::Init(int32_t& e) { | 37 void CBC_DataMatrixDetector::Init(int32_t& e) { |
38 m_rectangleDetector = new CBC_WhiteRectangleDetector(m_image); | 38 m_rectangleDetector = new CBC_WhiteRectangleDetector(m_image); |
39 m_rectangleDetector->Init(e); | 39 m_rectangleDetector->Init(e); |
40 BC_EXCEPTION_CHECK_ReturnVoid(e); | 40 BC_EXCEPTION_CHECK_ReturnVoid(e); |
41 } | 41 } |
42 CBC_DataMatrixDetector::~CBC_DataMatrixDetector() { | 42 CBC_DataMatrixDetector::~CBC_DataMatrixDetector() { |
43 if (m_rectangleDetector != NULL) { | 43 delete m_rectangleDetector; |
44 delete m_rectangleDetector; | |
45 } | |
46 m_rectangleDetector = NULL; | |
47 } | 44 } |
48 inline FX_BOOL ResultPointsAndTransitionsComparator(void* a, void* b) { | 45 inline FX_BOOL ResultPointsAndTransitionsComparator(void* a, void* b) { |
49 return ((CBC_ResultPointsAndTransitions*)b)->GetTransitions() > | 46 return ((CBC_ResultPointsAndTransitions*)b)->GetTransitions() > |
50 ((CBC_ResultPointsAndTransitions*)a)->GetTransitions(); | 47 ((CBC_ResultPointsAndTransitions*)a)->GetTransitions(); |
51 } | 48 } |
52 CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { | 49 CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { |
53 CFX_PtrArray* cornerPoints = m_rectangleDetector->Detect(e); | 50 CFX_PtrArray* cornerPoints = m_rectangleDetector->Detect(e); |
54 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 51 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
55 CBC_ResultPoint* pointA = (CBC_ResultPoint*)(*cornerPoints)[0]; | 52 CBC_ResultPoint* pointA = (CBC_ResultPoint*)(*cornerPoints)[0]; |
56 CBC_ResultPoint* pointB = (CBC_ResultPoint*)(*cornerPoints)[1]; | 53 CBC_ResultPoint* pointB = (CBC_ResultPoint*)(*cornerPoints)[1]; |
(...skipping 18 matching lines...) Expand all Loading... |
75 Increment(pointCount, lSideOne->GetTo()); | 72 Increment(pointCount, lSideOne->GetTo()); |
76 Increment(pointCount, lSideTwo->GetFrom()); | 73 Increment(pointCount, lSideTwo->GetFrom()); |
77 Increment(pointCount, lSideTwo->GetTo()); | 74 Increment(pointCount, lSideTwo->GetTo()); |
78 delete ((CBC_ResultPointsAndTransitions*)transitions[1]); | 75 delete ((CBC_ResultPointsAndTransitions*)transitions[1]); |
79 delete ((CBC_ResultPointsAndTransitions*)transitions[0]); | 76 delete ((CBC_ResultPointsAndTransitions*)transitions[0]); |
80 transitions.RemoveAll(); | 77 transitions.RemoveAll(); |
81 CBC_ResultPoint* maybeTopLeft = NULL; | 78 CBC_ResultPoint* maybeTopLeft = NULL; |
82 CBC_ResultPoint* bottomLeft = NULL; | 79 CBC_ResultPoint* bottomLeft = NULL; |
83 CBC_ResultPoint* maybeBottomRight = NULL; | 80 CBC_ResultPoint* maybeBottomRight = NULL; |
84 FX_POSITION itBegin = pointCount.GetStartPosition(); | 81 FX_POSITION itBegin = pointCount.GetStartPosition(); |
85 while (itBegin != NULL) { | 82 while (itBegin) { |
86 CBC_ResultPoint* key = 0; | 83 CBC_ResultPoint* key = 0; |
87 int32_t value = 0; | 84 int32_t value = 0; |
88 pointCount.GetNextAssoc(itBegin, key, value); | 85 pointCount.GetNextAssoc(itBegin, key, value); |
89 if (value == 2) { | 86 if (value == 2) { |
90 bottomLeft = key; | 87 bottomLeft = key; |
91 } else { | 88 } else { |
92 if (maybeBottomRight == NULL) { | 89 if (maybeBottomRight == NULL) { |
93 maybeBottomRight = key; | 90 maybeBottomRight = key; |
94 } else { | 91 } else { |
95 maybeTopLeft = key; | 92 maybeTopLeft = key; |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 (bottomLeft->GetX() - topLeft->GetX()) * | 395 (bottomLeft->GetX() - topLeft->GetX()) * |
399 (topRight->GetY() - topLeft->GetY())) { | 396 (topRight->GetY() - topLeft->GetY())) { |
400 CBC_ResultPoint* temp = topRight; | 397 CBC_ResultPoint* temp = topRight; |
401 topRight = bottomLeft; | 398 topRight = bottomLeft; |
402 bottomLeft = temp; | 399 bottomLeft = temp; |
403 } | 400 } |
404 (*patterns)[0] = bottomLeft; | 401 (*patterns)[0] = bottomLeft; |
405 (*patterns)[1] = topLeft; | 402 (*patterns)[1] = topLeft; |
406 (*patterns)[2] = topRight; | 403 (*patterns)[2] = topRight; |
407 } | 404 } |
OLD | NEW |