The right way to save image to external SD card

Hi,

I am writing a program to capture object by OpenMV camera. After the object is detected, I use image.save() to save image into external SD card. After I remount the OpenMV storage, I found the image is corrupted (refer to the attached file).

I wonder what the right approach to save the image file is. I.e. what should I do after executing the .save() method?

I also tried to add time.sleep(1) for the buffer flushing but it didn’t work.

Thanks.

864918050725124-210420-185657-388858

I checked my code carefully and finally found the reason!

It is incorrectly use sensor.dealloc_extra_fb() to deallocate the memory before saving the image to file, which caused some memory are overwritten but still being saved to file.

It is not the file corrupted but the content is.