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


C++ PointVector::size方法代码示例

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


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

示例1: Resample

    void Resample(PointVector& points, size_t n)
    {
        double I = PathLength(points) / (n - 1); // interval length
        double D = 0.0;
        PointVector newpoints;
        newpoints.push_back(points[0]);

        for (size_t i = 1; i < points.size(); ++i)
        {
            double d = Distance(points[i - 1], points[i]);
            if ((D + d) >= I)
            {
                double qx = points[i - 1]->X + ((I - D) / d) * (points[i]->X - points[i - 1]->X);
                double qy = points[i - 1]->Y + ((I - D) / d) * (points[i]->Y - points[i - 1]->Y);
                PointPtr q(new Point(qx, qy));
                newpoints.push_back(q);
                points.insert(points.begin()+i,q);
                D = 0.0;
            }
            else D += d;
        }
        // somtimes we fall a rounding-error short of adding the last point, so add it if so
        if (newpoints.size() == n - 1)
        {
            newpoints.push_back(points[points.size() - 1]);
        }

        points.clear();
        points.insert(points.begin(), newpoints.begin(), newpoints.end());
    }
开发者ID:rcfox,项目名称:NDS-1-Dollar-Gesture-Recognition,代码行数:30,代码来源:dollar.cpp

示例2: PathDistance

 double PathDistance(PointVector& pts1, PointVector& pts2)
 {
     double d = 0.0;
     for (size_t i = 0; i < pts1.size(); ++i) // assumes pts1.length == pts2.length
     {
         d += Distance(pts1[i], pts2[i]);
     }
     return d / pts1.size();
 }
开发者ID:rcfox,项目名称:NDS-1-Dollar-Gesture-Recognition,代码行数:9,代码来源:dollar.cpp

示例3: Centroid

 PointPtr Centroid(PointVector& points)
 {
     double x = 0;
     double y = 0;
     for (size_t i = 0; i < points.size(); ++i)
     {
         x += points[i]->X;
         y += points[i]->Y;
     }
     x /= points.size();
     y /= points.size();
     return PointPtr(new Point(x, y));
 }
开发者ID:rcfox,项目名称:NDS-1-Dollar-Gesture-Recognition,代码行数:13,代码来源:dollar.cpp

示例4: fourier_broken

void fourier_broken(T &m, feature_t* buf) {
    int dftCount = FDLENGTH;

	typename ImageFactory<T>::view_type *tmp = simple_image_copy(m);
    // get contour points for each CC
    ImageList* ccs = cc_analysis(*tmp);
    PointVector p;

    for(ImageList::iterator cc_it = ccs->begin(); cc_it != ccs->end();
            cc_it++) {
        Cc* cc = static_cast<Cc*>(*cc_it);
        Point orig = cc->origin();
        PointVector* cc_p = contour_pavlidis(*cc);

        for(PointVector::iterator p_it = cc_p->begin();
                p_it != cc_p->end(); p_it++) {

            p.push_back(*p_it + orig);
        }
        delete *cc_it;
        delete cc_p;
    } 
    delete ccs;
	delete tmp->data();
	delete tmp;

    if (p.size() == 0) {
      for (int k = 0; k < dftCount; k++)
        buf[k] = 0.0;
      return;
    }
    else if (p.size() == 1) {
      buf[0] = 1.0;
      for (int k = 1; k < dftCount; k++)
        buf[k] = 0.0;
      return;
    }

    //  calculate convex hull and interpolate points
    PointVector* hullPoints = convex_hull_from_points(&p);
    FloatPointVector* interpolatedHullPoints =
        interpolatePolygonPoints(hullPoints);

    FloatVector* distances = minimumContourHullDistances(interpolatedHullPoints, &p);

    floatFourierDescriptorBrokenA(interpolatedHullPoints, &p, distances, dftCount, buf);

    delete hullPoints;
    delete interpolatedHullPoints;
    delete distances;
}
开发者ID:elaboris,项目名称:gamera,代码行数:51,代码来源:fourier_features.hpp

