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

Function cvMinAreaRect2

deps/opencv/modules/imgproc/src/rotcalipers.cpp:351–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349
350
351CV_IMPL CvBox2D
352cvMinAreaRect2( const CvArr* array, CvMemStorage* storage )
353{
354 cv::Ptr<CvMemStorage> temp_storage;
355 CvBox2D box;
356 cv::AutoBuffer<CvPoint2D32f> _points;
357 CvPoint2D32f* points;
358
359 memset(&box, 0, sizeof(box));
360
361 int i, n;
362 CvSeqReader reader;
363 CvContour contour_header;
364 CvSeqBlock block;
365 CvSeq* ptseq = (CvSeq*)array;
366 CvPoint2D32f out[3];
367
368 if( CV_IS_SEQ(ptseq) )
369 {
370 if( !CV_IS_SEQ_POINT_SET(ptseq) &&
371 (CV_SEQ_KIND(ptseq) != CV_SEQ_KIND_CURVE ||
372 CV_SEQ_ELTYPE(ptseq) != CV_SEQ_ELTYPE_PPOINT ))
373 CV_Error( CV_StsUnsupportedFormat,
374 "Input sequence must consist of 2d points or pointers to 2d points" );
375 if( !storage )
376 storage = ptseq->storage;
377 }
378 else
379 {
380 ptseq = cvPointSeqFromMat( CV_SEQ_KIND_GENERIC, array, &contour_header, &block );
381 }
382
383 if( storage )
384 {
385 temp_storage = cvCreateChildMemStorage( storage );
386 }
387 else
388 {
389 temp_storage = cvCreateMemStorage(1 << 10);
390 }
391
392 ptseq = cvConvexHull2( ptseq, temp_storage, CV_CLOCKWISE, 1 );
393 n = ptseq->total;
394
395 _points.allocate(n);
396 points = _points;
397 cvStartReadSeq( ptseq, &reader );
398
399 if( CV_SEQ_ELTYPE( ptseq ) == CV_32SC2 )
400 {
401 for( i = 0; i < n; i++ )
402 {
403 CvPoint pt;
404 CV_READ_SEQ_ELEM( pt, reader );
405 points[i].x = (float)pt.x;
406 points[i].y = (float)pt.y;
407 }
408 }

Callers 1

minAreaRectMethod · 0.85

Calls 6

cvPointSeqFromMatFunction · 0.85
cvConvexHull2Function · 0.85
cvStartReadSeqFunction · 0.85
icvRotatingCalipersFunction · 0.85
sqrtFunction · 0.85
allocateMethod · 0.45

Tested by

no test coverage detected