If your ESP32 module has enough RAM, another solution is to set the frame buffer count to 2, and then set grab mode as CAMERA_GRAB_LATEST.
Example:
config.fb_count = 2;
config.grab_mode = CAMERA_GRAB_LATEST;
This is mentioned in the ESP32CAM library