Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
equationdetectbase.cpp
Go to the documentation of this file.
1
2 // 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 EquationDetectBase::EquationDetectBase() {
27 }
28
29 EquationDetectBase::~EquationDetectBase() {
30 }
31
32 void EquationDetectBase::RenderSpecialText(Pix* pix,
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