47 template<
typename Po
intSource,
typename Po
intTarget>
void
55 template<
typename Po
intSource,
typename Po
intTarget>
void
59 viewer_thread_.~thread ();
63 template<
typename Po
intSource,
typename Po
intTarget>
void
69 viewer_->initCameraParameters ();
81 viewer_->createViewPort (0.0, 0.0, 0.5, 1.0, v1);
82 viewer_->setBackgroundColor (0, 0, 0, v1);
83 viewer_->addText (
"Initial position of source and target point clouds", 10, 50,
"title v1", v1);
84 viewer_->addText (
"Blue -> target", 10, 30, 0.0, 0.0, 1.0,
"legend target v1", v1);
85 viewer_->addText (
"Red -> source", 10, 10, 1.0, 0.0, 0.0,
"legend source v1", v1);
87 viewer_->addPointCloud<PointSource> (cloud_source_.makeShared (), cloud_source_handler_,
"cloud source v1", v1);
88 viewer_->addPointCloud<PointTarget> (cloud_target_.makeShared (), cloud_target_handler_,
"cloud target v1", v1);
92 viewer_->createViewPort (0.5, 0.0, 1.0, 1.0, v2);
93 viewer_->setBackgroundColor (0.1, 0.1, 0.1, v2);
94 std::string registration_port_title_ =
"Registration using "+registration_method_name_;
95 viewer_->addText (registration_port_title_, 10, 90,
"title v2", v2);
97 viewer_->addText (
"Yellow -> intermediate", 10, 50, 1.0, 1.0, 0.0,
"legend intermediate v2", v2);
98 viewer_->addText (
"Blue -> target", 10, 30, 0.0, 0.0, 1.0,
"legend target v2", v2);
99 viewer_->addText (
"Red -> source", 10, 10, 1.0, 0.0, 0.0,
"legend source v2", v1);
102 viewer_->addPointCloud<PointTarget> (cloud_target_.makeShared (), cloud_target_handler_,
"cloud target v2", v2);
103 viewer_->addPointCloud<PointSource> (cloud_intermediate_.makeShared (), cloud_intermediate_handler_,
104 "cloud intermediate v2", v2);
107 std::size_t correspondeces_old_size = 0;
110 viewer_->addCoordinateSystem (1.0,
"global");
113 std::string line_root_ =
"line";
116 while (!viewer_->wasStopped ())
119 visualizer_updating_mutex_.lock ();
123 viewer_->removePointCloud (
"cloud intermediate v2", v2);
126 viewer_->addPointCloud<PointSource> (cloud_intermediate_.makeShared (), cloud_intermediate_handler_,
127 "cloud intermediate v2", v2);
131 std::string line_name_;
133 for (std::size_t correspondence_id = 0; correspondence_id < correspondeces_old_size; ++correspondence_id)
136 line_name_ = getIndexedName (line_root_, correspondence_id);
139 viewer_->removeShape (line_name_, v2);
143 std::size_t correspondences_new_size = cloud_intermediate_indices_.size ();
146 const std::string correspondences_text =
"Random -> correspondences " + std::to_string(correspondences_new_size);
147 viewer_->removeShape (
"correspondences_size", 0);
148 viewer_->addText (correspondences_text, 10, 70, 0.0, 1.0, 0.0,
"correspondences_size", v2);
151 if( ( 0 < maximum_displayed_correspondences_ ) &&
152 (maximum_displayed_correspondences_ < correspondences_new_size) )
153 correspondences_new_size = maximum_displayed_correspondences_;
156 correspondeces_old_size = correspondences_new_size;
159 for (std::size_t correspondence_id = 0; correspondence_id < correspondences_new_size; ++correspondence_id)
162 double random_red = 255 * rand () / (RAND_MAX + 1.0);
163 double random_green = 255 * rand () / (RAND_MAX + 1.0);
164 double random_blue = 255 * rand () / (RAND_MAX + 1.0);
167 line_name_ = getIndexedName (line_root_, correspondence_id);
170 viewer_->addLine (cloud_intermediate_[cloud_intermediate_indices_[correspondence_id]],
171 cloud_target_[cloud_target_indices_[correspondence_id]],
172 random_red, random_green, random_blue,
177 visualizer_updating_mutex_.unlock ();
180 viewer_->spinOnce (100);
181 using namespace std::chrono_literals;
182 std::this_thread::sleep_for(100ms);
187 template<
typename Po
intSource,
typename Po
intTarget>
void
195 visualizer_updating_mutex_.lock ();
199 if (!first_update_flag_)
201 first_update_flag_ =
true;
203 this->cloud_source_ = cloud_src;
204 this->cloud_target_ = cloud_tgt;
206 this->cloud_intermediate_ = cloud_src;
210 cloud_intermediate_ = cloud_src;
211 cloud_intermediate_indices_ = indices_src;
214 cloud_target_indices_ = indices_tgt;
217 visualizer_updating_mutex_.unlock ();