OpenCV  3.2.0-dev
Open Source Computer Vision
cv::Point_< _Tp > Class Template Reference

Template class for 2D points specified by its coordinates x and y. More...

#include "types.hpp"

Inheritance diagram for cv::Point_< _Tp >:
Collaboration diagram for cv::Point_< _Tp >:

Public Types

typedef _Tp value_type
 

Public Member Functions

 Point_ ()
 
 Point_ (_Tp _x, _Tp _y)
 
 Point_ (const Point_ &pt)
 
 Point_ (const Size_< _Tp > &sz)
 
 Point_ (const Vec< _Tp, 2 > &v)
 
double cross (const Point_ &pt) const
 cross-product More...
 
double ddot (const Point_ &pt) const
 dot product computed in double-precision arithmetics More...
 
_Tp dot (const Point_ &pt) const
 dot product More...
 
bool inside (const Rect_< _Tp > &r) const
 checks whether the point is inside the specified rectangle More...
 
template<typename _Tp2 >
 operator Point_< _Tp2 > () const
 conversion to another data type More...
 
 operator Vec< _Tp, 2 > () const
 conversion to the old-style C structures More...
 
Point_operator= (const Point_ &pt)
 

Public Attributes

_Tp x
 
_Tp y
 

Detailed Description

template<typename _Tp>
class cv::Point_< _Tp >

Template class for 2D points specified by its coordinates x and y.

An instance of the class is interchangeable with C structures, CvPoint and CvPoint2D32f . There is also a cast operator to convert point coordinates to the specified type. The conversion from floating-point coordinates to integer coordinates is done by rounding. Commonly, the conversion uses this operation for each of the coordinates. Besides the class members listed in the declaration above, the following operations on points are implemented:

pt1 = pt2 + pt3;
pt1 = pt2 - pt3;
pt1 = pt2 * a;
pt1 = a * pt2;
pt1 = pt2 / a;
pt1 += pt2;
pt1 -= pt2;
pt1 *= a;
pt1 /= a;
double value = norm(pt); // L2 norm
pt1 == pt2;
pt1 != pt2;

For your convenience, the following type aliases are defined:

typedef Point_<int> Point2i;
typedef Point2i Point;
typedef Point_<float> Point2f;
typedef Point_<double> Point2d;

Example:

Point2f a(0.3f, 0.f), b(0.f, 0.4f);
Point pt = (a + b)*10.f;
cout << pt.x << ", " << pt.y << endl;
Examples:
convexhull.cpp, demhist.cpp, ffilldemo.cpp, grabcut.cpp, kmeans.cpp, minarea.cpp, and watershed.cpp.

Member Typedef Documentation

template<typename _Tp>
typedef _Tp cv::Point_< _Tp >::value_type

Constructor & Destructor Documentation

template<typename _Tp>
cv::Point_< _Tp >::Point_ ( )
template<typename _Tp>
cv::Point_< _Tp >::Point_ ( _Tp  _x,
_Tp  _y 
)
template<typename _Tp>
cv::Point_< _Tp >::Point_ ( const Point_< _Tp > &  pt)
template<typename _Tp>
cv::Point_< _Tp >::Point_ ( const Size_< _Tp > &  sz)
template<typename _Tp>
cv::Point_< _Tp >::Point_ ( const Vec< _Tp, 2 > &  v)

Member Function Documentation

template<typename _Tp>
double cv::Point_< _Tp >::cross ( const Point_< _Tp > &  pt) const

cross-product

template<typename _Tp>
double cv::Point_< _Tp >::ddot ( const Point_< _Tp > &  pt) const

dot product computed in double-precision arithmetics

template<typename _Tp>
_Tp cv::Point_< _Tp >::dot ( const Point_< _Tp > &  pt) const

dot product

template<typename _Tp>
bool cv::Point_< _Tp >::inside ( const Rect_< _Tp > &  r) const

checks whether the point is inside the specified rectangle

template<typename _Tp>
template<typename _Tp2 >
cv::Point_< _Tp >::operator Point_< _Tp2 > ( ) const

conversion to another data type

template<typename _Tp>
cv::Point_< _Tp >::operator Vec< _Tp, 2 > ( ) const

conversion to the old-style C structures

template<typename _Tp>
Point_& cv::Point_< _Tp >::operator= ( const Point_< _Tp > &  pt)

Member Data Documentation


The documentation for this class was generated from the following file: