PCL1.8.0对应的是VTK7.0。。。VTK主要用于三维显示,所以如果出错,可以都注释掉,不影响其他函数的正常运行。
在使用计算最小包围盒时报错,且无法运行。
(1)具体报错为:
error LNK2019: 无法解析的外部符号"void __cdecl vtkRenderingOpenGL_AutoInit_Construct(void)"(?vtkRenderingOpenGL_AutoInit_Construct@@YAXXZ),该符号在函数 "public:__cdecl vtkRenderingOpenGL_ModuleInit::vtkRenderingOpenGL_ModuleInit(void)"(??0vtkRenderingOpenGL_ModuleInit@@QEAA@XZ) 中被引用
error LNK2019: 无法解析的外部符号"void __cdecl vtkRenderingOpenGL_AutoInit_Destruct(void)"(?vtkRenderingOpenGL_AutoInit_Destruct@@YAXXZ),该符号在函数 "public:__cdecl vtkRenderingOpenGL_ModuleInit::~vtkRenderingOpenGL_ModuleInit(void)"(??1vtkRenderingOpenGL_ModuleInit@@QEAA@XZ) 中被引用
(2)原因:自己的VTK中OpenGL是OpenGL2
(3)方法:参考文献:http://tieba.baidu.com/p/4551950404#93116920200l
因此把源程序中的:
#include
VTK_MODULE_INIT(vtkRenderingOpenGL);
VTK_MODULE_INIT(vtkInteractionStyle);
VTK_MODULE_INIT(vtkRenderingFreeType);
改成:
#include
//VTK_MODULE_INIT(vtkRenderingOpenGL); //自己的PCL1.8.0安装后产生的是OpenGL2,所以这一句需要改成OpenGL2.
VTK_MODULE_INIT(vtkRenderingOpenGL2); //解决方法参考【http://tieba.baidu.com/p/4551950404#93116920200l】
VTK_MODULE_INIT(vtkInteractionStyle); //外部依赖项添加opengl32.lib(我自己的还要添加vfw32.lib你的不知道要不要)
VTK_MODULE_INIT(vtkRenderingFreeType);
然后,在工程属性->链接器->输入->附加依赖项中添加:opengl32.lib和vfw32.lib
在region growing和最小包围盒时都会报错,可以运行除了显示之外的其他代码。
(1)具体报错:ERROR: In F:\PCLdon\VTK-7.0.0\Rendering\OpenGL2\vtkShaderProgram.cxx,line 370
vtkShaderProgram (00000000035E7160): ERROR:0:2: '' : extension 'GL_EXT_gpu_shader4'is not supported
ERROR: In F:\PCLdon\VTK-7.0.0\Rendering\OpenGL2\vtkOpenGLRenderWindow.cxx, line 545
vtkWin32OpenGLRenderWindow (0000000002A3F020): GL version 2.1 with the gpu_shader4 extension is not supported by your graphics driver but is required for the new OpenGL rendering backend. Please update your OpenGL driver. If you are using Mesa please make sure you have version 10.6.5 or later and make sure your driver in Mesa supports OpenGL 3.2.
ERROR: In F:\PCLdon\VTK-7.0.0\Rendering\OpenGL2\vtkOpenGLRenderWindow.cxx, line 545
vtkWin32OpenGLRenderWindow (0000000002A3F020): GL version 2.1 with the gpu_shader4 extension is not supported by your graphics driver but is required for the new OpenGL rendering backend. Please update your OpenGL driver. If you are using Mesa please make sure you have version 10.6.5 or later and make sure your driver in Mesa supports OpenGL 3.2.
ERROR: In F:\PCLdon\VTK-7.0.0\Rendering\OpenGL2\vtkShaderProgram.cxx, line 369
vtkShaderProgram (00000000035E7160): 1: #version 120
2: #extension GL_EXT_gpu_shader4 : require
3: #define highp
4: #define mediump
5: #define lowp
6:
7: /*=========================================================================
8:
9: Program: Visualization Toolkit
10: Module: vtkPolyDataFS.glsl
11:
12: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
13: All rights reserved.
14: See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
15:
16: This software is distributed WITHOUT ANY WARRANTY; without even
17: the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18: PURPOSE. See the above copyright notice for more information.
19:
20: =========================================================================*/
21: // Template for the polydata mappers fragment shader
22:
23: uniform int PrimitiveIDOffset;
24:
25: // VC position of this fragment
26: //VTK::PositionVC::Dec
27:
28: // optional color passed in from the vertex shader, vertexColor
29: uniform float opacityUniform; // the fragment opacity
30: uniform vec3 ambientColorUniform; // intensity weighted color
31: uniform vec3 diffuseColorUniform; // intensity weighted color
32: varying vec4 vertexColorVSOutput;
33:
34:
35: // optional surface normal declaration
36: //VTK::Normal::Dec
37:
38: // extra lighting parameters
39: //VTK::Light::Dec
40:
41: // Texture coordinates
42: //VTK::TCoord::Dec
43:
44: // picking support
45: //VTK::Picking::Dec
46:
47: // Depth Peeling Support
48: //VTK::DepthPeeling::Dec
49:
50: // clipping plane vars
51: //VTK::Clip::Dec
52:
53: // the output of this shader
54: //VTK::Output::Dec
55:
56: // Apple Bug
57: //VTK::PrimID::Dec
58:
59: // handle coincident offsets
60: //VTK::Coincident::Dec
61:
62: void main()
63: {
64: // Apple Bug
65: //VTK::PrimID::Impl
66:
67: //VTK::Clip::Impl
68:
69: vec3 ambientColor;
70: vec3 diffuseColor;
71: float opacity;
72: ambientColor = ambientColorUniform;
73: diffuseColor = diffuseColorUniform;
74: opacity = opacityUniform;
75: diffuseColor = vertexColorVSOutput.rgb;
76: opacity = opacity*vertexColorVSOutput.a;
77:
78: // VC position of this fragment
79: //VTK::PositionVC::Impl
80:
81: // Generate the normal if we are not passed in one
82: //VTK::Normal::Impl
83:
84: gl_FragData[0] = vec4(ambientColor + diffuseColor, opacity);
85: //VTK::Light::Impl
86:
87:
88: //VTK::TCoord::Impl
89:
90: if (gl_FragData[0].a <= 0.0)
91: {
92: discard;
93: }
94:
95: //VTK::DepthPeeling::Impl
96:
97: //VTK::Picking::Impl
98:
99: // handle coincident offsets
100: //VTK::Coincident::Impl
101: }
102:
ERROR: In F:\PCLdon\VTK-7.0.0\Rendering\OpenGL2\vtkShaderProgram.cxx, line 370
vtkShaderProgram (00000000035E7160): ERROR: 0:2: ” : extension ‘GL_EXT_gpu_shader4’ is not supported
(2)原因:这是由于VTK只支持英伟达的显卡。
(3)方法:参考文献:https://blog.csdn.net/bai_dreamer/article/details/52934470?readlog
如果出现这种问题,首先确保你有独立显卡(英伟达的)。找开显卡设置面板,将全局设置那一栏下的首先图形处理器设为高性能NVDIA处理器。