本文整理匯總了C++中CBlob::GetConvexHull方法的典型用法代碼示例。如果您正苦於以下問題:C++ CBlob::GetConvexHull方法的具體用法?C++ CBlob::GetConvexHull怎麽用?C++ CBlob::GetConvexHull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CBlob
的用法示例。
在下文中一共展示了CBlob::GetConvexHull方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: operator
double CBlobGetHullArea::operator()(CBlob &blob)
{
t_contours convexHull;
blob.GetConvexHull(convexHull);
double area;
if( convexHull.size()==0 )
area = fabs(contourArea(convexHull[0],true));
else
return 0;
return area;
}
示例2: operator
double CBlobGetHullArea::operator()(CBlob &blob)
{
CvSeq *convexHull;
double area;
convexHull = blob.GetConvexHull();
if( convexHull )
area = fabs(cvContourArea(convexHull));
else
return 0;
cvClearSeq(convexHull);
return area;
}
示例3: cvCloneImage
/*
* thread for displaying the opencv content
*/
void *cv_threadfunc (void *ptr) {
IplImage* timg = cvCloneImage(rgbimg); // Image we do our processing on
IplImage* dimg = cvCloneImage(rgbimg); // Image we draw on
CvSize sz = cvSize( timg->width & -2, timg->height & -2);
IplImage* outimg = cvCreateImage(sz, 8, 3);
CvMemStorage* storage = cvCreateMemStorage(0);
CvSeq* squares; // Sequence for squares - sets of 4 points
CvSeq* contours; // Raw contours list
CvSeq* result; // Single contour being processed
CBlobResult blobs;
CBlob *currentBlob;
IplImage *pyr = cvCreateImage(cvSize(sz.width/2, sz.height/2), 8, 1);
// Set region of interest
cvSetImageROI(timg, cvRect(0, 0, sz.width, sz.height));
cvSetImageROI(dimg, cvRect(0, 0, sz.width, sz.height));
// Processing and contours
while (1) {
squares = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvPoint), storage);
pthread_mutex_lock( &mutex_rgb );
cvCopy(rgbimg, dimg, 0);
cvCopy(rgbimg, timg, 0);
pthread_mutex_unlock( &mutex_rgb );
// BLUR TEST
// cvPyrDown(dimg, pyr, 7);
// cvPyrUp(pyr, timg, 7);
// DILATE TEST
IplConvKernel* element = cvCreateStructuringElementEx(5, 5, 2, 2, 0);
IplConvKernel* element2 = cvCreateStructuringElementEx(3, 3, 1, 1, 0);
cvDilate(timg, timg, element, 2);
cvErode(timg, timg, element2, 3);
// THRESHOLD TEST
cvThreshold(timg, timg, 200, 255, CV_THRESH_BINARY);
// Output processed or raw image.
cvCvtColor(timg, outimg, CV_GRAY2BGR);
// BLOB TEST
blobs = CBlobResult( timg, (IplImage*)NULL, 0, true );
// blobs.Filter( blobs, B_EXCLUDE, CBlobGetArea(), B_LESS, 50 );
printf("Blobs: %d\n", blobs.GetNumBlobs());
CBlob biggestBlob;
blobs.GetNthBlob( CBlobGetArea(), 1, biggestBlob );
biggestBlob.FillBlob( outimg, CV_RGB(255, 0, 0) );
CvSeq* dest;
biggestBlob.GetConvexHull(dest);
// for (int i = 0; i < blobs.GetNumBlobs(); i++ )
// {
// currentBlob = blobs.GetBlob(i);
// currentBlob->FillBlob( outimg, CV_RGB(255,0,0) );
// }
// // CONTOUR FINDING
// cvFindContours(timg, storage, &contours, sizeof(CvContour), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0));
//
// while (contours)
// {
// // Approximate contour, accuracy proportional to perimeter of contour; may want to tune accuracy.
// result = cvApproxPoly(contours, sizeof(CvContour), storage, CV_POLY_APPROX_DP, cvContourPerimeter(contours) * 0.02, 0);
// // Filter small contours and contours w/o 4 vertices (filters noise, finds rectangles)
// if (result->total == 4 &&
// fabs(cvContourArea(result, CV_WHOLE_SEQ)) > 600 &&
// cvCheckContourConvexity(result))
// {
// // Skipped checking whether angles were close to 90 degrees here; may want to implement.
// // Probably also want to check if it's square enough to filter out ex. long windows.
//
// for (int i = 0; i < 4; i++)
// {
// // Write vertices to output sequence
// cvSeqPush(squares, (CvPoint*)cvGetSeqElem(result, i));
// }
// }
//
// // Take next contour
// contours = contours->h_next;
// }
//
//
// // DRAW RECTANGLES
// CvSeqReader reader;
// cvStartReadSeq(squares, &reader, 0);
//
// // Read 4 points at a time
// CvPoint pt[4];
//.........這裏部分代碼省略.........