diff --git a/cmake/Modules/FindFreenect2.cmake b/cmake/Modules/FindFreenect2.cmake index e852a449338..10dd7df7e12 100644 --- a/cmake/Modules/FindFreenect2.cmake +++ b/cmake/Modules/FindFreenect2.cmake @@ -17,18 +17,8 @@ find_path(FREENECT2_INCLUDE_DIRS NAMES libfreenect2.hpp find_library(FREENECT2_LIBRARY NAMES freenect2 ) -if(FREENECT2_INCLUDE_DIRS AND FREENECT2_LIBRARY) - set(FREENECT2_FOUND TRUE) -endif() - -if(FREENECT2_LIBRARY) - set(FREENECT2_LIBRARY ${FREENECT2_LIBRARY}) - set(FREENECT2_LIBRARIES ${FREENECT2_LIBRARY}) -endif() - -if (FREENECT2_FOUND) - MESSAGE("-- Found Freenect2 ${FREENECT_LIBRARIES}") - mark_as_advanced(FREENECT2_INCLUDE_DIRS FREENECT2_LIBRARY FREENECT2_LIBRARIES) -endif() - - +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Freenect2 + FOUND_VAR FREENECT2_FOUND + REQUIRED_VARS FREENECT2_LIBRARY FREENECT2_INCLUDE_DIRS +) diff --git a/io/CMakeLists.txt b/io/CMakeLists.txt index b6a5af3ab72..8cfccc29233 100644 --- a/io/CMakeLists.txt +++ b/io/CMakeLists.txt @@ -162,11 +162,11 @@ if(build) if(WITH_FREENECT2) option(WITH_OPENCL "adds opencl support for freenect2" OFF) - set(K4W2_GRABBER_INCLUDES - include/pcl/io/k4w2_grabber.h + set(FREENECT2_GRABBER_INCLUDES + include/pcl/io/freenect2_grabber.h ) - set(K4W2_GRABBER_SOURCES - src/k4w2_grabber.cpp + set(FREENECT2_GRABBER_SOURCES + src/freenect2_grabber.cpp ) endif() @@ -236,7 +236,7 @@ if(build) ${DAVIDSDK_GRABBER_SOURCES} ${DSSDK_GRABBER_SOURCES} ${RSSDK_GRABBER_SOURCES} - ${K4W2_GRABBER_SOURCES} + ${FREENECT2_GRABBER_SOURCES} ) if(PNG_FOUND) list(APPEND srcs @@ -284,7 +284,7 @@ if(build) ${DAVIDSDK_GRABBER_INCLUDES} ${DSSDK_GRABBER_INCLUDES} ${RSSDK_GRABBER_INCLUDES} - ${K4W2_GRABBER_INCLUDES} + ${FREENECT2_GRABBER_INCLUDES} "include/pcl/${SUBSYS_NAME}/pxc_grabber.h" # contains only depreciation note ) @@ -370,7 +370,7 @@ if(build) endif() if(WITH_FREENECT2) - target_link_libraries(${LIB_NAME} ${FREENECT2_LIBRARIES}) + target_link_libraries(${LIB_NAME} ${FREENECT2_LIBRARY}) endif() if (PCAP_FOUND) diff --git a/io/include/pcl/io/k4w2_grabber.h b/io/include/pcl/io/freenect2_grabber.h similarity index 86% rename from io/include/pcl/io/k4w2_grabber.h rename to io/include/pcl/io/freenect2_grabber.h index 018e9a0b489..488ae654508 100644 --- a/io/include/pcl/io/k4w2_grabber.h +++ b/io/include/pcl/io/freenect2_grabber.h @@ -62,16 +62,16 @@ namespace pcl CPU, OPENCL, OPENGL }; -class PCL_EXPORTS k4w2Grabber : public Grabber +class PCL_EXPORTS Freenect2Grabber : public Grabber { public: typedef - void (sig_cb_k4w2_point_cloud_rgb) + void (sig_cb_freenect2_point_cloud_rgb) (const pcl::PointCloud::ConstPtr&); - k4w2Grabber(processor p = CPU, std::string serial = std::string()); + Freenect2Grabber(processor p = CPU, std::string serial = std::string()); virtual - ~k4w2Grabber() throw(); + ~Freenect2Grabber() throw(); virtual bool isRunning() const; @@ -85,7 +85,7 @@ class PCL_EXPORTS k4w2Grabber : public Grabber virtual std::string getName() const { - return (std::string("K4W2Grabber")); + return (std::string("Freenect2Grabber")); } virtual std::string @@ -104,7 +104,7 @@ class PCL_EXPORTS k4w2Grabber : public Grabber void prepareMake3D(const libfreenect2::Freenect2Device::IrCameraParams & depth_p); // Signals to indicate whether new clouds are available - boost::signals2::signal* point_cloud_rgb_signal_; + boost::signals2::signal* point_cloud_rgb_signal_; boost::thread thread_; @@ -117,12 +117,12 @@ class PCL_EXPORTS k4w2Grabber : public Grabber EventFrequency frequency_; mutable boost::mutex fps_mutex_; - libfreenect2::Registration* registration_ = 0; + libfreenect2::Registration* registration_; libfreenect2::Freenect2 freenect2_; - libfreenect2::Freenect2Device * dev_ = 0; - libfreenect2::SyncMultiFrameListener * listener_ = 0; - libfreenect2::PacketPipeline * pipeline_ = 0; + libfreenect2::Freenect2Device * dev_; + libfreenect2::SyncMultiFrameListener * listener_; + libfreenect2::PacketPipeline * pipeline_; libfreenect2::FrameMap frames_; libfreenect2::Frame undistorted_, registered_, big_mat_; Eigen::Matrix colmap_; diff --git a/io/src/k4w2_grabber.cpp b/io/src/freenect2_grabber.cpp similarity index 90% rename from io/src/k4w2_grabber.cpp rename to io/src/freenect2_grabber.cpp index 17b8c2c23ab..351da3d64bd 100644 --- a/io/src/k4w2_grabber.cpp +++ b/io/src/freenect2_grabber.cpp @@ -35,10 +35,10 @@ * */ -#include +#include #include -pcl::k4w2Grabber::k4w2Grabber (processor p, +pcl::Freenect2Grabber::Freenect2Grabber (processor p, std::string serial) : Grabber (), is_running_ (false), @@ -100,33 +100,33 @@ pcl::k4w2Grabber::k4w2Grabber (processor p, dev_->setColorFrameListener (listener_); dev_->setIrAndDepthFrameListener (listener_); - point_cloud_rgb_signal_ = createSignal (); + point_cloud_rgb_signal_ = createSignal (); } -pcl::k4w2Grabber::~k4w2Grabber () throw () +pcl::Freenect2Grabber::~Freenect2Grabber () throw () { dev_->stop (); dev_->close (); - disconnect_all_slots (); + disconnect_all_slots (); } void -pcl::k4w2Grabber::start () +pcl::Freenect2Grabber::start () { if (!is_running_) { - need_xyzrgb_ = num_slots () > 0; + need_xyzrgb_ = num_slots () > 0; frequency_.reset (); is_running_ = true; - thread_ = boost::thread (&k4w2Grabber::run, this); + thread_ = boost::thread (&Freenect2Grabber::run, this); } } void -pcl::k4w2Grabber::stop () +pcl::Freenect2Grabber::stop () { if (is_running_) { @@ -136,20 +136,20 @@ pcl::k4w2Grabber::stop () } bool -pcl::k4w2Grabber::isRunning () const +pcl::Freenect2Grabber::isRunning () const { return (is_running_); } float -pcl::k4w2Grabber::getFramesPerSecond () const +pcl::Freenect2Grabber::getFramesPerSecond () const { boost::mutex::scoped_lock lock (fps_mutex_); return (frequency_.getFrequency ()); } void -pcl::k4w2Grabber::prepareMake3D (const libfreenect2::Freenect2Device::IrCameraParams & depth_p) +pcl::Freenect2Grabber::prepareMake3D (const libfreenect2::Freenect2Device::IrCameraParams & depth_p) { const int w = 512; const int h = 424; @@ -166,7 +166,7 @@ pcl::k4w2Grabber::prepareMake3D (const libfreenect2::Freenect2Device::IrCameraPa } void -pcl::k4w2Grabber::run () +pcl::Freenect2Grabber::run () { dev_->start (); diff --git a/visualization/tools/CMakeLists.txt b/visualization/tools/CMakeLists.txt index 1e61307171e..989678e1bc3 100644 --- a/visualization/tools/CMakeLists.txt +++ b/visualization/tools/CMakeLists.txt @@ -60,7 +60,7 @@ if(WITH_RSSDK) endif() if(WITH_FREENECT2) - PCL_ADD_EXECUTABLE_OPT_BUNDLE(pcl_freenect2_viewer ${SUBSYS_NAME} k4w2_viewer.cpp) + PCL_ADD_EXECUTABLE_OPT_BUNDLE(pcl_freenect2_viewer ${SUBSYS_NAME} freenect2_viewer.cpp) target_link_libraries(pcl_freenect2_viewer pcl_common pcl_io pcl_visualization) endif() diff --git a/visualization/tools/k4w2_viewer.cpp b/visualization/tools/freenect2_viewer.cpp similarity index 89% rename from visualization/tools/k4w2_viewer.cpp rename to visualization/tools/freenect2_viewer.cpp index a5c5aa7ac21..184c5a644c1 100644 --- a/visualization/tools/k4w2_viewer.cpp +++ b/visualization/tools/freenect2_viewer.cpp @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include using namespace pcl::console; @@ -60,24 +60,24 @@ printHelp (int, } template -class k4w2Viewer +class Freenect2Viewer { public: typedef pcl::PointCloud PointCloudT; - k4w2Viewer (pcl::k4w2Grabber& grabber) : + Freenect2Viewer (pcl::Freenect2Grabber& grabber) : grabber_ (grabber), - viewer_ ("k4w2 Viewer") + viewer_ ("Freenect2 Viewer") { viewer_.setCameraFieldOfView (0.785398); // approximately 45 degrees viewer_.setCameraPosition (0, 0, 0, 0, 0, 1, 0, 1, 0); - viewer_.registerKeyboardCallback (&k4w2Viewer::keyboardCallback, *this); - viewer_.registerPointPickingCallback (&k4w2Viewer::pointPickingCallback, *this); + viewer_.registerKeyboardCallback (&Freenect2Viewer::keyboardCallback, *this); + viewer_.registerPointPickingCallback (&Freenect2Viewer::pointPickingCallback, *this); } - ~k4w2Viewer () + ~Freenect2Viewer () { connection_.disconnect (); } @@ -86,7 +86,7 @@ class k4w2Viewer run () { boost::function f = boost::bind (&k4w2Viewer::cloudCallback, this, _1); + (const typename PointCloudT::ConstPtr&)> f = boost::bind (&Freenect2Viewer::cloudCallback, this, _1); connection_ = grabber_.registerCallback (f); grabber_.start (); @@ -152,7 +152,7 @@ class k4w2Viewer pcl::console::print_value ("%.3f\n", z); } - pcl::k4w2Grabber& grabber_; + pcl::Freenect2Grabber& grabber_; pcl::visualization::PCLVisualizer viewer_; boost::signals2::connection connection_; @@ -165,7 +165,7 @@ int main (int argc, char** argv) { - print_info ("Viewer for K4W2 devices (run with --help for more information)\n", argv[0]); + print_info ("Viewer for Freenect2 devices (run with --help for more information)\n", argv[0]); if (find_switch (argc, argv, "--help") || find_switch (argc, argv, "-h")) { @@ -189,9 +189,9 @@ main (int argc, try { - pcl::k4w2Grabber grabber (pcl::OPENGL); + pcl::Freenect2Grabber grabber (pcl::OPENGL); - k4w2Viewer viewer (grabber); + Freenect2Viewer viewer (grabber); viewer.run (); } catch (pcl::io::IOException& e)