keystroke based saving of pointcloud from two primesense devices

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

keystroke based saving of pointcloud from two primesense devices

shome
This post was updated on .
i need to save pointclouds from two primesense devices whenever a keystroke
happens. I have two grabbers running in parallel, which save pcds
continously, but I dont know how I can capture the pcds when a keystroke
occurs.

I am not using the pcl::visualization::PCLVisualizer, so I am not sure if I can use registerKeyboardCallback. Any solution is welcome though.

My code for two primesense devices with parallel continous saving :

#include <pcl/io/openni2_grabber.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/io/pcd_io.h>
#include <thread>
#include <stdlib.h>
#include <iostream>
#include <mutex>

typedef pcl::PointXYZRGBA T;

class continous_saver {
public:
  continous_saver() {};

  void cloud_cb_1(const pcl::PointCloud<T>::ConstPtr &cloud1) {

          std::stringstream ss;
          ss << i;
          std::string num = ss.str();
          std::string filename1="RGBD1_"+num+".pcd";
       
          pcl::io::savePCDFile(filename1,*cloud1);
          i++;
  }

  void cloud_cb_2(const pcl::PointCloud<T>::ConstPtr &cloud2) {

          std::stringstream ss;
          ss << j;
          std::string num = ss.str();
          std::string filename="RGB2_"+num+".pcd";

          pcl::io::savePCDFile(hand_view_filename,*cloud2);
          j++;
  }

  void run() {

    pcl::Grabber *interface1 = new pcl::io::OpenNI2Grabber("#1");
    pcl::PointCloud<T>::Ptr cloud1(new pcl::PointCloud<T>);    

    boost::function<void(const pcl::PointCloud&lt;T>::ConstPtr &)> f1 =
boost::bind(&continous_saver::cloud_cb_1, this, _1);
    interface1->registerCallback(f1);  

    pcl::Grabber *interface2 = new pcl::io::OpenNI2Grabber("#2");
    pcl::PointCloud<T>::Ptr cloud2(new pcl::PointCloud<T>);    

    boost::function<void(const pcl::PointCloud&lt;T>::ConstPtr &)> f2 =
boost::bind(&continous_saver::cloud_cb_2, this, _1);
    interface2->registerCallback(f2);

    interface1->start();
    interface2->start();

    boost::this_thread::sleep(boost::posix_time::millisec(500));

    interface1->stop();
    interface2->stop();
  }

   int i=0;
   int j=0;

};

int main(int argc, char * argv[]) {

  continous_saver v;
  v.run();

  return 0;
}



--
Sent from: http://www.pcl-users.org/
_______________________________________________
PCL-users@pointclouds.org / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: keystroke based saving of pointcloud from two primesense devices

james
Administrator
Have them streaming in the background, and only perform the save when the
keystroke occurs. You could even just implement the keystroke in the console
without using the Visualiser callback.



--
Sent from: http://www.pcl-users.org/
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: keystroke based saving of pointcloud from two primesense devices

shome
This post was updated on .
What do you mean by streaming in the background? Do I use registerKeyboardCallback without actually displaying the clouds? Does visualizer class have that functionality?could you provide any code sample?

How can I implement keystroke in the console without using the Visualiser callback? Do you mean something like using curses.h(for linux) & getch?



--
Sent from: http://www.pcl-users.org/
_______________________________________________
PCL-users@pointclouds.org / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: keystroke based saving of pointcloud from two primesense devices

Tanaji_Kamble
This post was updated on .
Dear shome,
 First use
viewer.registerKeyboardCallback(&keyboardEventOccurred,
(void*)&viewer);

and after that use  something like
static void keyboardEventOccurred(const visualization::KeyboardEvent&
event, void* nothing)
{
       
        if (event.getKeySym() == "space" && event.keyDown())
                saveCloud = true;
}

after that write loop for saving cloud
if ( saveCloud = true)
{
// write code for saving cloud
}

Best luck




-----
Tanaji Kamble
Center of Excellence in Signal & Image Processing,
COEP Pune.
E-mail : tanajikamble13@gmail.com
--
Sent from: http://www.pcl-users.org/
_______________________________________________
PCL-users@pointclouds.org / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Tanaji Kamble
Center of Excellence in Signal & Image Processing,
COEP Pune.
E-mail : tanajikamble13@gmail.com