SceneCapture2D SceneDepth in R : Calibration

Hi,

I’m using a USceneCaptureComponent2D with the CaptureSource set to ESceneCaptureSource::SCS_SceneDepth

CameraDepth->ProjectionType = ECameraProjectionMode::Type::Perspective;
CameraDepth->FOVAngle = 90.0f;
CameraDepth->CaptureSource = ESceneCaptureSource::SCS_SceneDepth;
CameraDepth->CompositeMode = ESceneCaptureCompositeMode::SCCM_Overwrite;
CameraDepth->bCaptureOnMovement = false;
CameraDepth->bCaptureEveryFrame = true;
CameraDepth->MaxViewDistanceOverride = -1.0f;
CameraDepth->bAutoActivate = true;
CameraDepth->DetailMode = EDetailMode::DM_High;

This links to a UTextureRenderTarget2D

//create a  render target and link it to the camera
	RenderTargetDepth = CreateDefaultSubobject<UTextureRenderTarget2D>(TEXT("RenderTargetDepth"));
	RenderTargetDepth->InitAutoFormat(640, 640);
	RenderTargetDepth->AddressX = TA_Wrap;
	RenderTargetDepth->AddressY = TA_Wrap;
	RenderTargetDepth->RenderTargetFormat = RTF_RG32f;
	CameraDepth->TextureTarget = RenderTargetDepth;

At regular intervals I try to capture the data from the render target and then do some processing with OpenCV.

fTextureRenderTargetResource = RenderTargetDepth->GameThread_GetRenderTargetResource();

int32 ImageSize = TexWidth * TexHeight;
TexturePixels.AddUninitialized(ImageSize);
TexturePixels.Init(FColor(0, 0, 0, 0), ImageSize);

bool bReadSuccess = fTextureRenderTargetResource->ReadPixels(TexturePixels);

All seems to work OK. As the vehicle moves around the output image looks as it should and the red channel values vary as the depth to objects changes. Near objects show with red pixel values near 0 and distant with red = 255.

However, if I drive right up to a large object so that it fills the capture image, it seems to be rescaling in some way. As I approach the object it gets darker ( Red = 5,4,3,2…) and then when the object fills the frame it will instantly go bright red ( r=250 ).

It feels like something in the ReadPixels is scaling it.

If I follow this example and select the SceneDepth then the texture shows correctly.

Any suggestions very welcome !

Thanks
Tim.

By “scaling” I mean the color values change for a given distance. ( Not resizing )