#include <detlinefit.h>
|
| DetLineFit () |
|
| ~DetLineFit ()=default |
|
void | Clear () |
|
void | Add (const ICOORD &pt) |
|
void | Add (const ICOORD &pt, int halfwidth) |
|
double | Fit (ICOORD *pt1, ICOORD *pt2) |
|
double | Fit (int skip_first, int skip_last, ICOORD *pt1, ICOORD *pt2) |
|
double | ConstrainedFit (const FCOORD &direction, double min_dist, double max_dist, bool debug, ICOORD *line_pt) |
|
bool | SufficientPointsForIndependentFit () const |
|
double | Fit (float *m, float *c) |
|
double | ConstrainedFit (double m, float *c) |
|
Definition at line 56 of file detlinefit.h.
◆ DetLineFit()
tesseract::DetLineFit::DetLineFit |
( |
| ) |
|
◆ ~DetLineFit()
tesseract::DetLineFit::~DetLineFit |
( |
| ) |
|
|
default |
◆ Add() [1/2]
void tesseract::DetLineFit::Add |
( |
const ICOORD & |
pt | ) |
|
◆ Add() [2/2]
void tesseract::DetLineFit::Add |
( |
const ICOORD & |
pt, |
|
|
int |
halfwidth |
|
) |
| |
◆ Clear()
void tesseract::DetLineFit::Clear |
( |
| ) |
|
◆ ConstrainedFit() [1/2]
double tesseract::DetLineFit::ConstrainedFit |
( |
const FCOORD & |
direction, |
|
|
double |
min_dist, |
|
|
double |
max_dist, |
|
|
bool |
debug, |
|
|
ICOORD * |
line_pt |
|
) |
| |
Definition at line 130 of file detlinefit.cpp.
133 ComputeConstrainedDistances(
direction, min_dist, max_dist);
135 if (pts_.
empty() || distances_.empty()) {
140 int median_index = distances_.choose_nth_item(distances_.size() / 2);
141 *line_pt = distances_[median_index].data;
143 tprintf(
"Constrained fit to dir %g, %g = %d, %d :%d distances:\n",
145 line_pt->
x(), line_pt->
y(), distances_.size());
146 for (
int i = 0; i < distances_.size(); ++i) {
147 tprintf(
"%d: %d, %d -> %g\n", i, distances_[i].data.x(),
148 distances_[i].data.y(), distances_[i].key);
150 tprintf(
"Result = %d\n", median_index);
153 double dist_origin =
direction * *line_pt;
154 for (
int i = 0; i < distances_.size(); ++i) {
155 distances_[i].key -= dist_origin;
157 return sqrt(EvaluateLineFit());
void set_x(int16_t xin)
rewrite function
int16_t y() const
access_function
int direction(EDGEPT *point)
int16_t x() const
access function
DLLSYM void tprintf(const char *format,...)
void set_y(int16_t yin)
rewrite function
◆ ConstrainedFit() [2/2]
double tesseract::DetLineFit::ConstrainedFit |
( |
double |
m, |
|
|
float * |
c |
|
) |
| |
Definition at line 185 of file detlinefit.cpp.
191 double cos = 1.0 / sqrt(1.0 + m * m);
195 *c = line_pt.
y() - line_pt.
x() * m;
int16_t y() const
access_function
int direction(EDGEPT *point)
int16_t x() const
access function
double ConstrainedFit(const FCOORD &direction, double min_dist, double max_dist, bool debug, ICOORD *line_pt)
◆ Fit() [1/3]
double tesseract::DetLineFit::Fit |
( |
ICOORD * |
pt1, |
|
|
ICOORD * |
pt2 |
|
) |
| |
|
inline |
Definition at line 75 of file detlinefit.h.
76 return Fit(0, 0, pt1, pt2);
double Fit(ICOORD *pt1, ICOORD *pt2)
◆ Fit() [2/3]
double tesseract::DetLineFit::Fit |
( |
int |
skip_first, |
|
|
int |
skip_last, |
|
|
ICOORD * |
pt1, |
|
|
ICOORD * |
pt2 |
|
) |
| |
Definition at line 65 of file detlinefit.cpp.
75 int pt_count = pts_.
size();
77 if (skip_first >= pt_count) skip_first = pt_count - 1;
80 for (
int i = skip_first; i < end_i; ++i) {
81 starts[start_count++] = &pts_[i].pt;
84 if (skip_last >= pt_count) skip_last = pt_count - 1;
87 for (
int i = pt_count - 1 - skip_last; i >= end_i; --i) {
88 ends[end_count++] = &pts_[i].pt;
102 double best_uq = -1.0;
104 for (
int i = 0; i < start_count; ++i) {
105 ICOORD* start = starts[i];
106 for (
int j = 0; j < end_count; ++j) {
108 if (*start != *end) {
109 ComputeDistances(*start, *end);
111 double dist = EvaluateLineFit();
112 if (dist < best_uq || best_uq < 0.0) {
121 return best_uq > 0.0 ? sqrt(best_uq) : best_uq;
void set_x(int16_t xin)
rewrite function
void set_y(int16_t yin)
rewrite function
◆ Fit() [3/3]
double tesseract::DetLineFit::Fit |
( |
float * |
m, |
|
|
float * |
c |
|
) |
| |
Definition at line 169 of file detlinefit.cpp.
171 double error =
Fit(&start, &end);
172 if (end.
x() != start.
x()) {
173 *m =
static_cast<float>(end.
y() - start.
y()) / (end.
x() - start.
x());
174 *c = start.
y() - *m * start.
x();
int16_t y() const
access_function
int16_t x() const
access function
double Fit(ICOORD *pt1, ICOORD *pt2)
◆ SufficientPointsForIndependentFit()
bool tesseract::DetLineFit::SufficientPointsForIndependentFit |
( |
| ) |
const |
The documentation for this class was generated from the following files: