Question: How to convert and write multiple images on disk in parallel?

tldr: How to do multithreaded and parallel image conversion to PNG and save to disk?

I’m trying to convert multiple captured images to PNG and write them to disk. However, it seems like image save function is exclusively locked. So only one conversion and saving can take place at any time. Is this a desired behaviour?

My setup consists of 8x 12 mega pixel cameras. Each tacking an image roughly every 2 sec. All of them have to be written down to disk. To save space, it would be nice to convert them to PNGs instead of bitmaps. The conversion for a single image takes roughly 1 sec.

With a sequential (locked) implementation I’m out of luck. Is there another way to do the conversion and use the full power of our CPU or not?

Thank you in advance for your help.

Hi @asem,
for writing PNG files we use the libpng library. Despite the fact that libpng is thread safe it seems from the vague information I found online that libpng is not compressing multithreaded. From what I found we do not lock the save function calls from our side.

This means using PNG is not an option for you with the CVB Save function based on libpng.
You probably need to stick with BMP files. Or find an external library which is capable of a multithreaded lossless compression of image files.

If you have color cameras it is probably the best idea to save the raw image data with the bayer pattern and convert the images afterword’s in the moment, they are needed.

Hi @Sebastian,
Thanks for the fast response and for the tip regarding the color cameras.

Since I would like to also write image meta data I will try out a different library for compressing and writing them to disk. I will let you know how this ends up.