04-23-2012 06:00 PM
Hello,
I've built a producer/consumer VI where the first loop, after some condition is met, adds an element ("trigger camera") to a queue. This element is then dequeued in the consumer loop, and the image acquisition and writing images to an avi file starts. I'm trying to acquire several movies at 700fps, and each movie lasts approximately 2secs, but after running my VI a number of times, I end up with movies with different sizes, because the while loop of the acquisition doesn't keep a constant number of iterations (see pic bellow). From what I read here in the forum, I could try to acquire a "sequence" of images instead, using a high enough buffer - I tried this and didn't work, even when I used the number of iterations of the while loop directly as the buffer number..maybe I'm not implementing it right. Another possibility would be to add an extra loop just for writing the frames to some format, avi (or binary?). Can anyone give me some advice of how I should proceed and/or maybe show me how to implement this solution?
Thanks in advance,
albergaria
04-23-2012 07:33 PM
700 fps is very fast acquisition (if you are using GiGe these must be very small frames). Since you are doing a burst of 2 seconds 1200 frames, you should probably acquire the images into an array of image spaces, then save the images to avi, I doubt that you will be able to run 700 fps encode it it as an AVI and save to disk without dropping frames (you have set up your camera as continoius grab so if you dont grab fast enough you will miss some frames. There as a modest amount of ram required for this but gigE can only stream 125MB max per seond so 250MB or ram is not too much to preallocate.
04-24-2012 05:22 PM
hi falkpl,
thanks for your reply. Yes, I'm acquiring very small frames, so in MAX I'm easily able to acquire 700fps. I tried what you suggested, the ImageToArray function, but it didn't work, movies would still be of different sizes - I even tried to save the images to a binary file (since that's supposedly faster) instead of an avi, but I have the same problem (please check pic in attach to see if I did what you meant). I tried also to substitute the while loop for a for loop that would run 1000 times (to acquire a 2s movies at 500 fps), this time it would run okay for the first time but when I tried to acquire a second movie it would give me an error:
Picture of this vi is also attached...and the vi itself. Does anyone have other ideas I could try out?
Thanks
04-25-2012 10:16 AM
I was not suggesting Imaq to Array but to use an array of imaq images (these are actually pointers to memory to store your image). You can then run and store all images in your loop an array of ~1400 imaq images. once the images are in memory I would put them into the avi between image sequences.
So you should:
1. In an array initialize 1400 imaq memory spaces (you can even set their size if you really want to preallocate the space)
2. Start your camera
3. In a loop, gram each image into the next index of the imaq image array, you might want to keep this index to see how many frames you acquired
4. After acquiring add all images in the array to your avi file (this can be done in parallel if you make a circular buffer out of your array (ie keep both a read and write index).
04-25-2012 11:00 AM
Hi falkpl,
I understand what you're suggesting and it does sound like it would work, but I don't know how to implement it (like what array functions you mean exactly, inside/outside of which loops and so on), do you think you could show me a pic of what you mean, or sketch something in the VI I attached?
Thanks again,
albergaria
04-26-2012 01:48 PM
Here is a very crude one shot implementation (sorry for the low quality of code, I spent 3 minutes implementing it, works with my laptop webcam)
04-26-2012 04:47 PM
Hi,
I've tested it with my webcam too...still not working, I get an error: "IMAQ Vision: Incompatible image size".
The picture with what I've done is in attach. Do you see any obvious problems? I've set the speed of acquisition to 30fps and used 60 images (2sec x 30fps).
Thanks
04-27-2012 08:27 AM
Did my example work?
The problem I see with youe example is that you are closing the camera acter the first itteration you will not be able to acquire, if you want to do this in a loop I would either reopen and close on each itteration or better yet, open and close out of the loop and just start grab stop grap, save to avi and repeat n times.
Where is the error thrown?
04-29-2012 07:47 AM
Hi falkpl,
So, I tried a bunch of different things (unfortunately I couldn't make your example work for me) and here's the actual situation: for some reason I don't quite understand, by using the Express Vision Acquisiton VI I now get movies all with the same size and same number of frames. Great. Now the problem is that I need to stamp 2 specific frames because in my experiment I need to be able to know what and when the program is triggering stuff (like turning a led on, triggering a solenoid valve...), and I'm doing that by using a Queue system: my producer loop, when it sends an analog signal to my valve, for example, it also adds a "message" to the Queue that is then Dequeued in my consumer loop, that writes the word "valve" to the frame it's acquiring in that moment (take a look at the picture I attached). The problem with the movies I'm acquiring now is that these "words" come in variable times and are stamped in different frames, when it should always be the same frames being stamped. Do you know of more effective ways to process images during acquisition?
Thanks,
albergaria