* File: pithsync.h (Formerly pitsync2.h)
* Description: Code to find the optimum fixed pitch segmentation of some blobs.
* Author: Ray Smith
*
* (C) Copyright 1992, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
** http://www.apache.org/licenses/LICENSE-2.0
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*
**********************************************************************/
#ifndef PITHSYNC_H
#define PITHSYNC_H
#include "blobbox.h"
#include "params.h"
#include "statistc.h"
namespace tesseract {
class FPSEGPT_LIST;
class FPCUTPT {
public:
FPCUTPT() = default;
void setup(
FPCUTPT cutpts[],
int16_t array_origin,
STATS *projection,
int16_t zero_count,
int16_t pitch,
int16_t x,
int16_t offset);
void assign(
FPCUTPT cutpts[],
int16_t array_origin,
int16_t x,
bool faking,
bool mid_cut,
int16_t offset,
STATS *projection,
float projection_scale,
int16_t zero_count,
int16_t pitch,
int16_t pitch_error);
void assign_cheap(
FPCUTPT cutpts[],
int16_t array_origin,
int16_t x,
bool faking,
bool mid_cut,
int16_t offset,
STATS *projection,
float projection_scale,
int16_t zero_count,
int16_t pitch,
int16_t pitch_error);
int32_t position() {
return xpos;
}
double cost_function() {
return cost;
}
double squares() {
return sq_sum;
}
double sum() {
return mean_sum;
}
FPCUTPT *previous() {
return pred;
}
int16_t cheap_cuts() const {
return mid_cuts;
}
int16_t index() const {
return region_index;
}
bool faked;
bool terminal;
int16_t fake_count;
private:
int16_t region_index;
int16_t mid_cuts;
int32_t xpos;
uint32_t back_balance;
uint32_t fwd_balance;
FPCUTPT *pred;
double mean_sum;
double sq_sum;
double cost;
};
double check_pitch_sync2(
BLOBNBOX_IT *blob_it,
int16_t blob_count,
int16_t pitch,
int16_t pitch_error,
STATS *projection,
int16_t projection_left,
int16_t projection_right, float projection_scale,
int16_t &occupation_count,
FPSEGPT_LIST *seg_list,
int16_t start,
int16_t end
);
double check_pitch_sync3(
int16_t projection_left,
int16_t projection_right, int16_t zero_count,
int16_t pitch,
int16_t pitch_error,
STATS *projection,
float projection_scale,
int16_t &occupation_count,
FPSEGPT_LIST *seg_list,
int16_t start,
int16_t end
);
}
#endif