From 90bb1cdd9aa01a7631998afa3aa56f493295584f Mon Sep 17 00:00:00 2001 From: John Zhao Date: Thu, 10 May 2018 22:11:20 +0800 Subject: [PATCH] Update tutorial get_points --- samples/tutorials/CMakeLists.txt | 2 +- samples/tutorials/data/get_points.cc | 6 +++--- samples/tutorials/data/{pcviewer.cc => pc_viewer.cc} | 12 ++++++------ samples/tutorials/data/{pcviewer.h => pc_viewer.h} | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-) rename samples/tutorials/data/{pcviewer.cc => pc_viewer.cc} (92%) rename samples/tutorials/data/{pcviewer.h => pc_viewer.h} (79%) diff --git a/samples/tutorials/CMakeLists.txt b/samples/tutorials/CMakeLists.txt index 1ff1a11..8ce0700 100644 --- a/samples/tutorials/CMakeLists.txt +++ b/samples/tutorials/CMakeLists.txt @@ -98,7 +98,7 @@ make_executable(get_disparity SRCS data/get_disparity.cc WITH_OPENCV) make_executable(get_depth SRCS data/get_depth.cc WITH_OPENCV) if(PCL_FOUND) make_executable(get_points - SRCS data/get_points.cc data/pcviewer.cc + SRCS data/get_points.cc data/pc_viewer.cc WITH_OPENCV WITH_PCL ) endif() diff --git a/samples/tutorials/data/get_points.cc b/samples/tutorials/data/get_points.cc index 8f58382..7649d7f 100644 --- a/samples/tutorials/data/get_points.cc +++ b/samples/tutorials/data/get_points.cc @@ -17,7 +17,7 @@ #include "mynteye/api.h" -#include "data/pcviewer.h" +#include "data/pc_viewer.h" MYNTEYE_USE_NAMESPACE @@ -43,14 +43,14 @@ int main(int argc, char *argv[]) { auto &&points_data = api->GetStreamData(Stream::POINTS); if (!points_data.frame.empty()) { - pcviewer.Draw(points_data.frame); + pcviewer.Update(points_data.frame); } char key = static_cast(cv::waitKey(1)); if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q break; } - if (pcviewer.WasDrew() && pcviewer.WasStopped()) { + if (pcviewer.WasStopped()) { break; } } diff --git a/samples/tutorials/data/pcviewer.cc b/samples/tutorials/data/pc_viewer.cc similarity index 92% rename from samples/tutorials/data/pcviewer.cc rename to samples/tutorials/data/pc_viewer.cc index 6f05c6f..39bb9b2 100644 --- a/samples/tutorials/data/pcviewer.cc +++ b/samples/tutorials/data/pc_viewer.cc @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#include "data/pcviewer.h" +#include "data/pc_viewer.h" #include @@ -52,13 +52,13 @@ PCViewer::~PCViewer() { } } -void PCViewer::Draw(const cv::Mat &xyz) { +void PCViewer::Update(const cv::Mat &xyz) { pcl::PointCloud::Ptr pc(new pcl::PointCloud); ConvertMatToPointCloud(xyz, pc); - Draw(pc); + Update(pc); } -void PCViewer::Draw(pcl::PointCloud::ConstPtr pc) { +void PCViewer::Update(pcl::PointCloud::ConstPtr pc) { if (viewer_ == nullptr) { viewer_ = CustomColorVis(pc); } @@ -66,12 +66,12 @@ void PCViewer::Draw(pcl::PointCloud::ConstPtr pc) { viewer_->spinOnce(); } -bool PCViewer::WasDrew() const { +bool PCViewer::WasVisual() const { return viewer_ != nullptr; } bool PCViewer::WasStopped() const { - return viewer_ == nullptr || viewer_->wasStopped(); + return viewer_ != nullptr && viewer_->wasStopped(); } void PCViewer::ConvertMatToPointCloud( diff --git a/samples/tutorials/data/pcviewer.h b/samples/tutorials/data/pc_viewer.h similarity index 79% rename from samples/tutorials/data/pcviewer.h rename to samples/tutorials/data/pc_viewer.h index cbd2955..4092265 100644 --- a/samples/tutorials/data/pcviewer.h +++ b/samples/tutorials/data/pc_viewer.h @@ -11,8 +11,8 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef MYNTEYE_TUTORIALS_PCVIEWER_H_ // NOLINT -#define MYNTEYE_TUTORIALS_PCVIEWER_H_ +#ifndef MYNTEYE_TUTORIALS_PC_VIEWER_H_ // NOLINT +#define MYNTEYE_TUTORIALS_PC_VIEWER_H_ #pragma once #include @@ -26,11 +26,11 @@ class PCViewer { PCViewer(); ~PCViewer(); - void Draw(const cv::Mat &xyz); + void Update(const cv::Mat &xyz); - void Draw(pcl::PointCloud::ConstPtr pc); + void Update(pcl::PointCloud::ConstPtr pc); - bool WasDrew() const; + bool WasVisual() const; bool WasStopped() const; private: @@ -40,4 +40,4 @@ class PCViewer { std::shared_ptr viewer_; }; -#endif // MYNTEYE_TUTORIALS_PCVIEWER_H_ NOLINT +#endif // MYNTEYE_TUTORIALS_PC_VIEWER_H_ NOLINT