OpenCV  4.5.2
Open Source Computer Vision
Point Polygon Test

Table of Contents

Prev Tutorial: Image Moments
Next Tutorial: Image Segmentation with Distance Transform and Watershed Algorithm

Original author Ana Huamán
Compatibility OpenCV >= 3.0

Goal

In this tutorial you will learn how to:

Theory

Code

Explanation

Result

Here it is:

cv::Mat::rows
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions
Definition: mat.hpp:2096
cv::String
std::string String
Definition: cvstd.hpp:150
cv::Point_< int >
cv::Mat::zeros
static MatExpr zeros(int rows, int cols, int type)
Returns a zero array of the specified size and type.
cv::Mat::at
_Tp & at(int i0=0)
Returns a reference to the specified array element.
cv::Point2f
Point_< float > Point2f
Definition: types.hpp:192
cv::MatExpr::abs
MatExpr abs(const Mat &m)
Calculates an absolute value of each matrix element.
cv::waitKey
int waitKey(int delay=0)
Waits for a pressed key.
CV_8U
#define CV_8U
Definition: interface.h:73
highgui.hpp
cv::findContours
void findContours(InputArray image, OutputArrayOfArrays contours, OutputArray hierarchy, int mode, int method, Point offset=Point())
Finds contours in a binary image.
cv::Size
Size2i Size
Definition: types.hpp:347
cv::line
void line(InputOutputArray img, Point pt1, Point pt2, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
Draws a line segment connecting two points.
CV_32F
#define CV_32F
Definition: interface.h:78
cv::Vec
Template class for short numerical vectors, a partial case of Matx.
Definition: matx.hpp:341
cv::Mat::cols
int cols
Definition: mat.hpp:2096
CV_8UC3
#define CV_8UC3
Definition: interface.h:90
cv::Mat::size
MatSize size
Definition: mat.hpp:2118
cv::abs
static uchar abs(uchar a)
Definition: cvstd.hpp:66
cv::findContours
void findContours(InputArray image, OutputArrayOfArrays contours, int mode, int method, Point offset=Point())
uchar
unsigned char uchar
Definition: interface.h:51
cv::imshow
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
cv::minMaxLoc
void minMaxLoc(InputArray src, double *minVal, double *maxVal=0, Point *minLoc=0, Point *maxLoc=0, InputArray mask=noArray())
Finds the global minimum and maximum in an array.
cv::minMaxLoc
void minMaxLoc(const SparseMat &a, double *minVal, double *maxVal, int *minIdx=0, int *maxIdx=0)
cv::Scalar
Scalar_< double > Scalar
Definition: types.hpp:669
cv::Point
Point2i Point
Definition: types.hpp:194
cv::Mat
n-dimensional dense array class
Definition: mat.hpp:801
cv::imshow
void imshow(const String &winname, const ogl::Texture2D &tex)
Displays OpenGL 2D texture in the specified window.
cv
"black box" representation of the file storage associated with a file on disk.
Definition: affine.hpp:51
imgproc.hpp
cv::CHAIN_APPROX_SIMPLE
@ CHAIN_APPROX_SIMPLE
Definition: imgproc.hpp:442
cv::pointPolygonTest
double pointPolygonTest(InputArray contour, Point2f pt, bool measureDist)
Performs a point-in-contour test.
cv::RETR_TREE
@ RETR_TREE
Definition: imgproc.hpp:430
cv::circle
void circle(InputOutputArray img, Point center, int radius, const Scalar &color, int thickness=1, int lineType=LINE_8, int shift=0)
Draws a circle.