Skip to content

Commit

Permalink
Merge pull request PointCloudLibrary#4 from giacomodabisias/master
Browse files Browse the repository at this point in the history
different name fixes to move k4w2 to freenect2 name
  • Loading branch information
larshg committed Jan 14, 2016
2 parents 4062982 + 34716c7 commit 1c9b7f7
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 58 deletions.
20 changes: 5 additions & 15 deletions cmake/Modules/FindFreenect2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
14 changes: 7 additions & 7 deletions io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
)

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<pcl::PointXYZRGB>::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;
Expand All @@ -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
Expand All @@ -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<sig_cb_k4w2_point_cloud_rgb>* point_cloud_rgb_signal_;
boost::signals2::signal<sig_cb_freenect2_point_cloud_rgb>* point_cloud_rgb_signal_;

boost::thread thread_;

Expand All @@ -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<float,512,1> colmap_;
Expand Down
26 changes: 13 additions & 13 deletions io/src/k4w2_grabber.cpp → io/src/freenect2_grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
*
*/

#include <pcl/io/k4w2_grabber.h>
#include <pcl/io/freenect2_grabber.h>
#include <libfreenect2/packet_pipeline.h>

pcl::k4w2Grabber::k4w2Grabber (processor p,
pcl::Freenect2Grabber::Freenect2Grabber (processor p,
std::string serial) :
Grabber (),
is_running_ (false),
Expand Down Expand Up @@ -100,33 +100,33 @@ pcl::k4w2Grabber::k4w2Grabber (processor p,
dev_->setColorFrameListener (listener_);
dev_->setIrAndDepthFrameListener (listener_);

point_cloud_rgb_signal_ = createSignal<sig_cb_k4w2_point_cloud_rgb> ();
point_cloud_rgb_signal_ = createSignal<sig_cb_freenect2_point_cloud_rgb> ();
}

pcl::k4w2Grabber::~k4w2Grabber () throw ()
pcl::Freenect2Grabber::~Freenect2Grabber () throw ()
{
dev_->stop ();
dev_->close ();

disconnect_all_slots<sig_cb_k4w2_point_cloud_rgb> ();
disconnect_all_slots<sig_cb_freenect2_point_cloud_rgb> ();
}

void
pcl::k4w2Grabber::start ()
pcl::Freenect2Grabber::start ()
{
if (!is_running_)
{
need_xyzrgb_ = num_slots<sig_cb_k4w2_point_cloud_rgb> () > 0;
need_xyzrgb_ = num_slots<sig_cb_freenect2_point_cloud_rgb> () > 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_)
{
Expand All @@ -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;
Expand All @@ -166,7 +166,7 @@ pcl::k4w2Grabber::prepareMake3D (const libfreenect2::Freenect2Device::IrCameraPa
}

void
pcl::k4w2Grabber::run ()
pcl::Freenect2Grabber::run ()
{
dev_->start ();

Expand Down
2 changes: 1 addition & 1 deletion visualization/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include <pcl/console/print.h>
#include <pcl/console/parse.h>
#include <pcl/io/io_exception.h>
#include <pcl/io/k4w2_grabber.h>
#include <pcl/io/freenect2_grabber.h>
#include <pcl/visualization/pcl_visualizer.h>

using namespace pcl::console;
Expand All @@ -60,24 +60,24 @@ printHelp (int,
}

template <typename PointT>
class k4w2Viewer
class Freenect2Viewer
{

public:

typedef pcl::PointCloud<PointT> 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 ();
}
Expand All @@ -86,7 +86,7 @@ class k4w2Viewer
run ()
{
boost::function<void
(const typename PointCloudT::ConstPtr&)> f = boost::bind (&k4w2Viewer::cloudCallback, this, _1);
(const typename PointCloudT::ConstPtr&)> f = boost::bind (&Freenect2Viewer::cloudCallback, this, _1);
connection_ = grabber_.registerCallback (f);
grabber_.start ();

Expand Down Expand Up @@ -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_;

Expand All @@ -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"))
{
Expand All @@ -189,9 +189,9 @@ main (int argc,

try
{
pcl::k4w2Grabber grabber (pcl::OPENGL);
pcl::Freenect2Grabber grabber (pcl::OPENGL);

k4w2Viewer<pcl::PointXYZRGB> viewer (grabber);
Freenect2Viewer<pcl::PointXYZRGB> viewer (grabber);
viewer.run ();
}
catch (pcl::io::IOException& e)
Expand Down

0 comments on commit 1c9b7f7

Please sign in to comment.