Created
August 2, 2013 07:41
-
-
Save suplo/6138142 to your computer and use it in GitHub Desktop.
PCL Visualizer MFC (not work?)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace cv; | |
typedef pcl::PointXYZRGBA PointT; | |
typedef pcl::PointCloud<PointT> PointCloudT; | |
// PCL viewer // | |
pcl::visualization::PCLVisualizer viewer("PCL Viewer" , false); | |
vtkRenderer* ren1; | |
vtkRenderWindow* renwin; | |
vtkRenderWindowInteractor* iren; | |
BOOL CHelloworldDlg::OnInitDialog() | |
{ viewer.setBackgroundColor (0, 0, 0); | |
viewer.addCoordinateSystem (1.0f); | |
CStatic *pclStatic = new CStatic(); | |
LPRECT rect = new CRect; | |
pclStatic = (CStatic*)GetDlgItem(IDC_STATIC1); | |
renwin = viewer.getRenderWindow(); | |
renwin->SetParentId(pclStatic->m_hWnd); | |
iren = vtkRenderWindowInteractor::New(); | |
pclStatic->GetWindowRect(rect); | |
renwin->SetSize(rect->right-rect->left, rect->bottom-rect->top); | |
renwin->SetPosition(0,0); | |
iren->SetRenderWindow(renwin); | |
renwin->Render(); | |
return TRUE; // return TRUE unless you set the focus to a control | |
} | |
void cloud_cb_ (const PointCloudT::ConstPtr &callback_cloud, PointCloudT *cloud_object) | |
{ | |
//pcl::copyPointCloud<PointT, PointT>(*callback_cloud, *cloud_object); | |
if (!viewer.wasStopped()) | |
{ | |
pcl::visualization::PointCloudColorHandlerRGBField<PointT> rgb(callback_cloud); | |
if (!viewer.updatePointCloud(callback_cloud, rgb, "input_cloud")) | |
{ | |
viewer.addPointCloud<PointT>(callback_cloud, rgb, "input_cloud"); | |
} | |
iren->Render(); | |
} | |
} | |
void CHelloworldDlg::OnBnClickedButton3() | |
{ | |
// TODO: Add your control notification handler code here | |
PointCloudT cloud_obj; | |
pcl::Grabber *interface_ = new pcl::OpenNIGrabber(); | |
boost::function<void(const PointCloudT::ConstPtr&)> f = boost::bind(&cloud_cb_, _1, &cloud_obj); | |
boost::signals2::connection c = interface_->registerCallback(f); | |
interface_->start(); | |
while (!viewer.wasStopped()) | |
{ | |
boost::this_thread::sleep(boost::posix_time::seconds(1)); | |
viewer.spin(); | |
//viewer.spinOnce(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment