Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Real time saving and processing with IMAQ

Hi,

My application requires

1. First thread to save all acquired images (4 MB - max size of an image) at a frame rate of 30 fps on to the hard disk. No frame can be missed. A maximum of 20-30 sec worth images needs to be saved.
2. Parallel thread to process the acquired images (frames can be missed, just the last acquired frame can be processed everytime) and display them. This is necessary for us to get an idea of what exactly we are saving.

Currently I am using ring-buffered acquisition with IMAQ extract buffer. However the images are overwritten and the frames are lost because of saving the images to the disk.

To overcome the above problem I am thinking of using IMAQ Sequence but in this case I think I wont be able to perform the second process of processing the last acquired image and displaying it.

Kindly let me know if I can get the reference for the last acquired image during a sequence acquisition? Or let me know if there is a better way of doing this.

Thanks,
Aarthi



0 Kudos
Message 1 of 7
(4,174 Views)

Hi Aarthi,

You should be able to use the IMAQ Get Buffer VI to retrieve the image of your choice.  I may not fully understand your question, so it might be helpful if you chould attach a small portion of your code so that I can take a look at it.  Thanks.

Chris

Applications Engineer

National Instruments

0 Kudos
Message 2 of 7
(4,155 Views)
Hi Chris,

Thanks for replying. Actually i had alreadyy used the Get Buffer vi, however i face a completely different problem now. let me restate my question.

I just wish to save 20-30 sec worth of images at frame rate 30fps. Simultaneously I need to display some of those acquired images (Obviously I cant display all acquired images becasue the processing of images before display takes a long time)

I have two for loops.. One which uses Get Buffer vi to save the image references in a one element queue. The second loop reads this queue and processes and display the images. This loop reads whatever was the last entered image reference (As I said before its fine if frames are missed during display).

I have attached a sample vi which roughly shows what i am trying to do.

The problem now is - The horizontal synchronization signal and my analog out are not syynchronized. This problem occurs only in ONE-SHOT acquisition. If I try CONTINUOUS acquisition this problem disappears. I definitely want to use one-shot acquisition becasue I want to avoid the risk of overwriting the buffers after acquiring the images that i require.

Let me know your suggestion.

Thanks,
Aarthi


0 Kudos
Message 3 of 7
(4,142 Views)

Are you saying each image is 4 MB in size?  If so, I doubt you can stream 30 fps to disk.  That would be 120 MB/s to disk!!  I think that exceeds the capability of most disk drives.

You won't be able to store all the images in memory at one time, unless you have 4 GB of memory available.

You might want to try compressing the images on the fly and keeping them in memory.  The newer vision tools (v8 and above) include flatten image to string.  If you select JPEG compression, it will reduce the image size considerably, and you can store the string in memory for saving later, or stream it to disk.  I'm not sure if it would keep up with your acquisition, but if you create a large buffer you might do alright.

My advice: use a ring buffered acquisition with the most frames that you can fit in memory at one time.  Figure out the best way to store the images while processing them fast enough that you won't overwrite the images.  You probably should minimize the processing you are doing during the acquisition, since that will reduce the CPU availability for compressing and storing the images.  Maybe just process one image a second and leave the rest of the CPU time for storage.

By the way, you can find out the last image acquired during a sequence.  You just have to dig into the low level code for the sequence and duplicate it.  Essential, a sequence is acquired the same way as a ring buffer, but you only go through the buffer once (one-shot).

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 4 of 7
(4,141 Views)
Hi Bruce,

Thanks for the reply. I do have 4 GB of memory. So as of now I am just thinking of storing the images on to the memmory and saving them acter acquisition is complete. I will be definitely thinking of alternative ways to compress and store images in future.

I will look in to the lower level code of the sequence vi.

The problem I am facing right now is completely different. it has got something to do with one-stop and continuous acquisition that I have previous message to Chris. Let me know if you have some suggestions on that.

Thanks & Regards,
Aarthi

0 Kudos
Message 5 of 7
(4,136 Views)
Hi,

The earlier post for posted by me from my lab mate's (DAQ_nubee) login by mistakae. Sorry about that.

Regards,
Aarthi
0 Kudos
Message 6 of 7
(4,132 Views)

Aarthi,

What type of camera and framegrabber are you using?  Also, do you have a more complete piece of code that I could look at?  The parameters that are being passed into the VIs could have an effect on the synchronization problems you are seeing.

-Chris

Applications Engineer

National Instruments

0 Kudos
Message 7 of 7
(4,099 Views)