I have a USceneCaptureComponent2d attached to an actor that I am programatically controlling which is set to NOT capture every frame and NOT capture on movement. I have a non-scene component that holds a pointer to this USceneCaptureComponent. Periodically I would like my component to call CaptureScene(), and then read the resultant pixel data from the TextureRenderTarget2D. Ideally, the pixel data would be formatted as a TArray(uint8) of grayscale values. Currently, I have the capture component set to full desaturation and am using a threaded FRHI ReadSurfaceData request to get the data out as a TArray(FColor) and then converting manually to to a byte array of grayscale values by doing GrayArray.Add(pixel.R) for every pixel in the FColor array. This is obviously very slow and doesn’t scale well for my application. Is there a way to get a grayscale byte array directly from a render target so I can do things like memcopys on the buffer to copy the data around efficiently?
I have the same issue…
Could someone please help us?
I have to get a byte array from a render target in C++, so that I can send the “picture” to other device using a sort of TCP protocol