Obtaining color image and depth image from main camera

I have been attempting to extract the color and depth image from the camera of the main player. I want to get these saved as image files, so I need to get the buffers. The challenge is that I want to do this programmatically (either c++ or blueprint) so that I could capture the frame information each frame or on a certain time interval.