#include <detlinefit.h>
|
| DetLineFit () |
|
| ~DetLineFit () |
|
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 |
( |
| ) |
|
◆ 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 131 of file detlinefit.cpp.
134 ComputeConstrainedDistances(
direction, min_dist, max_dist);
136 if (pts_.
empty() || distances_.empty()) {
141 int median_index = distances_.choose_nth_item(distances_.size() / 2);
142 *line_pt = distances_[median_index].data;
144 tprintf(
"Constrained fit to dir %g, %g = %d, %d :%d distances:\n",
146 line_pt->
x(), line_pt->
y(), distances_.size());
147 for (
int i = 0; i < distances_.size(); ++i) {
148 tprintf(
"%d: %d, %d -> %g\n", i, distances_[i].data.x(),
149 distances_[i].data.y(), distances_[i].key);
151 tprintf(
"Result = %d\n", median_index);
154 double dist_origin =
direction * *line_pt;
155 for (
int i = 0; i < distances_.size(); ++i) {
156 distances_[i].key -= dist_origin;
158 return sqrt(EvaluateLineFit());
inT16 x() const
access function
int direction(EDGEPT *point)
void set_y(inT16 yin)
rewrite function
void set_x(inT16 xin)
rewrite function
inT16 y() const
access_function
◆ ConstrainedFit() [2/2]
double tesseract::DetLineFit::ConstrainedFit |
( |
double |
m, |
|
|
float * |
c |
|
) |
| |
Definition at line 186 of file detlinefit.cpp.
192 double cos = 1.0 / sqrt(1.0 + m * m);
197 *c = line_pt.
y() - line_pt.
x() * m;
double ConstrainedFit(const FCOORD &direction, double min_dist, double max_dist, bool debug, ICOORD *line_pt)
inT16 x() const
access function
int direction(EDGEPT *point)
inT16 y() const
access_function
◆ 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 66 of file detlinefit.cpp.
76 int pt_count = pts_.
size();
78 if (skip_first >= pt_count) skip_first = pt_count - 1;
81 for (
int i = skip_first; i < end_i; ++i) {
82 starts[start_count++] = &pts_[i].pt;
85 if (skip_last >= pt_count) skip_last = pt_count - 1;
88 for (
int i = pt_count - 1 - skip_last; i >= end_i; --i) {
89 ends[end_count++] = &pts_[i].pt;
103 double best_uq = -1.0;
105 for (
int i = 0; i < start_count; ++i) {
106 ICOORD* start = starts[i];
107 for (
int j = 0; j < end_count; ++j) {
109 if (*start != *end) {
110 ComputeDistances(*start, *end);
112 double dist = EvaluateLineFit();
113 if (dist < best_uq || best_uq < 0.0) {
122 return best_uq > 0.0 ? sqrt(best_uq) : best_uq;
void set_y(inT16 yin)
rewrite function
void set_x(inT16 xin)
rewrite function
◆ Fit() [3/3]
double tesseract::DetLineFit::Fit |
( |
float * |
m, |
|
|
float * |
c |
|
) |
| |
Definition at line 170 of file detlinefit.cpp.
172 double error =
Fit(&start, &end);
173 if (end.
x() != start.
x()) {
174 *m =
static_cast<float>(end.
y() - start.
y()) / (end.
x() - start.
x());
175 *c = start.
y() - *m * start.
x();
double Fit(ICOORD *pt1, ICOORD *pt2)
inT16 x() const
access function
inT16 y() const
access_function
◆ SufficientPointsForIndependentFit()
bool tesseract::DetLineFit::SufficientPointsForIndependentFit |
( |
| ) |
const |
The documentation for this class was generated from the following files: