17 static const Eigen::Vector3d
kSourceColor = Eigen::Vector3d(0, 1, 0);
18 static const Eigen::Vector3d
kTargetColor = Eigen::Vector3d(1, 0, 0);
19 static const Eigen::Vector3d
kCorresColor = Eigen::Vector3d(0, 0, 1);
21 static Eigen::Vector3d
Jet(
double v,
double vmin,
double vmax) {
22 Eigen::Vector3d c(1, 1, 1);
25 if (v < vmin) v = vmin;
26 if (v > vmax) v = vmax;
29 if (v < (vmin + 0.25 * dv)) {
31 c(1) = 4 * (v - vmin) / dv;
32 }
else if (v < (vmin + 0.5 * dv)) {
34 c(2) = 1 + 4 * (vmin + 0.25 * dv - v) / dv;
35 }
else if (v < (vmin + 0.75 * dv)) {
36 c(0) = 4 * (v - vmin - 0.5 * dv) / dv;
39 c(1) = 1 + 4 * (vmin + 0.75 * dv - v) / dv;
51 flip << 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1;
56 auto pcd_i_corres = std::make_shared<cloudViewer::geometry::PointCloud>(
59 pcd_i_corres->Transform(flip);
61 auto pcd_j_corres = std::make_shared<cloudViewer::geometry::PointCloud>(
64 pcd_j_corres->Transform(flip);
66 std::vector<std::pair<int, int>> corres_lines;
67 for (
int i = 0; i < correspondences_host.
GetLength(); ++i) {
68 corres_lines.push_back(
70 correspondences_host[i][1].Item<int64_t>()));
74 *pcd_i_corres, *pcd_j_corres, corres_lines);
84 flip << 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1;
87 auto pcd = std::make_shared<cloudViewer::geometry::PointCloud>(
93 auto pcd_grid = std::make_shared<cloudViewer::geometry::PointCloud>(
95 pcd_grid->Transform(flip);
103 auto pcd_grid_nb = std::make_shared<cloudViewer::geometry::PointCloud>(
104 tpcd_grid_nb.ToLegacy());
106 pcd_grid_nb->Transform(flip);
111 std::vector<std::pair<int, int>> corres_lines;
112 for (int64_t i = 0; i < corres.GetLength(); ++i) {
113 for (
int k = 0; k < 8; ++k) {
114 std::pair<int, int> pair = {i, corres[i][k].Item<int64_t>()};
115 corres_lines.push_back(pair);
120 *pcd, *pcd_grid, corres_lines);
122 core::Tensor corres_interp =
124 .To(core::Device(
"CPU:0"));
125 for (int64_t i = 0; i < corres.GetLength(); ++i) {
126 for (
int k = 0; k < 8; ++k) {
127 float ratio = corres_interp[i][k].Item<
float>();
128 Eigen::Vector3d
color =
Jet(ratio, 0, 0.5);
129 lineset->colors_.push_back(
color);
134 pcd->PaintUniformColor({0, 0, 0});
136 "Point cloud embedding");
141 Eigen::Matrix4d flip;
142 flip << 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1;
152 auto pcd_init_grid = std::make_shared<cloudViewer::geometry::PointCloud>(
154 pcd_init_grid->PaintUniformColor({0, 1, 0});
155 pcd_init_grid->Transform(flip);
157 auto pcd = std::make_shared<cloudViewer::geometry::PointCloud>(
159 pcd->PaintUniformColor({0, 1, 0});
160 pcd->Transform(flip);
163 auto pcd_curr_grid = std::make_shared<cloudViewer::geometry::PointCloud>(
165 pcd_curr_grid->PaintUniformColor({1, 0, 0});
166 pcd_curr_grid->Transform(flip);
168 auto tpcd_warped = ctr_grid.
Deform(tpcd_param);
169 auto pcd_warped = std::make_shared<cloudViewer::geometry::PointCloud>(
170 tpcd_warped.ToLegacy());
171 pcd_warped->PaintUniformColor({1, 0, 0});
172 pcd_warped->Transform(flip);
174 std::vector<std::pair<int, int>> deform_lines;
175 for (
size_t i = 0; i < pcd_init_grid->size(); ++i) {
180 *pcd_init_grid, *pcd_curr_grid, deform_lines);
183 {pcd, pcd_warped, pcd_init_grid, pcd_curr_grid, lineset},
184 "Point cloud deformation");
192 indices = indices.
To(host);
193 indices_nb = indices_nb.
To(host);
194 masks_nb = masks_nb.
To(host);
196 int64_t n = cgrid.
Size();
201 auto pcd_init_grid = std::make_shared<cloudViewer::geometry::PointCloud>(
203 pcd_init_grid->PaintUniformColor({0, 1, 0});
206 auto pcd_curr_grid = std::make_shared<cloudViewer::geometry::PointCloud>(
208 pcd_curr_grid->PaintUniformColor({1, 0, 0});
210 std::vector<std::pair<int, int>> nb_lines;
211 for (int64_t i = 0; i < indices.
GetLength(); ++i) {
212 for (
int j = 0; j < 6; ++j) {
213 if (masks_nb[i][j].Item<bool>()) {
215 indices[i].Item<int>(), indices_nb[i][j].Item<int>()));
223 *pcd_init_grid, nb_lines);
226 *pcd_curr_grid, nb_lines);
228 {pcd_init_grid, pcd_curr_grid, lineset_init, lineset_curr},
int64_t GetLength() const
Tensor IndexGet(const std::vector< Tensor > &index_tensors) const
Advanced indexing getter. This will always allocate a new Tensor.
Tensor Slice(int64_t dim, int64_t start, int64_t stop, int64_t step=1) const
Tensor To(Dtype dtype, bool copy=false) const
static std::shared_ptr< LineSet > CreateFromPointCloudCorrespondences(const ccPointCloud &cloud0, const ccPointCloud &cloud1, const std::vector< std::pair< int, int >> &correspondences)
Factory function to create a LineSet from two PointClouds (cloud0, cloud1) and a correspondence set.
A point cloud contains a list of 3D points.
core::Tensor & GetPointPositions()
Get the value of the "positions" attribute. Convenience function.
cloudViewer::geometry::PointCloud ToLegacy() const
Convert to a legacy CloudViewer PointCloud.
PointCloud Clone() const
Returns copy of the point cloud on the same device.
const TensorMap & GetPointAttr() const
Getter for point_attr_ TensorMap. Used in Pybind.
PointCloud & Transform(const core::Tensor &transformation)
Transforms the PointPositions and PointNormals (if exist) of the PointCloud.
static const std::string kGrid8NbVertexInterpRatios
8 neighbor grid interpolation ratio for vertex per point.
static const std::string kGrid8NbIndices
geometry::PointCloud Deform(const geometry::PointCloud &pcd)
Non-rigidly deform a point cloud using the control grid.
core::Tensor GetInitPositions()
Get control grid original positions directly from tensor keys.
std::tuple< core::Tensor, core::Tensor, core::Tensor > GetNeighborGridMap()
core::Tensor GetCurrPositions()
CLOUDVIEWER_HOST_DEVICE Pair< First, Second > make_pair(const First &_first, const Second &_second)
static const Eigen::Vector3d kCorresColor
void VisualizePointCloudEmbedding(t::geometry::PointCloud &tpcd_param, ControlGrid &ctr_grid, bool show_lines)
void VisualizePointCloudCorrespondences(const t::geometry::PointCloud &tpcd_i, const t::geometry::PointCloud &tpcd_j, const core::Tensor correspondences, const core::Tensor &T_ij)
Visualize pairs with correspondences.
static const Eigen::Vector3d kTargetColor
void VisualizeGridDeformation(ControlGrid &cgrid)
void VisualizePointCloudDeformation(const geometry::PointCloud &tpcd_param, ControlGrid &ctr_grid)
static const Eigen::Vector3d kSourceColor
static Eigen::Vector3d Jet(double v, double vmin, double vmax)
bool DrawGeometries(const std::vector< std::shared_ptr< const ccHObject >> &geometry_ptrs, const std::string &window_name, int width, int height, int left, int top, bool point_show_normal, bool mesh_show_wireframe, bool mesh_show_back_face, Eigen::Vector3d *lookat, Eigen::Vector3d *up, Eigen::Vector3d *front, double *zoom)
Function to draw a list of geometry objects.
Generic file read and write utility for python interface.