adding markers to OpenCV for 2.4 branch
This commit is contained in:
@@ -1797,6 +1797,73 @@ void ellipse(Mat& img, const RotatedRect& box, const Scalar& color,
|
||||
EllipseEx( img, center, axes, _angle, 0, 360, buf, thickness, lineType );
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------------------- */
|
||||
/* ADDING A SET OF PREDEFINED MARKERS WHICH COULD BE USED TO HIGHLIGHT POSITIONS IN AN IMAGE */
|
||||
/* ----------------------------------------------------------------------------------------- */
|
||||
|
||||
void drawMarker(Mat& img, Point position, const Scalar& color, int markerType, int markerSize, int thickness, int line_type)
|
||||
{
|
||||
switch(markerType)
|
||||
{
|
||||
// The cross marker case
|
||||
case MARKER_CROSS:
|
||||
line(img, Point(position.x-(markerSize/2), position.y), Point(position.x+(markerSize/2), position.y), color, thickness, line_type);
|
||||
line(img, Point(position.x, position.y-(markerSize/2)), Point(position.x, position.y+(markerSize/2)), color, thickness, line_type);
|
||||
break;
|
||||
|
||||
// The tilted cross marker case
|
||||
case MARKER_TILTED_CROSS:
|
||||
line(img, Point(position.x-(markerSize/2), position.y-(markerSize/2)), Point(position.x+(markerSize/2), position.y+(markerSize/2)), color, thickness, line_type);
|
||||
line(img, Point(position.x+(markerSize/2), position.y-(markerSize/2)), Point(position.x-(markerSize/2), position.y+(markerSize/2)), color, thickness, line_type);
|
||||
break;
|
||||
|
||||
// The star marker case
|
||||
case MARKER_STAR:
|
||||
line(img, Point(position.x-(markerSize/2), position.y), Point(position.x+(markerSize/2), position.y), color, thickness, line_type);
|
||||
line(img, Point(position.x, position.y-(markerSize/2)), Point(position.x, position.y+(markerSize/2)), color, thickness, line_type);
|
||||
line(img, Point(position.x-(markerSize/2), position.y-(markerSize/2)), Point(position.x+(markerSize/2), position.y+(markerSize/2)), color, thickness, line_type);
|
||||
line(img, Point(position.x+(markerSize/2), position.y-(markerSize/2)), Point(position.x-(markerSize/2), position.y+(markerSize/2)), color, thickness, line_type);
|
||||
break;
|
||||
|
||||
// The diamond marker case
|
||||
case MARKER_DIAMOND:
|
||||
line(img, Point(position.x, position.y-(markerSize/2)), Point(position.x+(markerSize/2), position.y), color, thickness, line_type);
|
||||
line(img, Point(position.x+(markerSize/2), position.y), Point(position.x, position.y+(markerSize/2)), color, thickness, line_type);
|
||||
line(img, Point(position.x, position.y+(markerSize/2)), Point(position.x-(markerSize/2), position.y), color, thickness, line_type);
|
||||
line(img, Point(position.x-(markerSize/2), position.y), Point(position.x, position.y-(markerSize/2)), color, thickness, line_type);
|
||||
break;
|
||||
|
||||
// The square marker case
|
||||
case MARKER_SQUARE:
|
||||
line(img, Point(position.x-(markerSize/2), position.y-(markerSize/2)), Point(position.x+(markerSize/2), position.y-(markerSize/2)), color, thickness, line_type);
|
||||
line(img, Point(position.x+(markerSize/2), position.y-(markerSize/2)), Point(position.x+(markerSize/2), position.y+(markerSize/2)), color, thickness, line_type);
|
||||
line(img, Point(position.x+(markerSize/2), position.y+(markerSize/2)), Point(position.x-(markerSize/2), position.y+(markerSize/2)), color, thickness, line_type);
|
||||
line(img, Point(position.x-(markerSize/2), position.y+(markerSize/2)), Point(position.x-(markerSize/2), position.y-(markerSize/2)), color, thickness, line_type);
|
||||
break;
|
||||
|
||||
// The triangle up marker case
|
||||
case MARKER_TRIANGLE_UP:
|
||||
line(img, Point(position.x-(markerSize/2), position.y+(markerSize/2)), Point(position.x+(markerSize/2), position.y+(markerSize/2)), color, thickness, line_type);
|
||||
line(img, Point(position.x+(markerSize/2), position.y+(markerSize/2)), Point(position.x, position.y-(markerSize/2)), color, thickness, line_type);
|
||||
line(img, Point(position.x, position.y-(markerSize/2)), Point(position.x-(markerSize/2), position.y-(markerSize/2)), color, thickness, line_type);
|
||||
break;
|
||||
|
||||
// The triangle down marker case
|
||||
case MARKER_TRIANGLE_DOWN:
|
||||
line(img, Point(position.x-(markerSize/2), position.y-(markerSize/2)), Point(position.x+(markerSize/2), position.y-(markerSize/2)), color, thickness, line_type);
|
||||
line(img, Point(position.x+(markerSize/2), position.y-(markerSize/2)), Point(position.x, position.y+(markerSize/2)), color, thickness, line_type);
|
||||
line(img, Point(position.x, position.y+(markerSize/2)), Point(position.x-(markerSize/2), position.y-(markerSize/2)), color, thickness, line_type);
|
||||
break;
|
||||
|
||||
// If any number that doesn't exist is entered, draw a cross marker
|
||||
default:
|
||||
drawMarker(img, position, color, MARKER_CROSS, markerSize, thickness, line_type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------------------- */
|
||||
|
||||
void fillConvexPoly( Mat& img, const Point* pts, int npts,
|
||||
const Scalar& color, int line_type, int shift )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user