| 1857 | /* ----------------------------------------------------------------------------------------- */ |
| 1858 | |
| 1859 | void drawMarker(Mat& img, Point position, const Scalar& color, int markerType, int markerSize, int thickness, int line_type) |
| 1860 | { |
| 1861 | switch(markerType) |
| 1862 | { |
| 1863 | // The cross marker case |
| 1864 | case MARKER_CROSS: |
| 1865 | line(img, Point(position.x-(markerSize/2), position.y), Point(position.x+(markerSize/2), position.y), color, thickness, line_type); |
| 1866 | line(img, Point(position.x, position.y-(markerSize/2)), Point(position.x, position.y+(markerSize/2)), color, thickness, line_type); |
| 1867 | break; |
| 1868 | |
| 1869 | // The tilted cross marker case |
| 1870 | case MARKER_TILTED_CROSS: |
| 1871 | line(img, Point(position.x-(markerSize/2), position.y-(markerSize/2)), Point(position.x+(markerSize/2), position.y+(markerSize/2)), color, thickness, line_type); |
| 1872 | line(img, Point(position.x+(markerSize/2), position.y-(markerSize/2)), Point(position.x-(markerSize/2), position.y+(markerSize/2)), color, thickness, line_type); |
| 1873 | break; |
| 1874 | |
| 1875 | // The star marker case |
| 1876 | case MARKER_STAR: |
| 1877 | line(img, Point(position.x-(markerSize/2), position.y), Point(position.x+(markerSize/2), position.y), color, thickness, line_type); |
| 1878 | line(img, Point(position.x, position.y-(markerSize/2)), Point(position.x, position.y+(markerSize/2)), color, thickness, line_type); |
| 1879 | line(img, Point(position.x-(markerSize/2), position.y-(markerSize/2)), Point(position.x+(markerSize/2), position.y+(markerSize/2)), color, thickness, line_type); |
| 1880 | line(img, Point(position.x+(markerSize/2), position.y-(markerSize/2)), Point(position.x-(markerSize/2), position.y+(markerSize/2)), color, thickness, line_type); |
| 1881 | break; |
| 1882 | |
| 1883 | // The diamond marker case |
| 1884 | case MARKER_DIAMOND: |
| 1885 | line(img, Point(position.x, position.y-(markerSize/2)), Point(position.x+(markerSize/2), position.y), color, thickness, line_type); |
| 1886 | line(img, Point(position.x+(markerSize/2), position.y), Point(position.x, position.y+(markerSize/2)), color, thickness, line_type); |
| 1887 | line(img, Point(position.x, position.y+(markerSize/2)), Point(position.x-(markerSize/2), position.y), color, thickness, line_type); |
| 1888 | line(img, Point(position.x-(markerSize/2), position.y), Point(position.x, position.y-(markerSize/2)), color, thickness, line_type); |
| 1889 | break; |
| 1890 | |
| 1891 | // The square marker case |
| 1892 | case MARKER_SQUARE: |
| 1893 | line(img, Point(position.x-(markerSize/2), position.y-(markerSize/2)), Point(position.x+(markerSize/2), position.y-(markerSize/2)), color, thickness, line_type); |
| 1894 | line(img, Point(position.x+(markerSize/2), position.y-(markerSize/2)), Point(position.x+(markerSize/2), position.y+(markerSize/2)), color, thickness, line_type); |
| 1895 | line(img, Point(position.x+(markerSize/2), position.y+(markerSize/2)), Point(position.x-(markerSize/2), position.y+(markerSize/2)), color, thickness, line_type); |
| 1896 | line(img, Point(position.x-(markerSize/2), position.y+(markerSize/2)), Point(position.x-(markerSize/2), position.y-(markerSize/2)), color, thickness, line_type); |
| 1897 | break; |
| 1898 | |
| 1899 | // The triangle up marker case |
| 1900 | case MARKER_TRIANGLE_UP: |
| 1901 | line(img, Point(position.x-(markerSize/2), position.y+(markerSize/2)), Point(position.x+(markerSize/2), position.y+(markerSize/2)), color, thickness, line_type); |
| 1902 | line(img, Point(position.x+(markerSize/2), position.y+(markerSize/2)), Point(position.x, position.y-(markerSize/2)), color, thickness, line_type); |
| 1903 | line(img, Point(position.x, position.y-(markerSize/2)), Point(position.x-(markerSize/2), position.y+(markerSize/2)), color, thickness, line_type); |
| 1904 | break; |
| 1905 | |
| 1906 | // The triangle down marker case |
| 1907 | case MARKER_TRIANGLE_DOWN: |
| 1908 | line(img, Point(position.x-(markerSize/2), position.y-(markerSize/2)), Point(position.x+(markerSize/2), position.y-(markerSize/2)), color, thickness, line_type); |
| 1909 | line(img, Point(position.x+(markerSize/2), position.y-(markerSize/2)), Point(position.x, position.y+(markerSize/2)), color, thickness, line_type); |
| 1910 | line(img, Point(position.x, position.y+(markerSize/2)), Point(position.x-(markerSize/2), position.y-(markerSize/2)), color, thickness, line_type); |
| 1911 | break; |
| 1912 | |
| 1913 | // If any number that doesn't exist is entered, draw a cross marker |
| 1914 | default: |
| 1915 | drawMarker(img, position, color, MARKER_CROSS, markerSize, thickness, line_type); |
| 1916 | break; |