boost::shared_ptr<pcl::visualization::PCLVisualizer> viewportsVis ( pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr cloud1,pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr cloud2) { // -------------------------------------------------------- // -----Open 3D viewer and add point cloud and normals----- // -------------------------------------------------------- boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer")); viewer->initCameraParameters (); int v1(0); viewer->createViewPort(0.0, 0.0, 0.5, 1.0, v1); viewer->setBackgroundColor (0.3, 0.3, 0.3, v1+1); viewer->addText("Radius: 0.01", 10, 10, "v1 text", v1); pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb1(cloud1); viewer->addPointCloud<pcl::PointXYZRGB> (cloud1, rgb1, "sample cloud1", v1); int v2(0); viewer->createViewPort(0.5, 0.0, 1.0, 1.0, v2); viewer->setBackgroundColor (0.3, 0.3, 0.3, v2+1); viewer->addText("Radius: 0.1", 10, 10, "v2 text", v2); pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb2(cloud2); viewer->addPointCloud<pcl::PointXYZRGB> (cloud2, rgb2, "sample cloud2", v2); viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "sample cloud1"); viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "sample cloud2"); viewer->addCoordinateSystem (1.0); return (viewer); }
HSVValue RenderBuffer::Get2ColorAdditive(HSVValue& hsv1, HSVValue& hsv2) { xlColor rgb; xlColor rgb1(hsv1); xlColor rgb2(hsv2); rgb.red = rgb1.red + rgb2.red; rgb.green = rgb1.green + rgb2.green; rgb.blue = rgb1.blue + rgb2.blue; return rgb.asHSV(); }
template <typename PointInT> double RejectivePointCloudCoherence<PointInT>::computeScore (const PointInT &p1,const PointInT& p2, float dist) { Eigen::Vector3f rgb1(p1.r, p1.g, p1.b); Eigen::Vector3f rgb2(p2.r, p2.g, p2.b); double d_rgb = (rgb1 - rgb2).norm () / 255.0f; // double d_spatial = (p1.getVector4fMap () - p2.getVector4fMap ()).norm (); return (1.0 / (1.0 + d_rgb + dist)); }
void CloudViewer::on_clouds_xyzrgb() { if(!prop_two_viewports) CLOG(LDEBUG) << "Set property two_viewports = 1\n"; CLOG(LTRACE) << "CloudViewer::on_clouds_xyzrgb\n"; pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud = in_cloud_xyzrgb.read(); pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud2 = in_cloud_xyzrgb2.read(); std::vector<int> indices; cloud->is_dense = false; pcl::removeNaNFromPointCloud(*cloud, *cloud, indices); std::vector<int> indices2; cloud2->is_dense = false; pcl::removeNaNFromPointCloud(*cloud2, *cloud2, indices2); viewer->removePointCloud("viewcloud",v1) ; pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb (cloud); viewer->addPointCloud<pcl::PointXYZRGB> (cloud, rgb, "viewcloud", v1); viewer->removePointCloud("viewcloud2",v2) ; pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb2 (cloud2); viewer->addPointCloud<pcl::PointXYZRGB> (cloud2, rgb2, "viewcloud2", v2); }
//! called if an event happened. bool CGUIColorSelectDialog::OnEvent(const SEvent& event) { if (isEnabled()) { switch(event.EventType) { case EET_GUI_EVENT: switch(event.GUIEvent.EventType) { case EGET_SPINBOX_CHANGED: { for ( u32 i = 0; i!= Battery.size (); ++i ) { if ( event.GUIEvent.Caller == Battery[i] ) { if (i<4) { video::SColor rgb((u32)Battery[0]->getValue(), (u32)Battery[1]->getValue(), (u32)Battery[2]->getValue(), (u32)Battery[3]->getValue()); video::SColorHSL hsl; video::SColorf rgb2(rgb); hsl.fromRGB(rgb2); Battery[4]->setValue(hsl.Hue); Battery[5]->setValue(hsl.Saturation); Battery[6]->setValue(hsl.Luminance); } else { video::SColorHSL hsl(Battery[4]->getValue(), Battery[5]->getValue(), Battery[6]->getValue()); video::SColorf rgb2; hsl.toRGB(rgb2); video::SColor rgb = rgb2.toSColor(); Battery[1]->setValue((f32)rgb.getRed()); Battery[2]->setValue((f32)rgb.getGreen()); Battery[3]->setValue((f32)rgb.getBlue()); } } } return true; } case EGET_ELEMENT_FOCUS_LOST: Dragging = false; break; case EGET_BUTTON_CLICKED: if (event.GUIEvent.Caller == CloseButton || event.GUIEvent.Caller == CancelButton) { sendCancelEvent(); remove(); return true; } else if (event.GUIEvent.Caller == OKButton) { sendSelectedEvent(); remove(); return true; } break; case EGET_LISTBOX_CHANGED: case EGET_LISTBOX_SELECTED_AGAIN: default: break; } break; case EET_MOUSE_INPUT_EVENT: switch(event.MouseInput.Event) { case EMIE_LMOUSE_PRESSED_DOWN: DragStart.X = event.MouseInput.X; DragStart.Y = event.MouseInput.Y; Dragging = true; Environment->setFocus(this); return true; case EMIE_LMOUSE_LEFT_UP: Dragging = false; Environment->removeFocus(this); return true; case EMIE_MOUSE_MOVED: if (Dragging) { // gui window should not be dragged outside its parent if (Parent) if (event.MouseInput.X < Parent->getAbsolutePosition().UpperLeftCorner.X +1 || event.MouseInput.Y < Parent->getAbsolutePosition().UpperLeftCorner.Y +1 || event.MouseInput.X > Parent->getAbsolutePosition().LowerRightCorner.X -1 || event.MouseInput.Y > Parent->getAbsolutePosition().LowerRightCorner.Y -1) return true; move(core::position2d<s32>(event.MouseInput.X - DragStart.X, event.MouseInput.Y - DragStart.Y)); DragStart.X = event.MouseInput.X; DragStart.Y = event.MouseInput.Y; return true; } default: break; } default: break; } } return IGUIElement::OnEvent(event); }