MCPcopy Create free account
hub / github.com/creatale/node-dv / CollectPolyEdges

Function CollectPolyEdges

deps/opencv/modules/core/src/drawing.cpp:1238–1291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1236/******** Arbitrary polygon **********/
1237
1238static void
1239CollectPolyEdges( Mat& img, const Point2l* v, int count, vector<PolyEdge>& edges,
1240 const void* color, int line_type, int shift, Point offset )
1241{
1242 int i, delta = offset.y + ((1 << shift) >> 1);
1243 Point2l pt0 = v[count-1], pt1;
1244 pt0.x = (pt0.x + offset.x) << (XY_SHIFT - shift);
1245 pt0.y = (pt0.y + delta) >> shift;
1246
1247 edges.reserve( edges.size() + count );
1248
1249 for( i = 0; i < count; i++, pt0 = pt1 )
1250 {
1251 Point2l t0, t1;
1252 PolyEdge edge;
1253
1254 pt1 = v[i];
1255 pt1.x = (pt1.x + offset.x) << (XY_SHIFT - shift);
1256 pt1.y = (pt1.y + delta) >> shift;
1257
1258 if( line_type < CV_AA )
1259 {
1260 t0.y = pt0.y; t1.y = pt1.y;
1261 t0.x = (pt0.x + (XY_ONE >> 1)) >> XY_SHIFT;
1262 t1.x = (pt1.x + (XY_ONE >> 1)) >> XY_SHIFT;
1263 Line( img, Point((int)(t0.x), (int)(t0.y)), Point((int)(t1.x), (int)(t1.y)), color, line_type );
1264 }
1265 else
1266 {
1267 t0.x = pt0.x; t1.x = pt1.x;
1268 t0.y = pt0.y << XY_SHIFT;
1269 t1.y = pt1.y << XY_SHIFT;
1270 LineAA( img, t0, t1, color );
1271 }
1272
1273 if( pt0.y == pt1.y )
1274 continue;
1275
1276 if( pt0.y < pt1.y )
1277 {
1278 edge.y0 = (int)(pt0.y);
1279 edge.y1 = (int)(pt1.y);
1280 edge.x = pt0.x;
1281 }
1282 else
1283 {
1284 edge.y0 = (int)(pt1.y);
1285 edge.y1 = (int)(pt0.y);
1286 edge.x = pt1.x;
1287 }
1288 edge.dx = (pt1.x - pt0.x) / (pt1.y - pt0.y);
1289 edges.push_back(edge);
1290 }
1291}
1292
1293struct CmpEdges
1294{

Callers 3

EllipseExFunction · 0.85
fillPolyFunction · 0.85
cvDrawContoursFunction · 0.85

Calls 6

LineAAFunction · 0.85
LineFunction · 0.70
PointClass · 0.50
reserveMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected