Tesseract  3.02
tesseract-ocr/classify/tessclassifier.cpp
Go to the documentation of this file.
00001 // Copyright 2011 Google Inc. All Rights Reserved.
00002 // Author: rays@google.com (Ray Smith)
00004 // File:        tessclassifier.cpp
00005 // Description: Tesseract implementation of a ShapeClassifier.
00006 // Author:      Ray Smith
00007 // Created:     Tue Nov 22 14:16:25 PST 2011
00008 //
00009 // (C) Copyright 2011, Google Inc.
00010 // Licensed under the Apache License, Version 2.0 (the "License");
00011 // you may not use this file except in compliance with the License.
00012 // You may obtain a copy of the License at
00013 // http://www.apache.org/licenses/LICENSE-2.0
00014 // Unless required by applicable law or agreed to in writing, software
00015 // distributed under the License is distributed on an "AS IS" BASIS,
00016 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00017 // See the License for the specific language governing permissions and
00018 // limitations under the License.
00019 //
00021 
00022 #include "tessclassifier.h"
00023 
00024 #include "classify.h"
00025 #include "trainingsample.h"
00026 
00027 namespace tesseract {
00028 
00029 // Classifies the given [training] sample, writing to results.
00030 // See ShapeClassifier for a full description.
00031 int TessClassifier::ClassifySample(const TrainingSample& sample,
00032                                    Pix* page_pix, int debug, int keep_this,
00033                                    GenericVector<ShapeRating>* results) {
00034   if (debug) {
00035     classify_->matcher_debug_level.set_value(debug ? 2 : 0);
00036     classify_->matcher_debug_flags.set_value(debug ? 25 : 0);
00037     classify_->classify_debug_level.set_value(debug ? 3 : 0);
00038   } else {
00039     classify_->classify_debug_level.set_value(debug ? 2 : 0);
00040   }
00041   classify_->CharNormTrainingSample(pruner_only_, sample, results);
00042   return results->size();
00043 }
00044 
00045 // Provides access to the ShapeTable that this classifier works with.
00046 const ShapeTable* TessClassifier::GetShapeTable() const {
00047   return classify_->shape_table();
00048 }
00049 
00050 }  // namespace tesseract
00051 
00052