Classes | Files | Functions

Shape detection

Library shape_detect is used for detection of line segments in data measured by a laser scanner. More...

Classes

class  Shape_detect
 There are detected line segments in input array of measured data (laser_scan) by using perpendicular line regression. More...
struct  Shape_detect::General_form
 General equation of line -> Ax + By + C = 0. More...
struct  Shape_detect::Point
 Point expressed in cartesian coordinates. More...
struct  Shape_detect::Line
 Line defined by two points which are expressed in cartesian coordinates. More...
struct  Shape_detect::Arc
 Arc defined by TODO. More...

Files

file  offline.cc
 

Debug file for testing detection shape.


file  online.cc
 

Debug file for testing detection shape.


file  shape_detect.cc

Functions

int main (int argc, char **argv)
 There are detected line segments in input file (laser scan data).
 Shape_detect::Shape_detect (void)
 The constructor with default setting of detection properties (for Hokuyo).
 Shape_detect::Shape_detect (int line_min_points, int line_error_threshold, int max_distance_point, float radius, float scale, int arc_min_points, int arc_max_distance)
 The constructor for other setting than default setting of detection properties.
void Shape_detect::prepare (const unsigned short laser_scan[])
 TODO.
std::vector< Point > & Shape_detect::getCartes ()
 Returns laser_scan data set by prepare converted to cartesian coordinates.
void Shape_detect::line_detect (std::vector< Line > &lines)
 There are detected line segments in input array of measured data by using perpendicular line regression.
void Shape_detect::arc_detect (std::vector< Arc > &arcs)
 There are detected line segments in input array of measured data.
std::vector< Arc > Shape_detect::arcs_compare (std::vector< Arc > &first, std::vector< Arc > &second, int eps)
 Is uset for comparing of two detected arcs vectors.

Detailed Description

Library shape_detect is used for detection of line segments in data measured by a laser scanner.

Content:

Introduction

The input of the algorithm is represented by array laser_scan (type unsigned short) which contains data expressed in polar coordinates. The first step is data conversion from polar coordinates to vector whose points are expressed in cartesian coordinates. The section includes filtering of errors in the scanned data which are represented by values lower then 20.

In the next is divided pointvector in dependence on parameter max_distance_point. Some line segment is searched by recursion in the individual parts of pointvector by perpendicular line regression. The line segment is detected or set is divided to achievement of parametersize line_min_points.

The founded line is written into output vector lines. The method line_detect is finished after research of all vectorparts.

Debugging

The debug mode permits detection of segment lines with connected laser scanner or from scanned data, which are saved in a file. There is a program shape_detect_offline, which takes the measured data (generated for example by hokuyo-dump command) and writes out the detected lines. It can also plot the results using gnuplot (-g option).

Example

In the file main.cc are introduced examples of using class Shape_detect. The first step is creation of classinstance by constructor calling (default setting for Hokuyo or with applicable parameters). After that it is possible preparation of output vector for saving founded segment line and calling method shape_detect with applicable parameters.

The first example is work illustration with connected laser scanner Hokuyo.

#include <shape_detect.h>
#include <roboorte_robottype.h>

void rcv_hokuyo_scan_cb(const ORTERecvInfo *info, void *vinstance,
                        void *recvCallBackParam)
{
        Shape_detect sd;

        struct hokuyo_scan_type *instance = (struct hokuyo_scan_type *)vinstance;
        static int count = 0;

        switch (info->status) {
                case NEW_DATA: {
                        printf("Scan\n");
                        if (++count >= 2) {
                                printf("Detect\n");
                                count = 0;
                                
                                std::vector<Shape_detect::Line> output;
                                sd.prepare(instance->data);
                                sd.line_detect(output);
                        }
                        break;
                }
                case DEADLINE:
                        printf("Deadline\n");
                        break;
        }
}

struct robottype_orte_data orte;

int robot_init_orte()
{
        int rv = 0;

        rv = robottype_roboorte_init(&orte);
        if (rv) return rv;

        robottype_subscriber_hokuyo_scan_create(&orte, rcv_hokuyo_scan_cb, &orte);
        return rv;
}

int main()
{
        robot_init_orte();
        return 0;
}

References

Fast line, arc/circle and leg detection from laser scan data in a Player driver, http://w3.ualg.pt/~dcastro/a1738.pdf

Mathpages, Perpendicular regression of a line, http://mathpages.com/home/kmath110.htm


Function Documentation

void Shape_detect::arc_detect ( std::vector< Arc > &  arcs  )  [inherited]

There are detected line segments in input array of measured data.

Parameters:
[out] &arcs vector which contains detected arcs.

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< Shape_detect::Arc > Shape_detect::arcs_compare ( std::vector< Arc > &  first,
std::vector< Arc > &  second,
int  eps 
) [inherited]

Is uset for comparing of two detected arcs vectors.

Parameters:
&first is vector for comparing.
&second is vector for comparing.
eps is pertubation measured center of arc.
Returns:
vector equality center of arc.

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< Shape_detect::Point > & Shape_detect::getCartes (  )  [inherited]

Returns laser_scan data set by prepare converted to cartesian coordinates.

Here is the caller graph for this function:

void Shape_detect::line_detect ( std::vector< Line > &  lines  )  [inherited]

There are detected line segments in input array of measured data by using perpendicular line regression.

Parameters:
[out] &lines vector which contains detected lines.

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

There are detected line segments in input file (laser scan data).

Parameters:
argv name input file with measured data

Here is the call graph for this function:

void Shape_detect::prepare ( const unsigned short  laser_scan[]  )  [inherited]

TODO.

Parameters:
[in] laser_scan contains laser scanned data.

Here is the caller graph for this function:

Shape_detect::Shape_detect ( int  line_min_points,
int  line_error_threshold,
int  max_distance_point,
float  radius,
float  scale,
int  arc_min_points,
int  arc_max_distance 
) [inherited]

The constructor for other setting than default setting of detection properties.

Parameters:
line_min_points the minimal number of points which can create segment line.
line_error_threshold the maximal pointerror from segment line of regression.
max_distance_point the maximal Euclidean distance of point.
radius the radius detected arc.
scale is precision detected center of arc.
arc_min_points the minimal number of points which can create arc.
arc_max_distance the maximal distance detected arc from origin coordinates [0; 0]
Shape_detect::Shape_detect ( void   )  [inherited]

The constructor with default setting of detection properties (for Hokuyo).

Line_min_points = 7 Line_error_threshold = 20 Max_distance_point = 300 Radius = 100 Scale = 10 Arc_min_points = 10 Arc_max_distance = 1000