cv::Point_<_Tp > Class Template Reference
Template class for 2D points specified by its coordinates x and y.
#include "types.hpp
Detailed Description :
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 coordinates. Besides the class member functions, 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;
Member Typedef Documentation :
value_type
typedef _Tp cv::Point<_Tp >::value_type
Constructor & Destructor Documentation :
Point_( ) [1 / 5]
cv::Point_<Tp >::Point( )
default constructor
Point_( ) [2 / 5]
cv::Point_<Tp >::Point(_Tp _x, _Tp _y )
Point_( ) [3 / 5]
cv::Point_<Tp >::Point( const Point_<_Tp > & pt )
Point_( ) [4 / 5]
cv::Point_<Tp >::Point( const Size_<_Tp > & sz )
Point_( ) [5 / 5]
cv::Point_<Tp >::Point( const Vec<_Tp, 2> & v )
Member Function Documentation :
cross( )
double cv::Point_<Tp >::cross( const Point<_Tp > & pt )
用法 : cross - product , 外积 、 向量积 、 叉积 。 |c| = |a| * |b| * sin (夹角)
ddot( )
double cv::Point_<_Tp >::ddot( const Point<_Tp > & pt )
用法 : dot product computed in double-precision arithmetics .
dot( )
Tp cv::Point_<_Tp >::dot( const Point<_Tp > & pt )
用法 : dot product
inside( )
bool cv::Point_<Tp >::inside( const Rect<_Tp > & r )
用法 : checks whether the points is inside the specified rectangle .
operator Point_<Tp2 >( )
cv::Point<Tp >::operator Point<_Tp2 >( )
用法 : conversion to another data type .
operator Vec<Tp , 2>( )
cv::Point<_Tp >::operator Vec<_Tp, 2>( )
用法 : conversion to the old-style C structures .
operator = ( )
Point_&cv::Point_<Tp >::operator = ( const Point<_Tp > & pt )
Member Data Documentation :
x
_Tp cv::Point<_Tp >::x
return x coordinate of the point .
y
_Tp cv::Point<_Tp >::y
return y coordinate of y
The documentation for this class was generated from the following file :
core/include/opencv2/core/types.hpp
Code :
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Point pt1;
Point pt2(2, 2);
Point pt3(3, 3);
int n = 2;
// 加减乘除 四则运算
pt1 = pt2 + pt3;
cout << "pt1 = " << pt1 << endl;
pt1 = pt2 - pt3;
cout << "pt1 = " << pt1 << endl;
pt1 = pt2 * n;
cout << "pt1 = " << pt1 << endl;
pt1 = pt2 / n;
cout << "pt1 = " << pt1 << endl;
//Example
Point2f a(0.3f, 0.f), b(0.f, 0.4f);
Point pt = (a + b) * 10.f;
cout << pt.x << ", " << pt.y << endl;
//Member Function
//cross 向量积 |a| * |b| * sin(夹角)
double cross_product = pt2.cross(pt3);
cout << "cross_product = " << cross_product << endl;
//ddot 以双浮点数精度 内积,点积,数量积
double double_dot_product = pt2.ddot(pt3);
cout << "double_dot_product = " << double_dot_product << endl;
//dot 点积 - dot product
int dot_product = pt2.dot(pt3);
cout << "dot_product = " << dot_product << endl;
//inside - checks whether the point inside the specified rectangle
Rect rect(1, 1, 4, 4);
if (pt2.inside(rect))
cout << "the point pt2 is inside the rect rectangle !" << endl;
//Member Data Documentation
int x = pt2.x;
int y = pt2.y;
cout << "x = " << x << endl;
cout << "y = " << y << endl;
system("pause");
return 0;
}