本文整理汇总了C++中CBlob::getCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ CBlob::getCenter方法的具体用法?C++ CBlob::getCenter怎么用?C++ CBlob::getCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBlob
的用法示例。
在下文中一共展示了CBlob::getCenter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: blobDetect
void PSTouch::blobDetect(cv::Mat& image){
CBlobResult res(image,cv::Mat(),NUMCORES);
std::vector<TouchEvent> events;
qRegisterMetaType<std::vector<TouchEvent > >("std::vector<TouchEvent>");
for (unsigned int i = 0; i<res.GetNumBlobs(); i++){
CBlob blob = res.GetBlob(i);
if(blob.Area()<3) {
continue;
}
cv::Point point = blob.getCenter();
cv::Point3f camPoint(point.x,point.y,groundTruth->at<openni::DepthPixel>(point.y,point.x));
cv::Point2i p = transform->transformPointfromCamToProjector(camPoint);
if(p.x < 1200 && p.y < 700 && p.x>0 && p.y >0){
TouchEvent event(p,camPoint);
events.push_back(event);
}
}
if(events.size() >10){
qDebug("RECALIBRATE");
calibrateTouch();
}
emit updateEvents(events);
//Timing
timerCount++;
//qDebug()<<"Timer: "<< timerCount;
if(timerCount==60){
timerCount=0;
int x = timer.restart();
float fps = 50.0/((float)x/1000.0);
qDebug() << " working with: " << fps << "fps " << x;
timer.restart();
}
}
示例2: main
//.........这里部分代码省略.........
CBlob* rightBlob;
CBlob* robotBlob;
copy.setTo(Vec3b(0,0,0));
// chooses the two largest blobs for the hands
Point center_1, center_2;
int max_1 = 0;
int max_2 = 0;
int maxArea_1 = 0;
int maxArea_2 = 0;
for(int i=0;i<numBlobs;i++){
int area = blobs.GetBlob(i)->Area();
if(area > maxArea_1){
maxArea_2 = maxArea_1;
maxArea_1 = area;
max_2 = max_1;
max_1 = i;
} else if(area > maxArea_2){
maxArea_2 = area;
max_2 = i;
}
}
int i_1 = max_1;
int i_2 = max_2;
double area_left, area_right;
Rect rect_1;
Rect rect_2;
//determines which hand is left/right
blob_1 = blobs.GetBlob(i_1);
blob_2 = blobs.GetBlob(i_2);
center_1 = blob_1->getCenter();
center_2 = blob_2->getCenter();
bool left_is_1 = (center_1.x < center_2.x)? true : false;
leftBlob = (left_is_1)? blob_1 : blob_2;
rightBlob = (left_is_1)? blob_2 : blob_1;
center_left = leftBlob->getCenter();
center_right = rightBlob->getCenter();
//determine the number of valid hands
//validity is decided by whether or not the hand followed a logical movement,
//and if the area of the blob is large enough to be accepted
int valids = 0;
rect_1 = leftBlob->GetBoundingBox();
rectangle(copy, rect_1.tl(), rect_1.br(), leftColor_2, 5);
error_left = norm(statePt_left - center_left);
area_left = leftBlob->Area();
left_valid = error_left < sensitivity && area_left > area;
if(left_valid){
leftBlob->FillBlob(copy,leftColor, true);
valids ++;
}
circle(copy, center_left, 5, leftColor_2, -1);
rect_2 = rightBlob->GetBoundingBox();
rectangle(copy, rect_2.tl(), rect_2.br(), rightColor_2, 5);
error_right = norm(statePt_right - center_right);
area_right = rightBlob->Area();
right_valid = error_right < sensitivity && area_right > area;
if(right_valid){
rightBlob->FillBlob(copy,rightColor, true);
valids ++;
}