tesseract
3.03
|
00001 /****************************************************************************** 00002 ** Filename: intfx.h 00003 ** Purpose: Interface to high level integer feature extractor. 00004 ** Author: Robert Moss 00005 ** History: Tue May 21 15:51:57 MDT 1991, RWM, Created. 00006 ** 00007 ** (c) Copyright Hewlett-Packard Company, 1988. 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 #ifndef INTFX_H 00019 #define INTFX_H 00020 00024 #include "blobs.h" 00025 #include "intproto.h" 00026 #include "normalis.h" 00027 #include <math.h> 00028 00029 class DENORM; 00030 00031 namespace tesseract { 00032 class TrainingSample; 00033 } 00034 00035 struct INT_FX_RESULT_STRUCT { 00036 inT32 Length; // total length of all outlines 00037 inT16 Xmean, Ymean; // center of mass of all outlines 00038 inT16 Rx, Ry; // radius of gyration 00039 inT16 NumBL, NumCN; // number of features extracted 00040 inT16 Width; // Width of blob in BLN coords. 00041 uinT8 YBottom; // Bottom of blob in BLN coords. 00042 uinT8 YTop; // Top of blob in BLN coords. 00043 }; 00044 00045 // The standard feature length 00046 const double kStandardFeatureLength = 64.0 / 5; 00047 00051 void InitIntegerFX(); 00052 00053 // Returns a vector representing the direction of a feature with the given 00054 // theta direction in an INT_FEATURE_STRUCT. 00055 FCOORD FeatureDirection(uinT8 theta); 00056 00057 namespace tesseract { 00058 // Generates a TrainingSample from a TBLOB. Extracts features and sets 00059 // the bounding box, so classifiers that operate on the image can work. 00060 // TODO(rays) BlobToTrainingSample must remain a global function until 00061 // the FlexFx and FeatureDescription code can be removed and LearnBlob 00062 // made a member of Classify. 00063 TrainingSample* BlobToTrainingSample( 00064 const TBLOB& blob, bool nonlinear_norm, INT_FX_RESULT_STRUCT* fx_info, 00065 GenericVector<INT_FEATURE_STRUCT>* bl_features); 00066 } 00067 00068 // Deprecated! Prefer tesseract::Classify::ExtractFeatures instead. 00069 bool ExtractIntFeat(const TBLOB& blob, 00070 bool nonlinear_norm, 00071 INT_FEATURE_ARRAY BLFeat, 00072 INT_FEATURE_ARRAY CNFeat, 00073 INT_FX_RESULT_STRUCT* Results); 00074 00075 #endif