当前位置: 首页>>代码示例>>C++>>正文


C++ PointSet::getPointsList方法代码示例

本文整理汇总了C++中PointSet::getPointsList方法的典型用法代码示例。如果您正苦于以下问题:C++ PointSet::getPointsList方法的具体用法?C++ PointSet::getPointsList怎么用?C++ PointSet::getPointsList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PointSet的用法示例。


在下文中一共展示了PointSet::getPointsList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: msg

double
MapImage::getExploredFraction(std::vector<CvPoint> & pathHistory)
{
    CvScalar p;
    // then also find trapped gray parts, make them zero too
    IplImage* im2 = cvCreateImage(cvSize(img->width,img->height), IPL_DEPTH_8U, 1);
    im2->widthStep = img->widthStep;
    cvCopy(img, im2);

    // consider mapped obstacles (180-255) as zeros, so all explored cells are represented
    // in a single continous interval
    cvThreshold(img, img, 180, 254, CV_THRESH_TOZERO_INV);
    // truncate values to get only obstacles
    cvThreshold(im2, im2, 180, 254, CV_THRESH_BINARY);
    cvDilate(im2, im2);

    bool found = false;
    CvPoint point;
    unsigned int i = 0;
    for(i = 0; i < pathHistory.size()-1; i++)
    {
        p = cvGet2D(im2, pathHistory[i].y, pathHistory[i].x);
        if( ((unsigned int)p.val[0]) < 73 )
        {
            point.x = pathHistory[i].x;
            point.y = pathHistory[i].y;
            found = true;
            break;
        }
    }

    if( !found && i == 0 )
    {
        point.x = pathHistory[0].x;
        point.y = pathHistory[0].y;
        found = true;
    }

    if( !found )
    {
        std::string msg("error in finding a seed point to make map qt ready");
        std::cout << msg << std::endl;
        throw MapException(msg.c_str());
    }

    cvFloodFill(im2, point, cvScalar(127));

    std::vector<int> dx;
    std::vector<int> dy;
    std::vector<CvPoint> neighbors;
    PointSet pointSet;

    for(int i = 0; i < img->height; i++)
    {
        dy.push_back(0);
        if(i == 0)
            dy.push_back(1);
        else if(i == img->height-1)
            dy.push_back(-1);
        else
        {
            dy.push_back(-1);
            dy.push_back(1);
        }
        for(int j = 0; j < img->width; j++)
        {
//			p = cvGet2D(im4,i,j);
            dx.push_back(0);
            if( j == 0 )
                dx.push_back(1);
            else if(j == img->width-1)
                dx.push_back(-1);
            else
            {
                dx.push_back(-1);
                dx.push_back(1);
            }
            p = cvGet2D(im2,i,j);
            if( (unsigned int)p.val[0] == 0)  // trapped gray cells
            {
                //cvSet2D(img, i, j, p); // set its neighbors too
                for(unsigned int k = 0; k < dy.size(); k++)
                {
                    for(unsigned int l = 0; l < dx.size(); l++)
                    {
                        //cvSet2D(img, i+dy[k], j+dx[l], p);
                        //neighbors.push_back(cvPoint(j+dx[l],i+dy[k]));
                        pointSet.addPoint(cvPoint(j+dx[l],i+dy[k]));
                    }
                }
            }
            dx.clear();
        }
        dy.clear();
    }

    pointSet.getPointsList(&neighbors);
    std::cout << "updating trapped pixels : " << neighbors.size() << std::endl;
    for(unsigned int i = 0; i < neighbors.size(); i++)
    {
//.........这里部分代码省略.........
开发者ID:namals,项目名称:directed_exploration,代码行数:101,代码来源:mapimage.cpp


注:本文中的PointSet::getPointsList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。