Repository: opencv
Issue: Add Line(Line Segment and LineRay)
Labels: priority: low,RFC

##### Detailed description
OpenCV has a lot of places where, in my opinion, it will be better to use some data structure for Line (line segment or line ray) instead of cv::Vec4 with the description of the index meaning or using two points.

like:

 - fitLine [[link](https://docs.opencv.org/2.4/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=fitline#cv.FitLine)]
> Output line parameters. In case of 2D fitting, it should be a vector of 4 elements (like Vec4f) - (vx, vy, x0, y0), where (vx, vy) is a normalized vector collinear to the line and (x0, y0) is a point on the line. In case of 3D fitting, it should be a vector of 6 elements (like Vec6f) - (vx, vy, vz, x0, y0, z0), where (vx, vy, vz) is a normalized vector collinear to the line and (x0, y0, z0) is a point on the line.

 - clipLine [[link](https://docs.opencv.org/2.4/modules/core/doc/drawing_functions.html?highlight=line#cv.ClipLine)]
> pt1 – First line point.
> pt2 – Second line point.

- houghLines[[link](https://docs.opencv.org/2.4/modules/imgproc/doc/feature_detection.html?highlight=line#houghlines)]
> lines – Output vector of lines. Each line is represented by a two-element vector (\rho, \theta) . \rho is the distance from the coordinate origin (0,0) (top-left corner of the image). \theta is the line rotation angle in radians ( 0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line} ).

- houghLinesP[[link](https://docs.opencv.org/2.4/modules/imgproc/doc/feature_detection.html?highlight=line#houghlines)]
> lines – Output vector of lines. Each line is represented by a 4-element vector (x_1, y_1, x_2, y_2) , where (x_1,y_1) and (x_2, y_2) are the ending points of each detected line segment.

- drawing function cv::line[[link](https://docs.opencv.org/2.4/modules/core/doc/drawing_functions.html?highlight=line#line)]
> pt1 – First point of the line segment.
> pt2 – Second point of the line segment.

- KeyLine [[link](https://docs.opencv.org/3.4/d1/dd7/structcv_1_1line__descriptor_1_1KeyLine.html)]

##### It would be fine to add Structure similar to Point

```
template<typename _Tp> class LineSegment_
{
public:
    typedef _Tp value_type;

    //! default constructor
    LineSegment_();
    LineSegment_(Point_<_Tp> _pt1, Point_<_Tp> _pt2);
    LineSegment_(const LineSegment_& pt);
    LineSegment_(LineSegment_&& pt) CV_NOEXCEPT;

    //! conversion from old-style C structure
    LineSegment_(const Vec<_Tp, 4>& v);

    LineSegment_& operator = (const LineSegment_& pt);
    LineSegment_& operator = (LineSegment_&& pt) CV_NOEXCEPT;

    //! conversion to another data type
    template<typename _Tp2> operator LineSegment_<_Tp2>() const;

    //! conversion to the old-style C structures
    operator Vec<_Tp, 4>() const;

    Point_<_Tp> pt1; //!< First point of the line segment
    Point_<_Tp> pt2; //!< Second point of the line segment
};

typedef LineSegment_<int> LineSegment2i;
typedef LineSegment_<int64> LineSegment2l;
typedef LineSegment_<float> LineSegment2f;
typedef LineSegment_<double> LineSegment2d;
typedef LineSegment2i LineSegment;
```

```
template<typename _Tp1, typename _Tp2> class LineRay_
{
public:
    LineRay_(Point_<_Tp1> _pt, Vec_<_Tp2> _dir);
    ...
    Point_<_Tp1> pt; //!< Point on the line ray
    Vec_<_Tp2> dir; //!< Direction of line ray(normalized may be)
};
```

Is it good idea to create This structure?
Which version use for start branch?
- OpenCV version => 2.4 :grey_question:

Redundacy Checked at:
   * OpenCV documentation: https://docs.opencv.org ✔️ No redundacy found ✔️
   * FAQ page: https://github.com/opencv/opencv/wiki/FAQ ✔️
   * OpenCV forum: https://answers.opencv.org✔️
   * OpenCV issue tracker: https://github.com/opencv/opencv/issues?q=is%3Aissue ✔️
   * Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv ✔️