tesseract  4.0.0-1-g2a2b
equationdetectbase.cpp
Go to the documentation of this file.
1 // File: equationdetectbase.cpp
3 // Description: The base class equation detection class.
4 // Author: Zongyi (Joe) Liu (joeliu@google.com)
5 // Created: Fri Aug 31 11:13:01 PST 2011
6 //
7 // (C) Copyright 2011, Google Inc.
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17 //
19 
20 #include "allheaders.h"
21 #include "blobbox.h"
22 #include "equationdetectbase.h"
23 
24 namespace tesseract {
25 
26 // Destructor.
27 // It is defined here, so the compiler can create a single vtable
28 // instead of weak vtables in every compilation unit.
30 
32  BLOBNBOX* blob) {
33  ASSERT_HOST(pix != nullptr && pixGetDepth(pix) == 32 && blob != nullptr);
34  const TBOX& tbox = blob->bounding_box();
35  int height = pixGetHeight(pix);
36  const int box_width = 5;
37 
38  // Coordinate translation: tesseract use left bottom as the original, while
39  // leptonica uses left top as the original.
40  Box *box = boxCreate(tbox.left(), height - tbox.top(),
41  tbox.width(), tbox.height());
42  switch (blob->special_text_type()) {
43  case BSTT_MATH: // Red box.
44  pixRenderBoxArb(pix, box, box_width, 255, 0, 0);
45  break;
46  case BSTT_DIGIT: // cyan box.
47  pixRenderBoxArb(pix, box, box_width, 0, 255, 255);
48  break;
49  case BSTT_ITALIC: // Green box.
50  pixRenderBoxArb(pix, box, box_width, 0, 255, 0);
51  break;
52  case BSTT_UNCLEAR: // blue box.
53  pixRenderBoxArb(pix, box, box_width, 0, 255, 0);
54  break;
55  case BSTT_NONE:
56  default:
57  // yellow box.
58  pixRenderBoxArb(pix, box, box_width, 255, 255, 0);
59  break;
60  }
61  boxDestroy(&box);
62 }
63 
64 } // namespace tesseract
Definition: rect.h:34
static void RenderSpecialText(Pix *pix, BLOBNBOX *blob)
int16_t width() const
Definition: rect.h:115
int16_t left() const
Definition: rect.h:72
int16_t top() const
Definition: rect.h:58
BlobSpecialTextType special_text_type() const
Definition: blobbox.h:290
const TBOX & bounding_box() const
Definition: blobbox.h:231
int16_t height() const
Definition: rect.h:108
#define ASSERT_HOST(x)
Definition: errcode.h:84