[vtkusers] How to achieve the screen shot with VTK
vinmean
iamdpak at gmail.com
Thu Nov 2 00:48:06 EDT 2017
You can convert the image data into opencv Mat. Then you can save it in any
format.
cv::Mat screenshot()
{
vtkSmartPointer<vtkWindowToImageFilter> wif =
vtkSmartPointer<vtkWindowToImageFilter>::New();
wif->SetInput(renderWindow);
wif->Update();
vtkImageData* vtkRGBimage = wif->GetOutput();
int dimsRGBImage[3];
vtkRGBimage->GetDimensions(dimsRGBImage);
cv::Mat cvImageRGB (dimsRGBImage[1], dimsRGBImage[0], CV_8UC3,
vtkRGBimage->GetScalarPointer());
cv::cvtColor( cvImageRGB, cvImageRGB, CV_BGR2RGB); //convert color
cv::flip( cvImageRGB, cvImageRGB, 0); //align axis with visualizer
return cvImageRGB;
}
--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
More information about the vtkusers
mailing list