示例5: project

  void PinholePointProjector::project(IntImage &indexImage,
				      DepthImage &depthImage, 
				      const PointVector &points) const {
    assert(_imageRows && _imageCols && "PinholePointProjector: _imageRows and _imageCols are zero");
    
    indexImage.create(_imageRows, _imageCols);
    depthImage.create(_imageRows, _imageCols);
 
    depthImage.setTo(cv::Scalar(std::numeric_limits<float>::max()));
    indexImage.setTo(cv::Scalar(-1));   

    float *drowPtrs[_imageRows];
    int *irowPtrs[_imageRows];
    for(int i = 0; i < _imageRows; i++) {
      drowPtrs[i] = &depthImage(i, 0);
      irowPtrs[i] = &indexImage(i, 0);
    }
    const Point *point = &points[0];
    for(size_t i = 0; i < points.size(); i++, point++) {
      int x, y;
      float d;
      if(!_project(x, y, d, *point) ||
	 d < _minDistance || d > _maxDistance ||
	 x < 0 || x >= indexImage.cols ||
	 y < 0 || y >= indexImage.rows)
	continue;
      float &otherDistance = drowPtrs[y][x];
      int &otherIndex = irowPtrs[y][x];
      if(!otherDistance || otherDistance > d) {
	otherDistance = d;
	otherIndex = i;
      }
    }
  }
开发者ID:Jinqiang,项目名称:g2o_frontend,代码行数:34,代码来源:pinholepointprojector.cpp

示例6: writeVtkVectorArray

void writeVtkVectorArray(ostream &out, const string &name, const PointVector &data) {
    out << "        <DataArray type=\"Float64\" Name=\"" << name << "\" NumberOfComponents=\"3\" format=\"ascii\">";
    for (int c = 0; c < data.size(); c++) {
        Vector3d point = data[c];
        out << "    " << point[0] << " " << point[1] << " " << point[2];
    }
    out << "    </DataArray>" << endl;
}
开发者ID:jcperezma,项目名称:Mechanistic-Model-cplusplus,代码行数:8,代码来源:Moldex+3D+flow+field+utilities.cpp

示例7: PathLength

 double PathLength(PointVector& points)
 {
     double d = 0.0;
     for (size_t i = 1; i < points.size(); ++i)
     {
         d += Distance(points[i - 1], points[i]);
     }
     return d;
 }
开发者ID:rcfox,项目名称:NDS-1-Dollar-Gesture-Recognition,代码行数:9,代码来源:dollar.cpp

示例8: compute

  void StatsCalculator::compute(NormalVector &normals,
				StatsVector &statsVector,
				const PointVector &points,
				const IntImage &indexImage) {
    assert(indexImage.rows > 0 && indexImage.cols > 0 && "StatsCalculator: indexImage has zero size");
    assert(points.size() > 0 && "StatsCalculator: points has zero size");
    
    // HAKKE in order to avoid an annoying warning
    if(indexImage.rows > 0 && indexImage.cols > 0) {
      assert(1);
    } 
    
    if(statsVector.size() != points.size())
      statsVector.resize(points.size());
    if(normals.size() != points.size())
      normals.resize(points.size());
    Normal dummyNormal = Normal::Zero();
    std::fill(statsVector.begin(), statsVector.end(), Stats());
    std::fill(normals.begin(), normals.end(), dummyNormal);
  }
开发者ID:9578577,项目名称:g2o_frontend,代码行数:20,代码来源:statscalculator.cpp

示例9: Name

    Template::Template(std::string name, PointVector points) : Name(name), references(0)
    {
        for (size_t i = 0; i < points.size(); ++i)
        {
            Points.push_back(PointPtr(new Point(points[i]->X,points[i]->Y)));
        }

        Resample(Points, NumPoints);
        RotateToZero(Points);
        ScaleToSquare(Points, SquareSize);
        TranslateToOrigin(Points);
    }
开发者ID:rcfox,项目名称:NDS-1-Dollar-Gesture-Recognition,代码行数:12,代码来源:dollar.cpp

