How to read from a RTF_R32f rendertarget

Hello everyone,
I’m having a bit of a problem with getting the data out of a TextureRenderTarget2D with the format RTF_R32f. I can’t find a perfect match for that problem in the methods of any related class and when I do

    TArray<FColor> Data;
    	auto DepthRenderTargetResource = DepthRenderTarget->GameThread_GetRenderTargetResource()->GetTextureRenderTarget2DResource();
    	DepthRenderTargetResource->ReadPixels(Data);
    	UE_LOG(LogTemp, Display, TEXT("some point: %f"), *reinterpret_cast<float*>(&Data[1000]) );

in the Tick method of an actor with

UPROPERTY(EditAnywhere)
		UTextureRenderTarget2D* DepthRenderTarget;

in the header I get an exception. When setting breakpoints it seems to crash at the line with the ReadPixels(Data).
I would just like to have a virtual depth camera in Unreal without the RGB luggage.

Not sure if it’s the canonical way but I succeeded with the following code:

for (auto& Color : Data) {
    auto depth = Color.FromRGBE().R;
    // ...
}

Hey I am running into this issue as well!

I tried to use your solution, but I am confused on how you managed to get anything in your data code based on what I have read here. To my knowledge you are doing:

//start
TArray Data;
auto DepthRenderTargetResource = DepthRenderTarget->GameThread_GetRenderTargetResource()->GetTextureRenderTarget2DResource();

DepthRenderTargetResource->ReadPixels(Data);

for (auto& Color : Data) {
auto depth = Color.FromRGBE().R;
// …
}

//end

But I also get an exception thrown when I try to run ReadPixels.

I am curious what portion I am missing, because I have been stuck on this for hours now.

Thank you ahead of time!

Set CaptureSource = ESceneCaptureSource::SCS_SceneColorSceneDepth;
Set RenderTargetFormat = ETextureRenderTargetFormat::RTF_RGBA32f;
Use Color.A As Depth