MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / initGUI

Method initGUI

apps/src/pcd_select_object_plane.cpp:551–597  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

549
550 /////////////////////////////////////////////////////////////////////////
551 void
552 initGUI()
553 {
554 cloud_viewer_.reset(new visualization::PCLVisualizer("PointCloud"));
555
556 if (cloud_->isOrganized()) {
557 // If the dataset is organized, and has RGB data, create an image viewer
558 std::vector<pcl::PCLPointField> fields;
559 int rgba_index = -1;
560 rgba_index = getFieldIndex<PointT>("rgba", fields);
561
562 if (rgba_index >= 0) {
563 image_viewer_.reset(new visualization::ImageViewer("RGB PCLImage"));
564
565 image_viewer_->registerMouseCallback(&ObjectSelection::mouse_callback, *this);
566 image_viewer_->registerKeyboardCallback(&ObjectSelection::keyboard_callback,
567 *this);
568 image_viewer_->setPosition(cloud_->width, 0);
569 image_viewer_->setSize(cloud_->width, cloud_->height);
570
571 int poff = fields[rgba_index].offset;
572 // BGR to RGB
573 rgb_data_ = new unsigned char[cloud_->width * cloud_->height * 3];
574 for (std::uint32_t i = 0; i < cloud_->width * cloud_->height; ++i) {
575 RGB rgb;
576 memcpy(&rgb,
577 reinterpret_cast<unsigned char*>(&(*cloud_)[i]) + poff,
578 sizeof(rgb));
579
580 rgb_data_[i * 3 + 0] = rgb.r;
581 rgb_data_[i * 3 + 1] = rgb.g;
582 rgb_data_[i * 3 + 2] = rgb.b;
583 }
584 image_viewer_->showRGBImage(rgb_data_, cloud_->width, cloud_->height);
585 }
586 cloud_viewer_->setSize(cloud_->width, cloud_->height);
587 }
588
589 cloud_viewer_->registerMouseCallback(&ObjectSelection::mouse_callback, *this);
590 cloud_viewer_->registerKeyboardCallback(&ObjectSelection::keyboard_callback, *this);
591 cloud_viewer_->registerPointPickingCallback(&ObjectSelection::pp_callback, *this);
592 cloud_viewer_->setPosition(0, 0);
593
594 cloud_viewer_->addPointCloud(cloud_, "scene");
595 cloud_viewer_->resetCameraViewpoint("scene");
596 cloud_viewer_->addCoordinateSystem(0.1, 0, 0, 0, "global");
597 }
598
599 /////////////////////////////////////////////////////////////////////////
600 bool

Callers 1

mainFunction · 0.80

Calls 11

isOrganizedMethod · 0.80
resetCameraViewpointMethod · 0.80
addCoordinateSystemMethod · 0.80
resetMethod · 0.45
registerMouseCallbackMethod · 0.45
setPositionMethod · 0.45
setSizeMethod · 0.45
showRGBImageMethod · 0.45
addPointCloudMethod · 0.45

Tested by

no test coverage detected