示例#1
0
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event, void* viewer_void)
{

	if (event.getKeySym () == "r" && event.keyDown ())
	{
		boost::mutex::scoped_lock startLock(updateOnlineMutex);
		std::cout << "r was pressed => starting construction " << std::endl;
		PointCloud<pcl::PointXYZRGB>::Ptr deep_copy (new PointCloud<pcl::PointXYZRGB>( *onlineView ) );
		if(noFrames == 0)
		{
			cloudA = deep_copy;
			boost::thread workerThread(alignFrames);
			cout << "Started recording --> " << endl;
			start = true;
		}
		noFrames++;
		startLock.unlock();

	}else if (event.getKeySym () == "p" && event.keyDown ())
	{
		stop = true;
		condQ.notify_one();
		//surfaceConst.fastTranguilation(global);
	}else if(event.getKeySym() == "s" && event.keyDown())
	{
		boost::mutex::scoped_lock saveLock(updateOnlineMutex);
		std::cout << "s was pressed => saving" << std::endl;
		PointCloud<pcl::PointXYZRGB>::Ptr deep_copy (new PointCloud<pcl::PointXYZRGB>( *onlineView ) );
		std::stringstream tmp;
		tmp << noFrames << ".pcd";
		pcl::io::savePCDFileBinary(tmp.str() , *deep_copy);
		noFrames++;
		saveLock.unlock();
	}
}
void
keyboardEventOccurred(const pcl::visualization::KeyboardEvent &event, void* viewer_void)
{
  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<pcl::visualization::PCLVisualizer> *>(viewer_void);
  if(event.getKeySym() == "d" && event.keyDown())
    cout << "d";
  if(event.getKeySym() == "n" && event.keyDown())
    viewer->removeAllPointClouds();
}
示例#3
0
// change camera view point
void chCameraViewPoint (const pcl::visualization::KeyboardEvent &event, void* viewer_void)
{
	boost::shared_ptr<visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<visualization::PCLVisualizer> *> (viewer_void);
	if (event.getKeySym () == "a" && event.keyDown ())
		viewer->setCameraPosition(camera_left[0], camera_left[1], camera_left[2], camera_left[3], camera_left[4], camera_left[5]);
	if (event.getKeySym () == "s" && event.keyDown ())
		viewer->setCameraPosition(camera_front[0], camera_front[1], camera_front[2], camera_front[3], camera_front[4], camera_front[5]);
	if (event.getKeySym () == "d" && event.keyDown ())
		viewer->setCameraPosition(camera_right[0], camera_right[1], camera_right[2], camera_right[3], camera_right[4], camera_right[5]);
}
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event, void* viewer_void)
{
  if ( (event.getKeySym () == "r" || event.getKeySym () == "R") && event.keyDown ())
  {
    cout << "r was pressed => change between regular/graph representation" << endl;
    graphRepresentation = !graphRepresentation;
  }
  else if ( (event.getKeySym () == "p" || event.getKeySym () == "P") && event.keyDown ())
    showPointCloud = !showPointCloud;
  else if ( (event.getKeySym () == "l" || event.getKeySym () == "L") && event.keyDown ())
    showPbMap = !showPbMap;
}
  void myCallback (const pcl::visualization::KeyboardEvent& event, void* cookie)
  {
    if(event.getKeySym () == "q" && event.keyDown ())
      {
	pressedQ=true;
      }
    else if(event.getKeySym () == "a" && event.keyDown ())
      {
	pressedA=true;
      }
    else
      return;
  }
 void keyboardCallback(const pcl::visualization::KeyboardEvent &event, void *) {
     std::string special_key = event.getKeyCode() ? "" : "special ";
     if (event.keyDown())
         Logger::log(Logger::INFO, "The %skey %c was pressed.", special_key.c_str(), event.getKeyCode());
     else
         Logger::log(Logger::INFO, "The %skey %c was released.", special_key.c_str(), event.getKeyCode());
 }
