|
|
|
@ -1654,6 +1654,71 @@ PolyLine( Mat& img, const Point* v, int count, bool is_closed, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------------------------- */ |
|
|
|
|
/* 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 as marker type, draw a cross marker, to avoid crashes
|
|
|
|
|
default: |
|
|
|
|
drawMarker(img, position, color, MARKER_CROSS, markerSize, thickness, line_type); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/****************************************************************************************\
|
|
|
|
|
* External functions * |
|
|
|
|
\****************************************************************************************/ |
|
|
|
|