12-27-2019 11:50 PM
Hello:
I have to save a lot of data from my camera, I'm now using FFV1 CODEC to save AVI file, the file is reasonably small, and no quality loss, which is good.
My problem is the saving speed is really slow, a 131072frame 128*128 AVI file may take up to 20 minute to save to disk, I think that way too slow, can I do anything to make this process faster?
My PC is I7 7700k OC to 5.0Ghz, 16GRAM, NVME SSD.
12-28-2019 12:15 AM - edited 12-28-2019 12:28 AM
The best way I have found is to use the image to JPEG string conversion. This will create a string that is equivalent to the data in a JPEG image file. You can accumulate this as a 100000 string array and write it to disk, or you can write each one sequentially to a single text file. Only opening a single file speeds up the process quite a bit. It should be pretty fast.
The difficulty is getting the images back. Unless NI has created the inverse function recently, there is no way to directly convert the JPEG string back to an image. I believe the simplest way is to save the string to disk, then read it back as an image file. Reusing the same file over and over again keeps all the data in the disk drive buffer, so it is still really fast. There might be another trick to convert the string back efficiently, but I haven't looked at that recently.
EDIT:
Okay, did a little research. There is the IMAQ Write String, which converts to a JPEG string as described above. The other option is IMAQ Flatten Image to String. It does the same sort of thing, but maintains the image name. When you unflatten it later, it will use the same image name it had before. If you are okay with the same image names, this is probably the way to go.
I realize neither of these create an AVI, and they just store the image data efficiently. If you must have an AVI, I would consider a no compression option. That will probably save the fastest, but it will be a larger file.
Bruce
12-28-2019 12:50 AM
Thank you very much for your advice:)
My image are U8 monochrome, and I wish I can have a lossless data saved, by the way, these data will hand to my coworker using matlab to do futher process, so I do perfer the data is easy to decode/access in matlab.
And yes, I did notice if I simpliy flatten the image to a 1D array and save it using TDMS, the saving speed is much faster then even uncompressed AVI file, but as I mentioned above, I perfer a format that is easy to access.