06-26-2008 08:17 AM
06-26-2008 05:17 PM
08-15-2008 04:42 AM
Hi, was searching the forum to do exactly that: unbuffered IMAG Image streaming to disk, so thanks for the info. I had the impression I needed to use a special Win32 Open File.vi to open a file in unbuffered mode. Is this also possible with the standard VI? My second question is how best to match the 512 byte multiple write requirement. I can check the image size with the "flatten to string" trick, but this seems like a bit of a hack to me. Is there a better way to do it? Even if I use the trick, how can I increase the size to the next 512 byte multiple without copying the data?
Dixie
08-18-2008 04:22 PM
Hi Dixie,
I’m not sure exactly what you are referring to with the “512 byte multiple” write requirement. Could you please elaborate?
For information on how to stream to disk with NI-IMAQ, have a look at this DevZone article specific to NI Vision. I hope this helps 🙂
08-19-2008 02:08 AM
Hi David,
What I meant was the comment from the post above that "Unbuffered writes must be done in a multiple of the disk sector size, usually 512 bytes, so you will need to calculate the size of the image buffer and round up" . I can calculate the size, but then simply rounding up and writing more bytes with Win32 WriteFile() would lead to access violations. This means that I have two choices:
1) copy the entire image into a larger buffer of the proper size which seems very wasteful and partially negates the point of doing unbuffered writing in the first place.
or
2) split the write into two parts: first write the largest part of the data that is N*512 bytes and then copy the last few bytes that are left into a 0 padded buffer of 512 bytes and write that separately
I think both options are a bit cumbersome and I would like suggestions for a better way. If there is a way of making an IMAQ image of size N*512 from the start that would be great.
Thanks for the link, I'll have a look at the article.
Dixie
08-20-2008 03:59 PM
Hi Dixie,
I wrote that article several years ago and it needs to be updated. All of the benchmark results shown were acquired using the NI Vision AVI file writing functions, which while convenient and straightforward, are not the most efficient way to put images on disk. In the mean time we have created more efficient tools using the winapi functions for unbuffered reads and writes. The attached examples are not completely polished, but should provide a good start.
Unbuffered IO operation do need to be performed in a multiple of the disk sector size, which is usually 512 bytes. In the general case, an image is not a multiple of 512 bytes, but this really doesn't pose a problem. We can calculate the image data length and round up to the next sector. No additional copy is required. Alternately, you can manually choose an image size that is an even multiple.
In some cases you can actually achieve better throughput by copying multiple small images into one larger "mosaic" image before writing to disk. For high frame rate applications with small image sizes, the copy is less of a penalty than waiting on a synchronous IO operation to complete for each acquired image.
Thanks,
Brent
06-08-2009 08:54 AM
I'm running into the same problems: building a DVR geared for 500 fps @1.3Mpixel, based on an 8 core machine with a 9x RAID array capable of 700MB/s sustained, but only when the write chunk size is of the order of 6MB (and yes, obviously sector aligned for unbuffered disk write). And solutions based on IMAQ image to Array.vi, Replace Array Subset are sooo inefficient. Your examples in streaming.zip seem what I'm looking for, though the VIs are a little untidy.
Please keep me posted too if there is any new on this thread. Thanks!
Eneico