26 vector<Point2f> vert(6);
28 vert[0] =
Point( 3*r/2, static_cast<int>(1.34*r) );
29 vert[1] =
Point( 1*r, 2*r );
30 vert[2] =
Point( 3*r/2, static_cast<int>(2.866*r) );
31 vert[3] =
Point( 5*r/2, static_cast<int>(2.866*r) );
32 vert[4] =
Point( 3*r, 2*r );
33 vert[5] =
Point( 5*r/2, static_cast<int>(1.34*r) );
36 for(
int j = 0; j < 6; j++ )
37 {
line( src, vert[j], vert[(j+1)%6],
Scalar( 255 ), 3, 8 ); }
40 vector<vector<Point> > contours; vector<Vec4i> hierarchy;
48 for(
int j = 0; j < src.
rows; j++ )
49 {
for(
int i = 0; i < src.
cols; i++ )
53 double minVal;
double maxVal;
55 minVal = abs(minVal); maxVal = abs(maxVal);
58 Mat drawing = Mat::zeros( src.size(),
CV_8UC3 );
60 for(
int j = 0; j < src.rows; j++ )
61 {
for(
int i = 0; i < src.
cols; i++ )
63 if( raw_dist.at<
float>(j,i) < 0 )
64 { drawing.
at<
Vec3b>(j,
i)[0] = (
uchar)(255 -
abs(raw_dist.at<
float>(j,i))*255/minVal); }
65 else if( raw_dist.at<
float>(j,i) > 0 )
66 { drawing.
at<
Vec3b>(j,
i)[2] = (
uchar)(255 - raw_dist.at<
float>(j,
i)*255/maxVal); }
73 const char* source_window =
"Source";
75 imshow( source_window, src );
77 imshow(
"Distance", drawing );
Scalar_< double > Scalar
Definition: types.hpp:597
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.
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions ...
Definition: mat.hpp:1865
static MatExpr zeros(int rows, int cols, int type)
Returns a zero array of the specified size and type.
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
#define CV_8UC1
Definition: cvdef.h:116
Definition: imgproc.hpp:409
Template class for short numerical vectors, a partial case of Matx.
Definition: matx.hpp:300
int cols
Definition: mat.hpp:1865
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.
Mat clone() const
Creates a full copy of the array and the underlying data.
MatSize size
Definition: mat.hpp:1882
unsigned char uchar
Definition: defs.h:284
void namedWindow(const String &winname, int flags=WINDOW_AUTOSIZE)
Creates a window.
Size2i Size
Definition: types.hpp:308
for i
Definition: modelConvert.m:63
#define CV_32FC1
Definition: cvdef.h:146
#define CV_8UC3
Definition: cvdef.h:118
Definition: imgproc.hpp:421
Definition: highgui.hpp:138
T abs(T x)
Definition: dist.h:58
double pointPolygonTest(InputArray contour, Point2f pt, bool measureDist)
Performs a point-in-contour test.
void findContours(InputOutputArray image, OutputArrayOfArrays contours, OutputArray hierarchy, int mode, int method, Point offset=Point())
Finds contours in a binary image.
int main(int argc, const char *argv[])
Definition: facerec_demo.cpp:67
n-dimensional dense array class
Definition: mat.hpp:726
_Tp & at(int i0=0)
Returns a reference to the specified array element.
Point2i Point
Definition: types.hpp:181
int waitKey(int delay=0)
Waits for a pressed key.