Ubuntu18.04中QT安装下载安装pcl和vtk以及使用过程中踩过的坑

一、先记录一下下载过程中踩过的坑

问题1:QVTKOpenGLNativeWidget和QVTKWidget

之前从来没有接触过QT中显示3D点云方面的知识,了解到可以用pcl,然后在网上各种找pcl下载的相关内容,想要在QT中显示出来,需要用到VTK,又开始找VTK的下载的相关内容。

网上大多数推荐的pcl1.9+vtk7.1,用QVTKWidget这个控件来显示,然后找了篇文章跟着流程进行下载。

但是!!!后来知道,不只要显示点云,还要显示模型。查找资料之后发现QVTKWidget这个控件不能显示模型,需要用QVTKOpenGLNativeWidget,刺激的来了,vtk8.2版本之后才有这个控件。(之后会介绍QVTKOpenGLNativeWidget和QVTKWidget的区别)

所以我现在要卸载vtk7.1,下载vtk8.2或以上版本。

问题2:关于sudo apt-get install libvtk7.1-qt libvtk7.1 libvtk7-qt-dev

之前找的下载pcl1.9+vtk7.1的帖子中,安装依赖都会安装sudo apt-get install libvtk7.1-qt libvtk7.1 libvtk7-qt-dev,我以为这个依赖是必不可少的,但是卸载之后,尝试将7.1改成8.2,结果是找不到的。

我以为这个是必不可少的,然后又下回来了,用这个依赖,然后下载的8.2版本,但是用之前的例子直接崩溃了,然后把这个依赖卸载之后就跑起来了。

所以是8.2版本不需要这个依赖了吗????

问题3:报错 error: qvtkopenglnativewidget.h: 没有那个文件或目录

将vtk8.2版本中的控件还是为QVTKWidget,需要手动提升为QVTKOpenGLNativeWidget控件。(如何提升也会在后面介绍)

提升为QVTKOpenGLNativeWidget控件之后,编辑是会报错的,找不到qvtkopenglnativewidget.h文件。

这是因为这个文件的名称是大写的QVTKOpenGLNativeWidget.h。

问题4:报错opengl版本太低

最一开始运行是会报一下错误

ERROR: In /home/li/VTK-8.2.0/Rendering/OpenGL2/vtkOpenGLRenderWindow.cxx, line 754

vtkGenericOpenGLRenderWindow (0x558f595d1520): Unable to find a valid OpenGL 3.2 or later implementation. Please update your video card driver to the latest version. If you are using Mesa please make sure you have version 11.2 or later and make sure your driver in Mesa supports OpenGL 3.2 such as llvmpipe or openswr. If you are on windows and using Microsoft remote desktop note that it only supports OpenGL 3.2 with nvidia quadro cards. You can use other remoting software such as nomachine to avoid this issue.

ERROR: In /home/li/VTK-8.2.0/Rendering/OpenGL2/vtkShaderProgram.cxx, line 446

vtkShaderProgram (0x558f595b6740): 1: #version 150

2: #ifndef GL_ES

3: #define highp

4: #define mediump

5: #define lowp

6: #endif // GL_ES

7: #define attribute in

8: #define varying out

9:

10:

11: /*=========================================================================

12:

13: Program: Visualization Toolkit

14: Module: vtkPolyDataVS.glsl

15:

16: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen

17: All rights reserved.

18: See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

19:

20: This software is distributed WITHOUT ANY WARRANTY; without even

21: the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

22: PURPOSE. See the above copyright notice for more information.

23:

24: =========================================================================*/

25:

26: in vec4 vertexMC;

27:

28: // frag position in VC

29: out vec4 vertexVCVSOutput;

30:

31: // optional normal declaration

32: //VTK::Normal::Dec

33:

34: // extra lighting parameters

35: //VTK::Light::Dec

36:

37: // Texture coordinates

38: //VTK::TCoord::Dec

39:

40: // material property values

41: //VTK::Color::Dec

42:

43: // clipping plane vars

44: //VTK::Clip::Dec

45:

46: // camera and actor matrix values

47: uniform mat4 MCDCMatrix;

48: uniform mat4 MCVCMatrix;

49:

50: // Apple Bug

51: //VTK::PrimID::Dec

52:

53: // Value raster

54: //VTK::ValuePass::Dec

55:

56: // picking support

57: //VTK::Picking::Dec

58:

59: void main()

60: {

61: //VTK::Color::Impl

62:

63: //VTK::Normal::Impl

64:

65: //VTK::TCoord::Impl

66:

67: //VTK::Clip::Impl

68:

69: //VTK::PrimID::Impl

70:

71: vertexVCVSOutput = MCVCMatrix * vertexMC;

72: gl_Position = MCDCMatrix * vertexMC;

73:

74:

75: //VTK::ValuePass::Impl

76:

77: //VTK::Light::Impl

78:

79: //VTK::Picking::Impl

80: }

ERROR: In /home/li/VTK-8.2.0/Rendering/OpenGL2/vtkShaderProgram.cxx, line 447

vtkShaderProgram (0x558f595b6740): 0:1(10): error: GLSL 1.50 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES

QOpenGLWidget允许在平台支持时使用不同的OpenGL版本和配置文件。

需要在main.cpp中的QApplication之前调用QSurfaceFormat::setDefaultFormat(QVTKOpenGLNativeWidget::defaultFormat());

相关推荐
m0_380743875 分钟前
为 OpenAI 兼容接口配置教程
开发语言·python·node.js
万邦科技Lafite1 小时前
阿里巴巴拍立淘按图搜索商品API返回值实践:提升用户购物满意度的关键措施
开发语言·api·开放api·电商开放平台·京东开放平台
小小龙学IT2 小时前
Qt 6 跨平台开发完全指南:从信号槽机制到实际项目落地
开发语言·qt
leisoo80972 小时前
ig50数据落盘ClickHousevsTimescaleDBvsDuckDB实测对比 IG50免费开源股票数据API接口
开发语言·jvm·数据库·python·json
敢敢のwings2 小时前
智元 GO-2 与 AgiBot-World 深度解读
开发语言·后端·golang
yaoxin5211233 小时前
503. Java 反射 - 编写 ServiceFactory 类
java·开发语言·python
一个帅气昵称啊3 小时前
.Net C# AI智能体开发-快速开始
开发语言·c#·.net
冬夜戏雪3 小时前
agent的trace 和eval
开发语言·前端·javascript
Sagittarius_A*4 小时前
Burst Lab | PHP 审计 13|反序列化(三):POP 链构造与 Gadget Chain 分析
开发语言·web安全·php·代码审计·反序列化
职场的momo4 小时前
11个后端与AI岗位同时开放:Java、网关、推理优化怎么匹配
java·开发语言·人工智能