12 double r = sqrtf(3) * 0.5 * R;
19 if (img.channels() == 1) cvtColor(img, img, CV_GRAY2RGB);
22 for (y = 0; Y < img.rows; y++) {
23 if (y % 2 == 0) X0 = r;
26 for (x = 0; X < img.cols; x++) {
31 line(img, Point2d(X, Y - R), Point2d(X + r, Y - (R / 2)), color, 1, CV_AA);
32 line(img, Point2d(X + r, Y - (R / 2)), Point2d(X + r, Y + (R / 2)), color, 1, CV_AA);
33 line(img, Point2d(X, Y + R), Point2d(X + r, Y + (R / 2)), color, 1, CV_AA);
36 rectangle(img, Point(0, 0), Point(img.cols - 1, img.rows - 1), color, 1);
45 CvPoint2D64f C = CCell::idx2d(idx, R, img.size());
47 for (
int i = 0; i < 6; i++) {
48 CvPoint2D64f c = CCell::getBoundaryPoint(C, i, R);
49 ic[i].x =
static_cast<int>(0.5 + c.x);
50 ic[i].y =
static_cast<int>(0.5 + c.y);
53 const Point * countours[1] = { &ic[0] };
55 fillPoly(img, countours, npt, 1, color);
void markGrid(Mat &img, double R, CvScalar color)
Draws the hexagonical grid on the image.
void markHexagon(Mat &img, double R, int idx, CvScalar color)
Draws a single filled hexagon.