Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to playback an AVI recorded at the start of the program execution

Hi all, I'm currently writing a VI to capture a user-specified number of frames, write them to an AVI and then play the subsequent AVI back. I have tried to do this using the AVI functions in vision utilities>files>avi. My VI writes the AVIs fine, i've had no problems playing the AVIs back from windows explorer.  However I cannot get the AVI to play back within Labview, i've tried using IMAQ AVI open and reading the frames back one by one in a for loop using IMAQ AVI read frame and then the picture display control but still no joy.

The two functions seem to clash with the write function, if I put them in the same AVI session I get the error

'Error -1074395708 occurred at IMAQ AVI Read Frame The AVI session is a write session, but this operation requires a read session.'

When i close the write session, re-open it using IMAQ open AVI and then read and display the frames, (again in a for loop) i get the error

'Error -1074396077 occurred at IMAQ AVI Read Frame.   Incompatible image type.'

I used IMAQ create to input the image into the AVI read function. According to the help IMAQ AVI read frame can read grayscale (u8) and RGB (u32), but even when the image type is set to one of these two it still doesn't work. The camera I'm using is a Sentech SC-1000, which is black and white so I'm surprised the grayscale option doesn't work.

Can anyone tell me what sort of image IMAQ AVI read frame requires? Or how to turn a sequence (acquired using IMAQsequence) into an AVI?

Any help would be very much appreciated - thanks:)

0 Kudos
Message 1 of 5
(4,253 Views)
JenRi -

It sounds like you're on the right track.  You are correct that you can't write to and read from an .avi file in the same session, so you will need two separate sessions.

The easiest way to make sure you're passing in the right image type to IMAQ AVI Read Frame is to call IMAQ AVI Get Info after opening the session and using the Image Type output to create a new image.

If the problem is that the AVI has RGB (u32) images and you were expecting grayscale (u8) images, I have a few more questions: can you post your code?  And what version of the NI Vision Development Module are you using?

Hope these help!

Greg Stoll
Vision R&D
National Instruments
Greg Stoll
LabVIEW R&D
0 Kudos
Message 2 of 5
(4,246 Views)
JenRi -

It sounds like you're on the right track.  You are correct that you can't write to and read from an .avi file in the same session, so you will need two separate sessions.

The easiest way to make sure you're passing in the right image type to IMAQ AVI Read Frame is to call IMAQ AVI Get Info after opening the session and using the Image Type output to create a new image.

If the problem is that the AVI has RGB (u32) images and you were expecting grayscale (u8) images, I have a few more questions: can you post your code?  And what version of the NI Vision Development Module are you using?

Hope these help!

Greg Stoll
Vision R&D
National Instruments

Thanks, I'm using NI vision 7.1 and I thought I had posted my code the first time but i'll try again. Some of the code will seem unecessary but thats because originally the VI also used IMAQsequence, which doesn't work unless all the images have different names, i'm  leaving it in for now as I might go back to it later.

I added in the IMAQ AVI Get Info AVI and now I get a different error

'Error -1074395995 occurred at IMAQ AVI Open. File not found. Possible reason(s): IMAQ Vision:  (Hex 0xBFF604A5) File not found.'

Does this mean I might need a time delay or sequence structure? And the file is definitely there as I checked and the filenames are also identical

And it is still claiming that the image type is incompatible, despite having done what you suggested....

Thanks for your help and I have attached my code for your inspection!

JenRi
0 Kudos
Message 3 of 5
(4,233 Views)
JenRi -

Since there's no data dependencies in your code, LabVIEW will try to run them more or less simultaneously.  So yes, a sequence structure will work (putting the writing code in the first frame and the reading code in the second frame), or you can connect the Error Out of the IMAQ AVI Close to the Error In of the IMAQ AVI Open, thus setting up a data dependency.

As for writing U8 images to an AVI, prior to Vision 7.1.1 U8 images were written as RGB32 images.  The free Vision 7.1.1 update allows them to be written as U8 images, resulting in a bit of space savings.  Unfortunately, that update doesn't seem to be posted online so probably your best bet would be to contact your sales representative and ask for it.

Even if you can't get the update for some reason, things should still work - you can just cast the RGB32 image coming out of the AVI file to U8.

Let me know how it goes!

Greg Stoll
Vision R&D
National Instruments
Greg Stoll
LabVIEW R&D
0 Kudos
Message 4 of 5
(4,223 Views)
I added a sequence structure for the read and write part and changed the image type to RGB and all the errors i mentioned in previous posts seemed to have gone so thats great - thanks to you. Unfortunately its now complaining about the frame numbers, so looks like i have a bit more work to to yet!

Thanks for your help, i think the original problem is solved:-)
0 Kudos
Message 5 of 5
(4,201 Views)