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
Have you test this code? I have got an exceptionat line points3d.create(n_points, 1, CV_64F);
I test this code on Visual Studio 2015 communication c++
thanks