All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
27 }
28 
30 }
31 
33  BLOBNBOX* blob) {
34  ASSERT_HOST(pix != NULL && pixGetDepth(pix) == 32 && blob != NULL);
35  const TBOX& tbox = blob->bounding_box();
36  int height = pixGetHeight(pix);
37  const int box_width = 5;
38 
39  // Coordinate translation: tesseract use left bottom as the original, while
40  // leptonica uses left top as the original.
41  Box *box = boxCreate(tbox.left(), height - tbox.top(),
42  tbox.width(), tbox.height());
43  switch (blob->special_text_type()) {
44  case BSTT_MATH: // Red box.
45  pixRenderBoxArb(pix, box, box_width, 255, 0, 0);
46  break;
47  case BSTT_DIGIT: // cyan box.
48  pixRenderBoxArb(pix, box, box_width, 0, 255, 255);
49  break;
50  case BSTT_ITALIC: // Green box.
51  pixRenderBoxArb(pix, box, box_width, 0, 255, 0);
52  break;
53  case BSTT_UNCLEAR: // blue box.
54  pixRenderBoxArb(pix, box, box_width, 0, 255, 0);
55  break;
56  case BSTT_NONE:
57  default:
58  // yellow box.
59  pixRenderBoxArb(pix, box, box_width, 255, 255, 0);
60  break;
61  }
62  boxDestroy(&box);
63 }
64 
65 }; // namespace tesseract
#define ASSERT_HOST(x)
Definition: errcode.h:84
inT16 left() const
Definition: rect.h:68
static void RenderSpecialText(Pix *pix, BLOBNBOX *blob)
BlobSpecialTextType special_text_type() const
Definition: blobbox.h:274
inT16 height() const
Definition: rect.h:104
inT16 width() const
Definition: rect.h:111
Definition: rect.h:30
#define NULL
Definition: host.h:144
const TBOX & bounding_box() const
Definition: blobbox.h:215
inT16 top() const
Definition: rect.h:54