示例#7
0
void
KeyboardEventOccurred(const pcl::visualization::KeyboardEvent &event, void * data)
{
  R200Grabber * g = (R200Grabber*)data;
  std::shared_ptr<DSAPI> p = g->getDSAPI();
  if(event.keyDown())
  {
    if(event.getKeySym() == "o")
    {
      p->accessHardware()->setDepthControlParameters(DSGetDepthControlPreset(DS_DEPTHCONTROL_PRESET_OFF));
      std::cout << "activated DS_DEPTHCONTROL_PRESET_OFF" << std::endl;
    }
    if(event.getKeySym() == "p")
    {
      p->accessHardware()->setDepthControlParameters(DSGetDepthControlPreset(DS_DEPTHCONTROL_PRESET_LOW));
      std::cout << "activated DS_DEPTHCONTROL_PRESET_LOW" << std::endl;
    }
    if(event.getKeySym() == "k")
    {
      p->accessHardware()->setDepthControlParameters(DSGetDepthControlPreset(DS_DEPTHCONTROL_PRESET_MEDIUM));
      std::cout << "activated DS_DEPTHCONTROL_PRESET_MEDIUM" << std::endl;
    }
    if(event.getKeySym() == "l")
    {
      p->accessHardware()->setDepthControlParameters(DSGetDepthControlPreset(DS_DEPTHCONTROL_PRESET_HIGH));
      std::cout << "activated DS_DEPTHCONTROL_PRESET_HIGH" << std::endl;
    }
    if(event.getKeySym() == "m")
    {
      p->accessHardware()->setDepthControlParameters(DSGetDepthControlPreset(DS_DEPTHCONTROL_PRESET_OPTIMIZED));
      std::cout << "activated DS_DEPTHCONTROL_PRESET_OPTIMIZED" << std::endl;
    }
  }
}
示例#8
0
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event, void* viewer_void)
{
  if ( (event.getKeySym () == "r" || event.getKeySym () == "R") && event.keyDown ())
  {
    graphRepresentation = !graphRepresentation;
  }
}
示例#9
0
void SimpleOpenNIViewer::keyboard_callback (const pcl::visualization::KeyboardEvent& event, void* cookie)
{

	unsigned char key = 0;
	

	string* message = (string*)cookie;
	cout << (*message) << " :: ";
	if (event.getKeyCode())
	{
		key = event.getKeyCode();
		//cout << "the key \'" << event.getKeyCode() << "\' (" << (int)event.getKeyCode() << ") was";
	}
	else
		;//cout << "the special key \'" << event.getKeySym() << "\' was";


	if (event.keyDown())
		;//cout << " pressed" << endl;
	else
	{
		if(key )
		{
			proc_key(key);

			//cout << " released" << endl;
			
		}

		
		

		
	}
}
示例#10
0
void keyboard_cb(const pcl::visualization::KeyboardEvent &event, void* viewer_void) {
    if (event.getKeySym () == "q" && event.keyDown ()) {
        std::cout << "Exiting." << std::endl;
        viewer.close();
    }

    if (event.getKeySym () == "s" && event.keyDown ()) {
        if (running) {
            running = false;
            std::cout << "Stopping modelling." << std::endl;
        } else {
            running = true;
            std::cout << "Starting modelling." << std::endl;
        }
    }
}
void
KeyboardEventOccurred(const pcl::visualization::KeyboardEvent &event, void * data)
{
  std::string pressed;
  pressed = event.getKeySym();
  PlySaver * s = (PlySaver*)data;
  if(event.keyDown())
  {
    if(pressed == "s")
    {
      
      pcl::PLYWriter writer;
      std::chrono::high_resolution_clock::time_point p = std::chrono::high_resolution_clock::now();
      std::string now = std::to_string((long)std::chrono::duration_cast<std::chrono::milliseconds>(p.time_since_epoch()).count());
      cv::Mat color;
      for(size_t i = 0; i < s->kinects_.size(); ++i){
      	writer.write ("cloud_"+ std::to_string(i) + "_" + now + ".ply", *(s->clouds_[i]), s->binary_, s->use_camera_);
        s->kinects_[i]->getColor(color);
      	cv::imwrite("color_" + std::to_string(i) + "_" + now + ".jpg", color);
      }
      std::cout << "saved " << "cloud and color " + now << std::endl;
    }
    if(pressed == "x")
    {
        for(auto & k : s->kinects_){
        	k->storeParameters();
        }
        std::cout << "stored calibration parameters" << std::endl;
    }
  }
}
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event, void* cookie)
{
	if (event.getKeySym () == "space" && event.keyDown ()) // Save annotation file
	{
		viewer->spinOnce();
	}
}
示例#13
0
/** \brief callback function for the PCLvisualizer */
void
keyboard_callback (const pcl::visualization::KeyboardEvent &event, void *cookie)
{
    if (event.keyDown())
    {
        switch (event.getKeyCode())
        {
        case 27:
        case (int)'q':
        case (int)'Q':
        case (int)'e':
        case (int)'E':
            cout << "Exiting program" << endl;
            quit = true;
            break;
        case (int)'s':
        case (int)'S':
            cout << "Saving volume and cloud" << endl;
            save = true;
            break;
        default:
            break;
        }
    }
}
示例#14
0
void
keyboardEventOccurred (const pcl::visualization::KeyboardEvent& event,
                       void* nothing)
{
  if (event.getKeySym () == "space" && event.keyDown ())
    next_iteration = true;
}
示例#15
0
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event, void* viewer_void) {
  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<pcl::visualization::PCLVisualizer> *> (viewer_void);
  if (event.getKeySym () == "n" && event.keyDown () && pausing)
  {
    std::cout << "n was pressed => next frame" << std::endl;
    pausing = false;
  }
}
 static void onSwitchKeyPressed(const pcl::visualization::KeyboardEvent& e, void* data)
 {
   SwitchKeyBinding* binding = (SwitchKeyBinding*) data;
   if(e.keyDown() && e.getKeySym() == binding->key)
   {
     binding->s.toggle();
   }
 }
