02-11-2009 12:08 AM
Hi,
I am very new to Labview but I have to use it for my project. The aim to is display different images on the monitor at very fast speed of about 50 to 60Hz. I am using the vision IMAQ function for my program. And the program works roughly like this:
IMAQ WindSetup-> IMAQ Create-> IMAQ ReadFile-> IMAQ WindDraw -> IMAQ Dispose-> IMAQ WindClose
This will run in a while loop with IMAQ ReadFile fetching new files to read from a folder.
The problem I faced is that when I set the speed at a fast rate(ie. short exposure time for each image) the image will not be able to follow the actual specified speed/exposure time. It will refresh at a fast rate and later slows down gradually and reached a complete stop at 1 moment. After a few seconds, the image will refresh again with high speed and slow down again.
So after that I opened up task manager and checked the CPU usage and realised that the CPU usage is a lot, at about 80% from the normal 10-20%. Then it will increase to 100% CPU usage where that's the point the program stop and later drop back to around 80%. So I gathered that this has something to do with the CPU memory usage or something.
I have also looked at the profile performance and memory and realise IMAQ ReadFile and IMAQ WindDraw takes the longest to run for each loop. I can think of putting IMAQ ReadFile outside the loop and storing the readout image into an array. However I cannot avoid having to loop IMAQ WindDraw.
Can anyone help me on this? How can I avoid the problem on the intensive CPU usage and long runtime of the IMAQ WindDraw as I do need the speed to be accurate and I do need the speed to be near to 60Hz. Thanks.
I have attached the vi and also the results from the profile performance and memory
Cheers
02-17-2009 02:10 AM
Hi Weixuan,
I recomend taking an unneccesarily process out if the loop for example: IMAQ Create, IMAQ Read File, IMAQ WindSetup, IMAQ Dispose, IMAQ WIndClose.
You may refer to my attached screenshot to see how I modify your program.
I can achieve the same task at 17ms interval with <30% CPU consumption.
Regards, Kate
02-19-2009 01:56 AM
Thanks Kate for your reply and help. I've tried your suggestion and it helped to speed up the display speed. However, I realised that you read the image file twice and send it into the loop. I am using 2 image as an example and in my final aim of the project is to have quite a number of different images to be displayed. There's another issue when I tested out with loading the images. When I tried to load an image of a big dimension for eg. 1920x1200 pixels the speed is slower as compared to a smaller image eg. 400x200 pixels. Does it have anything to do with the efficiency of the program or is that the limitation of IMAQ WindDraw? Is there any other function other than IMAQ WindDraw to display image on the monitor?
Cheers,
Weixuan
02-19-2009 08:16 PM
Hi Weixuan,
Even you have a lot of images, but you still need to read them outside the loop, and write an algorithm to select image reference to show up, since IMAQ read file is the slowest process in your task.
Using larger image will slow down the process for sure.
The VI I show you is the most optimize I can think of so far.
Therefore, if it's still not fast enough, you should:
1. Change to faster PC.
2. Change from IMAQ Windraw to just show an image on Image Display.
Regards, Kate