Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Wasteful code?

hi I Check this code

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

and i found faster code. -> libmv_reconstruction_.reconstruction.AllPoints()[i].X[j]

should

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

click to hide/show revision 2
No.2 Revision

updated 2017-04-06 04:37:53 -0600

berak gravatar image

Wasteful code?

hi
I Check this code 

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

from: opencv32\opencv_contrib\modules\sfm\src\simple_pipeline.cpp and i found faster code. -> libmv_reconstruction_.reconstruction.AllPoints()[i].X[j]

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

be: libmv:: vector<euclideanpoint> vector<EuclideanPoint> Points = libmv_reconstruction_.reconstruction.AllPoints(); and change to Points [i].X[j]


[i].X[j] ------------------------------------- getPoints(OutputArray points3d) { const size_t n_points = libmv_reconstruction_.reconstruction.AllPoints().size();

    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> vector<EuclideanPoint> points = libmv_reconstruction_.reconstruction.AllPoints(); const size_t n_points = points.size(); points3d.create(n_points, 1, CV_64F);

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