示例#17
0
文件: demo.cpp 项目: ana-GT/golems
/**
 * @function keyboardEventOccurred
 */
void keyboardEventOccurred( const pcl::visualization::KeyboardEvent &_event,
			   void *_nothing ) {
  
  // Save cloud when pressing space
  if( _event.getKeySym() == "space" && _event.keyDown() ) {
    gProcessCloud = true;
  }
}
void
keyboardEventOccurred(const pcl::visualization::KeyboardEvent& event,
					  void* nothing)
{
	if (event.getKeySym() == "space" && event.keyDown())
		boost::this_thread::sleep(boost::posix_time::seconds(5));
   
}
示例#19
0
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event,
                            void* viewer_void) {
  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = 
		*static_cast<boost::shared_ptr<pcl::visualization::PCLVisualizer> *> (viewer_void);
	double dd = 0.01;
  if (event.getKeySym () == "a" && event.keyDown ()) (*T)(0,3) += dd;
  if (event.getKeySym () == "d" && event.keyDown ()) (*T)(0,3) -= dd;
  if (event.getKeySym () == "w" && event.keyDown ()) (*T)(1,3) += dd;
  if (event.getKeySym () == "s" && event.keyDown ()) (*T)(1,3) -= dd;
  if (event.getKeySym () == "j" && event.keyDown ()) { 
		printf("\nasdf\nasdf\nasdf\n"); 
		(*T)(2,3) += dd;
	}
  if (event.getKeySym () == "l" && event.keyDown ()) (*T)(2,3) -= dd;
  if (event.getKeySym () == "n" && event.keyDown ()) {
		T = &T1;
		printf("Working on transform 1\n");
	}
  if (event.getKeySym () == "m" && event.keyDown ()) {
		T = &T2;
		printf("Working on transform 2\n");
	}
  if (event.getKeySym () == "k" && event.keyDown ()) {
		T = &T3;
		printf("Working on transform 3\n");
	}
  if (event.getKeySym () == "i" && event.keyDown ()) seeAll = !seeAll;
}
示例#20
0
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event, void* viewer_void){
	boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<pcl::visualization::PCLVisualizer> *> (viewer_void);
	if (event.getKeySym () == "n" && event.keyDown ())
	{
		std::cout << "n was pressed => changing viewing point" << std::endl;
		viewer->removeAllPointClouds();
		//viewer->addPointCloud(cloud,"keyboardId");
	}
}
示例#21
0
/*---------------------------------------------*-
 * KEYBOARD EVENT TRACKING
 * Keys we like: (* = all PCL owned)
 * 'q' = quit*
 * 'r' = recentre the view*
 * 'c' = capture
-*---------------------------------------------*/
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event,void* viewer_void)
{
	boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<pcl::visualization::PCLVisualizer> *> (viewer_void);
	if (event.getKeySym () == "c"&&event.keyDown ())
	{
		std::cout <<"c was pressed => capturing a pointcloud"<< std::endl;
		std::string filename = "KinectCap";
		filename.append(boost::lexical_cast<std::string>(cloud_id));
		filename.append(".pcd");
		pcl::io::savePCDFileASCII (filename, *cloud);
		cloud_id++;
	}
	if (event.getKeySym() == "d" && event.keyDown())
	{
		std::cout << "d was pressed => going to detect now" << std::endl;
		do_detection = true;
	}
}
示例#22
0
 //Defining callback
 void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event,void* viewer_void)
 {

   if (event.getKeySym () == "s" && event.keyDown ())
   {
     std::cout << "s was pressed : starting" << std::endl;
     v.save_cloud();
   }
 }
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event,
                        void* viewer_void)
{
  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<pcl::visualization::PCLVisualizer> *> (viewer_void);
  if (event.getKeySym() == "n" && event.keyDown ())
  {
    pressed = true;
  }
}
示例#24
0
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event,
        void* viewer_void)
{
    static bool existSight = false;
    pcl::visualization::PCLVisualizer *viewer = static_cast<pcl::visualization::PCLVisualizer*> (viewer_void);
    if (event.getKeySym () == "f" && event.keyDown ())
    {
        //viewer->removeShape ("o1");
        //viewer->removePointCloud("p1");
        //viewer->resetCameraViewpoint("o2");
        //viewer->setCameraPosition(1,1,1,3,2,1);
        //viewer->setCameraPosition(_x--,_y,_z,x,y,z);

    }

    if (event.getKeySym () == "j" && event.keyDown ()){
        // get camera
        std::vector<pcl::visualization::Camera> cameras;
        viewer->getCameras(cameras);
        pcl::visualization::Camera &c = *cameras.begin();
        camera_info(*cameras.begin());
        // remove camera point and line of sight
        if(existSight){
            viewer->removePointCloud("camera");
            viewer->removeShape("sight");
        }
        existSight = true;
        // add camera point
        pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZRGB>);
        cloud->points.push_back(create_point(c.pos[0], c.pos[1], c.pos[2], 0, 0, 255));
        pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgbs(cloud);
        viewer->addPointCloud<pcl::PointXYZRGB> (cloud, rgbs,"camera");
        viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 30, "camera");
        // add line of sight
        pcl::PointXYZ cameraPos(c.pos[0], c.pos[1], c.pos[2]);
        pcl::PointXYZ view(c.view[0], c.view[1], c.view[2]);
        viewer->addLine(cameraPos, view, "sight");

        /*pcl::PointCloud<pcl::PointXYZ>::Ptr scene (new pcl::PointCloud<pcl::PointXYZ>());*/
        /*viewer->renderView(300, 600, scene);*/
    }
}
示例#25
0
文件: OKFlower.cpp 项目: Qworg/OKPCL
///Keyboard Event Tracking
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event,
                            void* viewer_void)
{
  boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<pcl::visualization::PCLVisualizer> *> (viewer_void);
  if (event.getKeySym () == "c" && event.keyDown ())
  {
    std::cout << "c was pressed => capturing a pointcloud" << std::endl;
    std::string filename = "KinectCap";
    filename.append(boost::lexical_cast<std::string>(cloud_id));
    filename.append(".pcd");
    pcl::io::savePCDFileASCII (filename, *cloud);
    cloud_id++;
  }

  if (event.getKeySym () == "b" && event.keyDown ())
  {
  	std::cout << "b was pressed" << std::endl;
  	if (BackgroundSub == false) 
  	{
  		//Start background subtraction
  		if (hasBackground == false) 
  		{
  			//Copy over the current cloud as a BG cloud.
  			pcl::copyPointCloud(*cloud, *bgcloud);
  			hasBackground = true;
  		}
  		BackgroundSub = true;
  	}
  	else 
  	{
  		//Stop Background Subtraction
  		BackgroundSub = false;
  	}
  }
  
  if (event.getKeySym () == "v" && event.keyDown ())
  {
  	std::cout << "v was pressed" << std::endl;
  	Voxelize = !Voxelize;
  }

}
 void
 OpenNIFrameSource::onKeyboardEvent (const pcl::visualization::KeyboardEvent & event)
 {
   // When the spacebar is pressed, trigger a frame capture
   mutex_.lock ();
   if (event.keyDown () && event.getKeySym () == "e")
   {
     active_ = false;
   }
   mutex_.unlock ();
 }
