Capture an image through player camera in C++ function and save it to disk

Hi,

I want to take a picture of my current scene in the level, and save it in disk, using scripting (preferably c++, blueprints also fine). I want this capture thing in a function so that i can call that function on a custom event. I already have custom event that calls a sample function, but i don’t know how to capture an image (png, bmp or jpeg… or any) through scripting.