OV5642 producing scrambled pictures


I’m using an OV5642 camera to take some still jpeg images using the C++ arduino example code and I’m often getting scrambled pictures like the second one below. You can see in the first image it took a normal picture but then it was 20 minutes later that it took the scrambled image and you can see it retained some information as it has the same person in the same position in both pictures. Is anyone aware of any settings on the OV5642 that would help prevent these scrambled images. It almost looks like the picture buffer isn’t being cleared properly between photos but the buffer in my code is 100% being cleared and if it wasn’t, I think it’d just result in a corrupt file anyway, not a viewable picture like this. So is this internal to the camera? Any suggestions are appreciated.