示例10: initialize

int Process::initialize(const PointVector &sensors)
{
	if (sensors.size() < 3) {
		fprintf(stderr, "Process needs at least 3 sensors.\n");
		return -1;
	}

	sensors_ = PointVector(sensors);
	clear();
	initialized_ = true;
	return 0;
}
开发者ID:richese,项目名称:magneto-locator,代码行数:12,代码来源:process.cpp

示例11: TranslateToOrigin

 void TranslateToOrigin(PointVector& points)
 {
     PointPtr c = Centroid(points);
     PointVector newpoints;
     for (size_t i = 0; i < points.size(); ++i)
     {
         double qx = points[i]->X - c->X;
         double qy = points[i]->Y - c->Y;
         newpoints.push_back(PointPtr(new Point(qx, qy)));
     }
     points.clear();
     points.insert(points.begin(), newpoints.begin(), newpoints.end());
 }
开发者ID:rcfox,项目名称:NDS-1-Dollar-Gesture-Recognition,代码行数:13,代码来源:dollar.cpp

示例12: ScaleToSquare

 void ScaleToSquare(PointVector& points, double size)
 {
     RectanglePtr B = BoundingBox(points);
     PointVector newpoints;
     for (size_t i = 0; i < points.size(); ++i)
     {
         double qx = points[i]->X * (size / B->Width);
         double qy = points[i]->Y * (size / B->Height);
         newpoints.push_back(PointPtr(new Point(qx, qy)));
     }
     points.clear();
     points.insert(points.begin(), newpoints.begin(), newpoints.end());
 }
开发者ID:rcfox,项目名称:NDS-1-Dollar-Gesture-Recognition,代码行数:13,代码来源:dollar.cpp

示例13: removeBadPoints

PointVector ImageRegistrator::removeBadPoints(PointVector points, std::vector<uchar> status)
{
    std::vector<uchar>::iterator statusIter = status.begin();
    PointVector::iterator pointIter = points.begin();
    PointVector goodPoints(points.size() - std::count(status.begin(), status.end(), 0));

    for (int i = 0; statusIter != status.end(); ++statusIter, ++pointIter) {
        if (*statusIter == 1) {
            goodPoints[i] = *pointIter;
            ++i;
        }
    }

    return goodPoints;
}
开发者ID:renutyagi,项目名称:SuperResolutionProject,代码行数:15,代码来源:ImageRegistrator.cpp

示例14: BoundingBox

 RectanglePtr BoundingBox(PointVector& points)
 {
     int minX = INT_MAX, maxX = INT_MIN, minY = INT_MAX, maxY = INT_MIN;
     for (size_t i = 0; i < points.size(); ++i)
     {
         if (points[i]->X < minX)
             minX = points[i]->X;
         if (points[i]->X > maxX)
             maxX = points[i]->X;
         if (points[i]->Y < minY)
             minY = points[i]->Y;
         if (points[i]->Y > maxY)
             maxY = points[i]->Y;
     }
     return RectanglePtr(new Rectangle(minX, minY, maxX - minX, maxY - minY));
 }
开发者ID:rcfox,项目名称:NDS-1-Dollar-Gesture-Recognition,代码行数:16,代码来源:dollar.cpp

示例15: RotateBy

    void RotateBy(PointVector& points, double theta)
    {
        PointPtr c = Centroid(points);
        double cosine = cos(theta);
        double sine = sin(theta);

        PointVector newpoints;
        for (size_t i = 0; i < points.size(); ++i)
        {
            double qx = (points[i]->X - c->X) * cosine - (points[i]->Y - c->Y) * sine + c->X;
            double qy = (points[i]->X - c->X) * sine + (points[i]->Y - c->Y) * cosine + c->Y;
            newpoints.push_back(PointPtr(new Point(qx, qy)));
        }

        points.clear();
        points.insert(points.begin(), newpoints.begin(), newpoints.end());
    }
开发者ID:rcfox,项目名称:NDS-1-Dollar-Gesture-Recognition,代码行数:17,代码来源:dollar.cpp


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