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
feature_hybrid.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 * File: feature_chebyshev.cpp
3 * Description: Implementation of the Chebyshev coefficients Feature Class
4 * Author: Ahmad Abdulkader
5 * Created: 2008
6 *
7 * (C) Copyright 2008, 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 *
18 **********************************************************************/
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <math.h>
23 #include <string>
24 #include <vector>
25 #include <algorithm>
26 #include "feature_base.h"
27 #include "feature_hybrid.h"
28 #include "cube_utils.h"
29 #include "const.h"
30 #include "char_samp.h"
31
32 namespace tesseract {
33
34 FeatureHybrid::FeatureHybrid(TuningParams *params)
35 :FeatureBase(params) {
36 feature_bmp_ = new FeatureBmp(params);
37 feature_chebyshev_ = new FeatureChebyshev(params);
38 }
39
40 FeatureHybrid::~FeatureHybrid() {
41 delete feature_bmp_;
42 delete feature_chebyshev_;
43 }
44
45 // Render a visualization of the features to a CharSamp.
46 // This is mainly used by visual-debuggers
47 CharSamp *FeatureHybrid::ComputeFeatureBitmap(CharSamp *char_samp) {
48 return char_samp;
49 }
50
51
52 // Compute the features of a given CharSamp
53 bool FeatureHybrid::ComputeFeatures(CharSamp *char_samp, float *features) {
54 if (feature_bmp_ == NULL || feature_chebyshev_ == NULL) {
55 return false;
56 }
57 if (!feature_bmp_->ComputeFeatures(char_samp, features)) {
58 return false;
59 }
60 return feature_chebyshev_->ComputeFeatures(char_samp,
61 features + feature_bmp_->FeatureCnt());
62 }
63
64 } // namespace tesseract