示例#27
0
void
OpenNICapture::onKeyboardEvent (const pcl::visualization::KeyboardEvent & event)
{
  // When the spacebar is pressed, trigger a frame capture
  mutex_.lock ();
  if (event.keyDown () && event.getKeySym () == "space")
  {
    trigger_ = true;
  }
  mutex_.unlock ();
}
示例#28
0
void keyboardEventOccurred (const pcl::visualization::KeyboardEvent &event,
                            void *stop_void)
{
  boost::shared_ptr<bool> stop = *static_cast<boost::shared_ptr<bool>*> (stop_void);
  if (event.getKeySym () == "s" && event.keyDown ())
  {
    *stop = ! *stop;
    if (*stop) std::cout << "Computing is now stopped!\n";
    else std::cout << "Computing commencing!\n";
  }
}
示例#29
0
void Viewer::keyboardEventOccurred( const pcl::visualization::KeyboardEvent &event, void* data ) {

	if( ( event.getKeySym() == "d" || event.getKeySym() == "D" ) && event.keyDown() ) {

		if( event.getKeySym() == "d" ) {
			selectedDepth++;
		}
		else {
			selectedDepth--;
			if( selectedDepth < 0 )
				selectedDepth = 15;
		}

		selectedDepth = selectedDepth % 16;
		std::cout << "Selected Depth " << selectedDepth << "\n";
	}
	if( ( event.getKeySym() == "v" || event.getKeySym() == "V" ) && event.keyDown() ) {

		if( event.getKeySym() == "v" ) {
			selectedViewDir++;
			if( selectedViewDir == 7 )
				selectedViewDir = -1;
		}
		else {
			selectedViewDir--;
			if( selectedViewDir < -1 )
				selectedViewDir = 6;
		}

		std::cout << "Selected View Dir " << selectedViewDir << "\n";

	}
	if( ( event.getKeySym() == "p" ) && event.keyDown() ) {
		processFrame = true;
	}
	if( ( event.getKeySym() == "s" ) && event.keyDown() ) {
		displayScene = !displayScene;
	}
	if( ( event.getKeySym() == "m" ) && event.keyDown() ) {
		displayMap = !displayMap;
	}
	if( ( event.getKeySym() == "a" ) && event.keyDown() ) {
		displayAll = !displayAll;
	}
	if( ( event.getKeySym() == "c" ) && event.keyDown() ) {
		displayCorr = !displayCorr;
	}
	if( ( event.getKeySym() == "f" ) && event.keyDown() ) {
		forceRedraw = true;
	}
}
示例#30
-13
void showModel(const pcl::visualization::KeyboardEvent &event, void* viewer_void)
{
	boost::shared_ptr<visualization::PCLVisualizer> viewer = *static_cast<boost::shared_ptr<visualization::PCLVisualizer> *> (viewer_void);
	if (event.getKeySym () == "m" && event.keyDown ())
	{
		if(show == true)
		{
			viewer->removeAllShapes();
			show = false;
			reshow = false;
		}
		else
		{
			show = true;
			reshow = true;
		}
	}
	if (event.getKeySym () == "b" && event.keyDown ())
	{
		if(skel == true)
		{
			viewer->removeAllShapes();
			skel = false;
			reshow = true;
		}
		else
		{
			viewer->removeAllShapes();
			skel = true;
			reshow = true;
		}
	}
}