1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge pull request #22598 from savuor:icp_oframe_readonly

Complement PR: #3366@contrib
Changes

    OdometryFrame losts its getters: a user can provide data at construction stage only, pyramids and other generated data is read-only now
    OdometryFrame is based on UMats: no TMat templates inside, CPU operations are done with UMat::getMat() method, chaining issues are solved ad-hoc
    No more Odometry::createOdometryFrame() method, frames are compatible with all odometry algorithms
    Normals computer is cached inside Odometry and exposed to API as well as its settings
    Volume::raycast() won't return the result in OdometryFrame anymore
    Added test for Odometry::prepareFrame*() & other test fixes
    Minor code improvements

TODOs:

    fix TODOs in code
    lower acceptable accuracy errors
This commit is contained in:
Rostislav Vasilikhin
2022-10-24 15:34:01 +02:00
committed by GitHub
parent 8358efaca1
commit 8b7e586faa
24 changed files with 994 additions and 1857 deletions
+5 -248
View File
@@ -471,13 +471,11 @@ PERF_TEST(Perf_TSDF, integrate_frame)
{
Matx44f pose = poses[i].matrix;
Mat depth = scene->depth(pose);
OdometryFrame odf;
odf.setDepth(depth);
OdometryFrame odf(noArray(), depth);
startTimer();
volume.integrate(odf, pose);
stopTimer();
}
SANITY_CHECK_NOTHING();
}
@@ -521,55 +519,6 @@ PERF_TEST(Perf_TSDF, raycast_mat)
SANITY_CHECK_NOTHING();
}
// Perf_TSDF_GPU.raycast_frame
#ifdef HAVE_OPENCL
PERF_TEST(Perf_TSDF_GPU, raycast_frame)
#else
PERF_TEST(Perf_TSDF, raycast_frame)
#endif
{
VolumeType volumeType = VolumeType::TSDF;
VolumeSettings vs(volumeType);
Volume volume(volumeType, vs);
Size frameSize(vs.getRaycastWidth(), vs.getRaycastHeight());
Matx33f intr;
vs.getCameraIntegrateIntrinsics(intr);
bool onlySemisphere = false;
float depthFactor = vs.getDepthFactor();
Vec3f lightPose = Vec3f::all(0.f);
Ptr<Scene> scene = Scene::create(frameSize, intr, depthFactor, onlySemisphere);
std::vector<Affine3f> poses = scene->getPoses();
for (size_t i = 0; i < poses.size(); i++)
{
Matx44f pose = poses[i].matrix;
Mat depth = scene->depth(pose);
#ifdef HAVE_OPENCL
OdometryFrame odf(OdometryFrameStoreType::UMAT);
#else
OdometryFrame odf;
#endif
odf.setDepth(depth);
volume.integrate(odf, pose);
startTimer();
volume.raycast(pose, frameSize.height, frameSize.width, odf);
stopTimer();
if (display)
{
Mat points, normals;
odf.getPyramidAt(points, OdometryFramePyramidType::PYR_CLOUD, 0);
odf.getPyramidAt(normals, OdometryFramePyramidType::PYR_NORM, 0);
displayImage(depth, points, normals, depthFactor, lightPose);
}
}
SANITY_CHECK_NOTHING();
}
#ifdef HAVE_OPENCL
// Perf_TSDF_CPU.integrate_mat
@@ -626,8 +575,7 @@ PERF_TEST(Perf_TSDF_CPU, integrate_frame)
{
Matx44f pose = poses[i].matrix;
Mat depth = scene->depth(pose);
OdometryFrame odf;
odf.setDepth(depth);
OdometryFrame odf(noArray(), depth);
startTimer();
volume.integrate(odf, pose);
@@ -678,53 +626,8 @@ PERF_TEST(Perf_TSDF_CPU, raycast_mat)
cv::ocl::setUseOpenCL(true);
}
// Perf_TSDF_CPU.raycast_frame
PERF_TEST(Perf_TSDF_CPU, raycast_frame)
{
cv::ocl::setUseOpenCL(false);
VolumeType volumeType = VolumeType::TSDF;
VolumeSettings vs(volumeType);
Volume volume(volumeType, vs);
Size frameSize(vs.getRaycastWidth(), vs.getRaycastHeight());
Matx33f intr;
vs.getCameraIntegrateIntrinsics(intr);
bool onlySemisphere = false;
float depthFactor = vs.getDepthFactor();
Vec3f lightPose = Vec3f::all(0.f);
Ptr<Scene> scene = Scene::create(frameSize, intr, depthFactor, onlySemisphere);
std::vector<Affine3f> poses = scene->getPoses();
for (size_t i = 0; i < poses.size(); i++)
{
Matx44f pose = poses[i].matrix;
Mat depth = scene->depth(pose);
OdometryFrame odf;
odf.setDepth(depth);
volume.integrate(odf, pose);
startTimer();
volume.raycast(pose, frameSize.height, frameSize.width, odf);
stopTimer();
if (display)
{
Mat points, normals;
odf.getPyramidAt(points, OdometryFramePyramidType::PYR_CLOUD, 0);
odf.getPyramidAt(normals, OdometryFramePyramidType::PYR_NORM, 0);
displayImage(depth, points, normals, depthFactor, lightPose);
}
}
SANITY_CHECK_NOTHING();
cv::ocl::setUseOpenCL(true);
}
#endif
// Perf_HashTSDF_GPU.integrate_mat
#ifdef HAVE_OPENCL
PERF_TEST(Perf_HashTSDF_GPU, integrate_mat)
@@ -780,8 +683,7 @@ PERF_TEST(Perf_HashTSDF, integrate_frame)
{
Matx44f pose = poses[i].matrix;
Mat depth = scene->depth(pose);
OdometryFrame odf;
odf.setDepth(depth);
OdometryFrame odf(noArray(), depth);
startTimer();
volume.integrate(odf, pose);
@@ -830,56 +732,6 @@ PERF_TEST(Perf_HashTSDF, raycast_mat)
SANITY_CHECK_NOTHING();
}
// Perf_HashTSDF_GPU.raycast_frame
#ifdef HAVE_OPENCL
PERF_TEST(Perf_HashTSDF_GPU, raycast_frame)
#else
PERF_TEST(Perf_HashTSDF, raycast_frame)
#endif
{
VolumeType volumeType = VolumeType::HashTSDF;
VolumeSettings vs(volumeType);
Volume volume(volumeType, vs);
Size frameSize(vs.getRaycastWidth(), vs.getRaycastHeight());
Matx33f intr;
vs.getCameraIntegrateIntrinsics(intr);
bool onlySemisphere = false;
float depthFactor = vs.getDepthFactor();
Vec3f lightPose = Vec3f::all(0.f);
Ptr<Scene> scene = Scene::create(frameSize, intr, depthFactor, onlySemisphere);
std::vector<Affine3f> poses = scene->getPoses();
for (size_t i = 0; i < poses.size(); i++)
{
Matx44f pose = poses[i].matrix;
Mat depth = scene->depth(pose);
#ifdef HAVE_OPENCL
OdometryFrame odf(OdometryFrameStoreType::UMAT);
#else
OdometryFrame odf;
#endif
odf.setDepth(depth);
volume.integrate(odf, pose);
startTimer();
volume.raycast(pose, frameSize.height, frameSize.width, odf);
stopTimer();
if (display)
{
Mat points, normals;
odf.getPyramidAt(points, OdometryFramePyramidType::PYR_CLOUD, 0);
odf.getPyramidAt(normals, OdometryFramePyramidType::PYR_NORM, 0);
displayImage(depth, points, normals, depthFactor, lightPose);
}
}
SANITY_CHECK_NOTHING();
}
#ifdef HAVE_OPENCL
// Perf_HashTSDF_CPU.integrate_mat
PERF_TEST(Perf_HashTSDF_CPU, integrate_mat)
@@ -935,8 +787,7 @@ PERF_TEST(Perf_HashTSDF_CPU, integrate_frame)
{
Matx44f pose = poses[i].matrix;
Mat depth = scene->depth(pose);
OdometryFrame odf;
odf.setDepth(depth);
OdometryFrame odf(noArray(), depth);
startTimer();
volume.integrate(odf, pose);
@@ -985,53 +836,9 @@ PERF_TEST(Perf_HashTSDF_CPU, raycast_mat)
cv::ocl::setUseOpenCL(true);
}
// Perf_HashTSDF_CPU.raycast_frame
PERF_TEST(Perf_HashTSDF_CPU, raycast_frame)
{
cv::ocl::setUseOpenCL(false);
VolumeType volumeType = VolumeType::HashTSDF;
VolumeSettings vs(volumeType);
Volume volume(volumeType, vs);
Size frameSize(vs.getRaycastWidth(), vs.getRaycastHeight());
Matx33f intr;
vs.getCameraIntegrateIntrinsics(intr);
bool onlySemisphere = false;
float depthFactor = vs.getDepthFactor();
Vec3f lightPose = Vec3f::all(0.f);
Ptr<Scene> scene = Scene::create(frameSize, intr, depthFactor, onlySemisphere);
std::vector<Affine3f> poses = scene->getPoses();
for (size_t i = 0; i < poses.size(); i++)
{
Matx44f pose = poses[i].matrix;
Mat depth = scene->depth(pose);
OdometryFrame odf;
odf.setDepth(depth);
volume.integrate(odf, pose);
startTimer();
volume.raycast(pose, frameSize.height, frameSize.width, odf);
stopTimer();
if (display)
{
Mat points, normals;
odf.getPyramidAt(points, OdometryFramePyramidType::PYR_CLOUD, 0);
odf.getPyramidAt(normals, OdometryFramePyramidType::PYR_NORM, 0);
displayImage(depth, points, normals, depthFactor, lightPose);
}
}
SANITY_CHECK_NOTHING();
cv::ocl::setUseOpenCL(true);
}
#endif
// Perf_ColorTSDF_CPU.integrate_mat
#ifdef HAVE_OPENCL
PERF_TEST(Perf_ColorTSDF_CPU, integrate_mat)
@@ -1089,9 +896,7 @@ PERF_TEST(Perf_ColorTSDF, integrate_frame)
Matx44f pose = poses[i].matrix;
Mat depth = scene->depth(pose);
Mat rgb = scene->rgb(pose);
OdometryFrame odf;
odf.setDepth(depth);
odf.setImage(rgb);
OdometryFrame odf(rgb, depth);
startTimer();
volume.integrate(odf, pose);
@@ -1141,52 +946,4 @@ PERF_TEST(Perf_ColorTSDF, raycast_mat)
SANITY_CHECK_NOTHING();
}
// Perf_ColorTSDF_CPU.raycast_frame
#ifdef HAVE_OPENCL
PERF_TEST(Perf_ColorTSDF_CPU, raycast_frame)
#else
PERF_TEST(Perf_ColorTSDF, raycast_frame)
#endif
{
VolumeType volumeType = VolumeType::ColorTSDF;
VolumeSettings vs(volumeType);
Volume volume(volumeType, vs);
Size frameSize(vs.getRaycastWidth(), vs.getRaycastHeight());
Matx33f intr;
vs.getCameraIntegrateIntrinsics(intr);
bool onlySemisphere = false;
float depthFactor = vs.getDepthFactor();
Vec3f lightPose = Vec3f::all(0.f);
Ptr<Scene> scene = Scene::create(frameSize, intr, depthFactor, onlySemisphere);
std::vector<Affine3f> poses = scene->getPoses();
for (size_t i = 0; i < poses.size(); i++)
{
Matx44f pose = poses[i].matrix;
Mat depth = scene->depth(pose);
Mat rgb = scene->rgb(pose);
OdometryFrame odf;
odf.setDepth(depth);
odf.setImage(rgb);
volume.integrate(odf, pose);
startTimer();
volume.raycast(pose, frameSize.height, frameSize.width, odf);
stopTimer();
if (display)
{
Mat points, normals, colors;
odf.getPyramidAt(points, OdometryFramePyramidType::PYR_CLOUD, 0);
odf.getPyramidAt(normals, OdometryFramePyramidType::PYR_NORM, 0);
odf.getPyramidAt(colors, OdometryFramePyramidType::PYR_IMAGE, 0);
displayColorImage(depth, rgb, points, normals, colors, depthFactor, lightPose);
}
}
SANITY_CHECK_NOTHING();
}
}} // namespace