[vtkusers] Can't read image with VTK
Franks
masterwangzx at gmail.com
Sun Oct 28 02:25:20 EDT 2018
Hi,
I have a question when I use VTK with CLion. I'm using VTK 8.1 in c++ build
with cmake3.12. When I read image by using class *"vtkMetaImageReader"(other
class inheriting "vtkImageReader2" have the same problem*), the program
crash with "*Process finished with exit code -1073741515
(0xC0000135)*"(display in clion). But class "vtkStructuredPointsReader" can
run correctly. I think it may lack some libraries related with image. Now, I
have no idea with this problem.
CMakeLists.txt
/cmake_minimum_required(VERSION 3.12)
project(vtk_demo)
set(CMAKE_CXX_STANDARD 14)
aux_source_directory(src SOURCE_FILES)
set(RES_FILES res/brain.mhd res/brain.raw)
include_directories(include)
#vtk
set(VTK_DIR G:\\VTK)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
add_executable(vtk_demo ${SOURCE_FILES} ${RES_FILES})
target_link_libraries(vtk_demo ${VTK_LIBRARIES})/
main.cpp
/#include <vtkSmartPointer.h>
#include <vtkImageViewer2.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkMetaImageReader.h>
int main(int argc, char* argv[])
{
auto reader =
vtkSmartPointer<vtkMetaImageReader>::New();
reader->SetFileName("../res/brain.mhd");
reader->Update();
auto imageViewer =
vtkSmartPointer<vtkImageViewer2>::New();
imageViewer->SetInputConnection(reader->GetOutputPort());
auto renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
imageViewer->SetupInteractor(renderWindowInteractor);
imageViewer->SetColorLevel(500);
imageViewer->SetColorWindow(2000);
imageViewer->SetSlice(40);
imageViewer->SetSliceOrientationToXY();
imageViewer->Render();
imageViewer->GetRenderer()->SetBackground(1.0, 1.0, 1.0);
imageViewer->SetSize(640, 480);
imageViewer->GetRenderWindow()->SetWindowName("DisplayImageExample");
renderWindowInteractor->Start();
return 0;
}
/
Thank you very much in advance,
Best regards,
Franks
--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
More information about the vtkusers
mailing list