| 2206 | } |
| 2207 | |
| 2208 | void putText( Mat& img, const string& text, Point org, |
| 2209 | int fontFace, double fontScale, Scalar color, |
| 2210 | int thickness, int line_type, bool bottomLeftOrigin ) |
| 2211 | |
| 2212 | { |
| 2213 | const int* ascii = getFontData(fontFace); |
| 2214 | |
| 2215 | double buf[4]; |
| 2216 | scalarToRawData(color, buf, img.type(), 0); |
| 2217 | |
| 2218 | int base_line = -(ascii[0] & 15); |
| 2219 | int hscale = cvRound(fontScale*XY_ONE), vscale = hscale; |
| 2220 | |
| 2221 | if( line_type == CV_AA && img.depth() != CV_8U ) |
| 2222 | line_type = 8; |
| 2223 | |
| 2224 | if( bottomLeftOrigin ) |
| 2225 | vscale = -vscale; |
| 2226 | |
| 2227 | int64 view_x = (int64)org.x << XY_SHIFT; |
| 2228 | int64 view_y = ((int64)org.y << XY_SHIFT) + base_line*vscale; |
| 2229 | vector<Point2l> pts; |
| 2230 | pts.reserve(1 << 10); |
| 2231 | const char **faces = cv::g_HersheyGlyphs; |
| 2232 | |
| 2233 | for( int i = 0; i < (int)text.size(); i++ ) |
| 2234 | { |
| 2235 | int c = (uchar)text[i]; |
| 2236 | Point2l p; |
| 2237 | |
| 2238 | readCheck(c, i, text, fontFace); |
| 2239 | |
| 2240 | const char* ptr = faces[ascii[(c-' ')+1]]; |
| 2241 | p.x = (uchar)ptr[0] - 'R'; |
| 2242 | p.y = (uchar)ptr[1] - 'R'; |
| 2243 | int64 dx = p.y*hscale; |
| 2244 | view_x -= p.x*hscale; |
| 2245 | pts.resize(0); |
| 2246 | |
| 2247 | for( ptr += 2;; ) |
| 2248 | { |
| 2249 | if( *ptr == ' ' || !*ptr ) |
| 2250 | { |
| 2251 | if( pts.size() > 1 ) |
| 2252 | PolyLine( img, &pts[0], (int)pts.size(), false, buf, thickness, line_type, XY_SHIFT ); |
| 2253 | if( !*ptr++ ) |
| 2254 | break; |
| 2255 | pts.resize(0); |
| 2256 | } |
| 2257 | else |
| 2258 | { |
| 2259 | p.x = (uchar)ptr[0] - 'R'; |
| 2260 | p.y = (uchar)ptr[1] - 'R'; |
| 2261 | ptr += 2; |
| 2262 | pts.push_back(Point2l(p.x*hscale + view_x, p.y*vscale + view_y)); |
| 2263 | } |
| 2264 | } |
| 2265 | view_x += dx; |
no test coverage detected