Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

imaqReadAVIFrame retrieves blank image in certain conditions?

Solved!
Go to solution

Hi,

 

I'm having a problem where imaqReadAVIFrame(..) is retrieving blank (all black images) in some conditions.  The conditions seem to be when the height of the AVI file is equal to or greater than the width, and the height is an odd number.  The AVI files were created using the various AVI functions in NI Vision (IMAQ 4.6.1, IMAQdx 4.6.1) in an application created in CVI 2012 on a computer running Windows 7 64-bit.  The AVI files use MJPEG as the compressor, and they play back fine in an external program like VLC or Windows Media Player.  Any ideas on why this might be?  My solution for now is to not allow the creation of AVI files where the height is odd and equal to or greater than the width which isn't an annoying restriction but it does seem like there is something odd going on with imaqReadAVIFrame().  I can provide some AVI files if needed but they are 16+ MB each.

0 Kudos
Message 1 of 3
(3,103 Views)
Solution
Accepted by topic author tstanley

TStanley,

 

I have managed to reproduce what you are seeing with your .avi files in a program that I have written.  I have built a program in LabVIEW that creates an AVI file that can be saved to memory, and then am using some code from the example finder to read that created file.  I am building the file to your specifications with the height being larger than the width, as well as the height being an odd number of pixels.  Something interesting about this, however, is that there seems to be a point at which an odd height is acceptable.  Once you go below the height of 291 pixels, any odd height then works.  The files I used are written as well as read in LabVIEW, but how that is configured should be irrelevant as we are seeing the same issue.  Also, LabWindows CVI and LabVIEW call the same .dlls to actually configure the code. 

 

Looking into this, I believe this issue stems from the nature of how you are compressing the .AVI file.  If you are interested in reading a bit more about this, a useful link can be found here:

 

http://www.manifest-tech.com/media_pc/avi_formats.htm

 

However, what I believe is happening is that the MJPEG file compression format results in files being created that cannot be read by our software unless the pixel height is a multiple of 2 or the file size is under a certain limit.  In order to fix that, there is a simple solution. Compress the file with any of the other compression methods available (DV Video, Cinepak Codec, Intel IYUV codec, Microsoft RLE, Microsoft Video) and you will be able to open the file without the black screen.  This worked for me and should fix any of your issues.  Hopefully this provides you a bit of insight.

 

Regards,

 

Keith M

Applications Engineer

0 Kudos
Message 2 of 3
(3,080 Views)

Thanks for the response and the information.  I've found that MJPEG, for our application, works the best in terms of speed and quality (file size is not a huge concern Smiley Happy) so we plan on sticking with it for now.  Now that I understand the problem better, it's not a big deal to adjust the size by one pixel in the situation where height > width and height >= 291 so I'll go with that for now.

0 Kudos
Message 3 of 3
(3,070 Views)