Tesseract
3.02
|
00001 /********************************************************************** 00002 * File: feature_chebyshev.cpp 00003 * Description: Implementation of the Chebyshev coefficients Feature Class 00004 * Author: Ahmad Abdulkader 00005 * Created: 2008 00006 * 00007 * (C) Copyright 2008, Google Inc. 00008 ** Licensed under the Apache License, Version 2.0 (the "License"); 00009 ** you may not use this file except in compliance with the License. 00010 ** You may obtain a copy of the License at 00011 ** http://www.apache.org/licenses/LICENSE-2.0 00012 ** Unless required by applicable law or agreed to in writing, software 00013 ** distributed under the License is distributed on an "AS IS" BASIS, 00014 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 ** See the License for the specific language governing permissions and 00016 ** limitations under the License. 00017 * 00018 **********************************************************************/ 00019 00020 #include <stdio.h> 00021 #include <stdlib.h> 00022 #include <math.h> 00023 #include <string> 00024 #include <vector> 00025 #include <algorithm> 00026 #include "feature_base.h" 00027 #include "feature_hybrid.h" 00028 #include "cube_utils.h" 00029 #include "const.h" 00030 #include "char_samp.h" 00031 00032 namespace tesseract { 00033 00034 FeatureHybrid::FeatureHybrid(TuningParams *params) 00035 :FeatureBase(params) { 00036 feature_bmp_ = new FeatureBmp(params); 00037 feature_chebyshev_ = new FeatureChebyshev(params); 00038 } 00039 00040 FeatureHybrid::~FeatureHybrid() { 00041 delete feature_bmp_; 00042 delete feature_chebyshev_; 00043 } 00044 00045 // Render a visualization of the features to a CharSamp. 00046 // This is mainly used by visual-debuggers 00047 CharSamp *FeatureHybrid::ComputeFeatureBitmap(CharSamp *char_samp) { 00048 return char_samp; 00049 } 00050 00051 00052 // Compute the features of a given CharSamp 00053 bool FeatureHybrid::ComputeFeatures(CharSamp *char_samp, float *features) { 00054 if (feature_bmp_ == NULL || feature_chebyshev_ == NULL) { 00055 return false; 00056 } 00057 if (!feature_bmp_->ComputeFeatures(char_samp, features)) { 00058 return false; 00059 } 00060 return feature_chebyshev_->ComputeFeatures(char_samp, 00061 features + feature_bmp_->FeatureCnt()); 00062 } 00063 00064 } // namespace tesseract