Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
laser_scan_utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
labrobotica
algorithms
laser_scan_utils
Commits
f9ee2867
Commit
f9ee2867
authored
9 years ago
by
andreucm
Browse files
Options
Downloads
Patches
Plain Diff
fitLineRansac pseudocode added
parent
6a77639b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.txt
+1
-1
1 addition, 1 deletion
README.txt
src/line_finder.cpp
+39
-0
39 additions, 0 deletions
src/line_finder.cpp
src/line_finder.h
+16
-0
16 additions, 0 deletions
src/line_finder.h
with
56 additions
and
1 deletion
README.txt
+
1
−
1
View file @
f9ee2867
A Toolbox with utilities for 2D laser scan processing, made at IRI (www.iri.upc.edu)
A
C++
Toolbox with utilities for 2D laser scan processing, made at IRI (www.iri.upc.edu)
This diff is collapsed.
Click to expand it.
src/line_finder.cpp
+
39
−
0
View file @
f9ee2867
...
...
@@ -30,6 +30,45 @@ void LineFinder::fitLine(const Eigen::MatrixXs & _points, LineSegment & _line) c
//_line.fit_error_ = (_points.transpose() * _line.abc_).array().abs().sum() / (_line.abc_.head(2).norm()*_points.cols());
}
void
LineFinder
::
fitLineRansac
(
const
Eigen
::
MatrixXs
&
_points
,
LineSegment
&
_line
,
ScalarT
_error
)
const
{
std
::
vector
<
bool
>
used_points
(
_points
.
cols
(),
false
);
//mask, true means used
std
::
vector
<
unsigned
int
>
available_points
(
_points
.
cols
());
unsigned
int
support_counter
,
best_support_counter
;
LineSegment
line
;
//init best_support_counter
best_support_counter
=
0
;
// while (attempts < max_attempts)
// {
//init available_points vector with all indexes
for
(
unsigned
int
ii
=
0
;
ii
<
available_points
.
size
();
ii
++
)
{
available_points
[
ii
]
=
ii
;
}
// pick randomly two indexes from available_points
// Set the selecte points to MatrixXs P
// fitLine(P,line)
// support_counter = 0;
// while (available_points.size() > 0 )
// {
// choose a point q randomly from the index vector available_points
// remove that index from available_points
// Compute dist between q and line
// if (dist < max_error) support_counter ++;
// }
//
// if ( support_counter > best_support_counter )
// {
// _line = line;
// best_support_counter = support_counter;
// }
// attempts ++;
// }
}
void
LineFinder
::
pointProjectionToLine
(
const
Eigen
::
Vector3s
&
_line
,
const
Eigen
::
Vector3s
&
_in_pt
,
Eigen
::
Vector3s
&
_out_pt
)
const
{
ScalarT
a
,
b
,
c
,
qx
,
qy
,
dd
;
...
...
This diff is collapsed.
Click to expand it.
src/line_finder.h
+
16
−
0
View file @
f9ee2867
...
...
@@ -47,6 +47,22 @@ class LineFinder
**/
void
fitLine
(
const
Eigen
::
MatrixXs
&
_points
,
LineSegment
&
_line
)
const
;
/** \brief Find the best fittig line given a set of points, applying RANSAC
*
* Find the best fittig line given a set of points, applying RANSAC
*
* \Requires:
* \param _points: 3xN matrix, set of points. Each column is a 2D point in homogeneous (x,y,1). Ordering is not required.
* \param _error: maximum fitting error to accept a point in a line
*
* \Provides:
* \param _line: a laserscanutils::Line object of the best fitting line in the Least Squares sense
*
* RANSAC is applied as outlier rejection method.
*
**/
void
fitLineRansac
(
const
Eigen
::
MatrixXs
&
_points
,
LineSegment
&
_line
,
ScalarT
_error
=
0.1
)
const
;
/** \brief Computes projection of point to line
*
* Computes the projection of _in_pt to _line. Result at _out_pt
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment