Embedding PCL Viewer on a Qt GUI Main Window

你说的曾经没有我的故事 提交于 2019-11-29 15:10:44

问题


I am trying to develop a user interface using QtCreator on a Windows 7 64-bit machine. This user interface will be deployed on a 32-bit Windows 7 machine, and will control a projector and a camera for a structured-light application. For reasons beyond my control (compatibility with camera and projector's APIs), I will use the MS VS 2010 32bit compiler for this. After a couple of weeks trying to have everything I need working together (Qt 4.8.4, QtCreator and Point Cloud Library), I am now facing a slight problem.

Is there a way that I can embed the PCL Point Cloud Viewer inside my main Qt GUI window? The problem is that when I use the PCL viewer, it brings up a separate window. I want this window to be embedded inside my main window, and I want to still be able to interact with it (rotate, pan, zoom, etc.).

As you may be able to tell from my post, I am a newbie on Qt/PCL/etc., so any example with minimal code to do this would be greatly appreciated. I have done weeks of research on this and I have not been able to find a solution, although I get the impression that a Qt Widget might be the way to go.


回答1:


You can simply use PCL's PCLVisualizer, which is extensively described here, via the QVTKWidget. This is the setup I'm currently running. So you would end up doing something along the lines of the following (pseudo-)code:

In your header:

class PointCloudWidget : public QVTKWidget
{
    //Whatever comes before (constructor, methods, etc.)

private:

    pcl::visualization::PCLVisualizer m_visualizer;
};

And in your cpp:

PointCloudWidget::PointCloudWidget(QWidget *parent) : QVTKWidget(parent)
{
    this->SetRenderWindow(m_visualizer.getRenderWindow());
}

You can then use the visualizer to achieve the same functionality as the PCL viewer has.




回答2:


Look at the kind of minimal code I put here (PCL Viewer with Qt GUI minimal code). There are some redundancies, but the code I believe is pretty straightforward.

The main idea is to put the files in the one folder and start project from CMakeLists.txt (Qt cmake wizard).

I use build directory inside project dir. (this is important, because in pclwindow.cpp I hardcoded the path to the generated file #include "build/ui_pclwindow.h"

If app builds, but crashes you'll probably need to add some dependencies (e.g. dll files on Win platform)

I hope it will give you fast and simple start!



来源:https://stackoverflow.com/questions/16065984/embedding-pcl-viewer-on-a-qt-gui-main-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!