Ask Your Question

yakuto4's profile - activity

2017-05-10 00:36:05 -0600 commented question Wasteful code?

I test this code on Visual Studio 2015 communication c++

thanks

2017-04-06 05:08:48 -0600 received badge  Student (source)
2017-04-06 04:34:11 -0600 asked a question Wasteful code?
hi
I Check this code from: 

 opencv32\opencv_contrib\modules\sfm\src\simple_pipeline.cpp

and i found faster code.
->

    libmv_reconstruction_.reconstruction.AllPoints()[i].X[j]

 should be: 

    libmv:: vector<EuclideanPoint> Points = libmv_reconstruction_.reconstruction.AllPoints();

and  change to Points [i].X[j]

-------------------------------------

    getPoints(OutputArray points3d) {
        const size_t n_points =
          libmv_reconstruction_.reconstruction.AllPoints().size();

        points3d.create(n_points, 1, CV_64F);

        Vec3d point3d;
        for ( size_t i = 0; i < n_points; ++i )
        {
          for ( int j = 0; j < 3; ++j )
            point3d[j] =  libmv_reconstruction_.reconstruction.AllPoints()[i].X[j];
          Mat(point3d).copyTo(points3d.getMatRef(i));
        }

      }

-------------------------------------
getPoints(OutputArray points3d) {
    libmv:: vector<EuclideanPoint> points = libmv_reconstruction_.reconstruction.AllPoints();
    const size_t n_points = points.size();
    points3d.create(n_points, 1, CV_64F);

    Vec3d point3d;
    for ( size_t i = 0; i < n_points; ++i )
    {
      for ( int j = 0; j < 3; ++j )
        point3d[j] = points[i].X[j];
      Mat(point3d).copyTo(points3d.getMatRef(i));
    }
  }

thanks