How to obtain the depth map of a scene in VTK?

What I obtained using the following method is clearly incorrect

	auto windowToImageFilter = vtkSmartPointer<vtkWindowToImageFilter>::New();
	windowToImageFilter->SetInputBufferTypeToZBuffer();
	windowToImageFilter->SetInput(window);
	windowToImageFilter->Update();

Hello @Lincac

You can easily get the Z buffer data like this:

vtkNew<vtkFloatArray> depthValues;
int* size = window->GetSize();
window->GetZBufferData(0, size[0] - 1, 0, size[1] - 1, depthValues);