#include <dppoint.h>
Definition at line 44 of file dppoint.h.
◆ CostFunc
typedef int64_t(DPPoint::* tesseract::DPPoint::CostFunc) (const DPPoint *prev) |
◆ DPPoint()
tesseract::DPPoint::DPPoint |
( |
| ) |
|
|
inline |
Definition at line 51 of file dppoint.h.
52 : local_cost_(0), total_cost_(INT32_MAX), total_steps_(1), best_prev_(
nullptr),
53 n_(0), sig_x_(0), sig_xsq_(0) {
◆ AddLocalCost()
void tesseract::DPPoint::AddLocalCost |
( |
int |
new_cost | ) |
|
|
inline |
Definition at line 77 of file dppoint.h.
78 local_cost_ += new_cost;
◆ best_prev()
const DPPoint* tesseract::DPPoint::best_prev |
( |
| ) |
const |
|
inline |
◆ CostWithVariance()
int64_t tesseract::DPPoint::CostWithVariance |
( |
const DPPoint * |
prev | ) |
|
Definition at line 69 of file dppoint.cpp.
70 if (prev ==
nullptr || prev ==
this) {
71 UpdateIfBetter(0, 1,
nullptr, 0, 0, 0);
75 int delta =
this - prev;
76 int32_t n = prev->n_ + 1;
77 int32_t sig_x = prev->sig_x_ + delta;
78 int64_t sig_xsq = prev->sig_xsq_ + delta * delta;
79 int64_t cost = (sig_xsq - sig_x * sig_x / n) / n;
80 cost += prev->total_cost_;
81 UpdateIfBetter(cost, prev->total_steps_ + 1, prev, n, sig_x, sig_xsq);
◆ Pathlength()
int tesseract::DPPoint::Pathlength |
( |
| ) |
const |
|
inline |
◆ Solve()
DPPoint * tesseract::DPPoint::Solve |
( |
int |
min_step, |
|
|
int |
max_step, |
|
|
bool |
debug, |
|
|
CostFunc |
cost_func, |
|
|
int |
size, |
|
|
DPPoint * |
points |
|
) |
| |
|
static |
Definition at line 31 of file dppoint.cpp.
33 if (size <= 0 || max_step < min_step || min_step >= size)
40 for (
int i = 0; i < size; ++i) {
41 for (
int offset = min_step; offset <= max_step; ++offset) {
42 DPPoint* prev = offset <= i ? points + i - offset :
nullptr;
43 int64_t new_cost = (points[i].*cost_func)(prev);
44 if (points[i].best_prev_ !=
nullptr && offset > min_step * 2 &&
45 new_cost > points[i].total_cost_)
48 points[i].total_cost_ += points[i].local_cost_;
50 tprintf(
"At point %d, local cost=%d, total_cost=%d, steps=%d\n",
51 i, points[i].local_cost_, points[i].total_cost_,
52 points[i].total_steps_);
56 int best_cost = points[size - 1].total_cost_;
57 int best_end = size - 1;
58 for (
int end = best_end - 1; end >= size - min_step; --end) {
59 int cost = points[end].total_cost_;
60 if (cost < best_cost) {
65 return points + best_end;
DLLSYM void tprintf(const char *format,...)
◆ total_cost()
int tesseract::DPPoint::total_cost |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following files:
- /usr/src/tesseract-ocr.master/src/ccstruct/dppoint.h
- /usr/src/tesseract-ocr.master/src/ccstruct/dppoint.cpp