04-02-2017 09:47 PM
Hi all,
I am trying to display a series of 100 images as a slideshow with a constant delay between each picture. I am trying to get the framerate of the slide show to be about 60Hz (or as fast as Labview can do). I'm not too sure how fast the fps of my slideshow is right now, but it does not look to be 60Hz (it looks much slower).
I have looked up some possible solutions to what I assume a bottleneck in opening and drawing a jpg image. One solution I read was an image buffer. I'm not too sure how to implement this. I am new to Labview, so any help in finding an elegant solution would be appreciated. Thank you!
(1): Pseudo code of what I am trying to do
for(i=0; i<Num_pictures; i++){ display(array_of_pictures[i]); wait(20ms); //this would give me a fps of 50. If I could achieve this, it would be great. }
(2) My block diagram
(3): For your reference, this is the first picture I display. I am trying to display 100 images. The white block is 10x10, and moves across the black screen (100x100) left to right until it ends up at the bottom right corner.
Solved! Go to Solution.
04-03-2017 01:13 AM
Hi agin,
why don't you follow your own pseudocode?
To improve execution speed you should load all images into memory first - before showing them in the loop!
And please use the autoindexing behaviour of loops…
04-03-2017 02:04 AM
Hi GerdW,
Thank you, I will look into how to use the auto-index. I am curious about how to load all images into memory first?
Thanks,
agin
04-03-2017 03:13 AM
04-03-2017 03:21 AM
Now you're trying to read 50 jpeg files/second from disc, which'll be hard.
Just do your first loop without wait and gather up the Image refs (index output, which should be the default output of a for loop), and you'll have your picture array. Then loop through those at 20ms and see how it turns out.
/Y
04-03-2017 05:14 PM
GerdW and Yamaeda, Thank you very much! I think I have succeeded. I have not found a way to measure the exact fps, but at 20ms delay the block moves much faster and smoother than my original code. Also, I am not sure if my block diagram here can utilize auto-indexing? I am unsure. Finally, does this block diagram make sense to an experienced Labview user? Is there any way I can make the solution better, or more intuitive. Thank you.
Pseudocode:
for(i=0; i<Num_pictures; i++){ array_of_pictures[i]=pictures_in_folder[i]; //initialize array of pictures } for(i=0; i<Num_pictures; i++){ display(array_of_pictures[i]); wait(20ms); }
For future reference to anybody, here is my block diagram:
04-03-2017 10:00 PM
agin,
A quick note: if you want to use auto-indexing, don't wire the 'N' terminal on the for loop. You already have an auto-indexed input to your first loop from the 'Folder of Pics' subVI.
The Sequence structure is unnecessary here - there is a dependency of the second loop on the first loop (it can't start until it receives the array of pictures, which is created by the first loop. If you remove it, the only possible change is that your 'Array of pictures' indicator could update after the start of the second loop, but I guess you're using it only for diagnostics?
04-07-2017 02:42 AM
Now the second loop only goes through all the pictures once, but that might be the goal. If so, just autoindex the input and you'll get 1 picture at a time. If you want to continuously loop it you'll need a while loop, use quotient and remainder to index out the picture (in this case you'll need the Index array) and a stop button.
One possible change, and i don't know if it's faster, is to only watch that array of pictures and change the shown index instead.
I don't know what the build array/merge block function is, but i doubt you'll need it. 🙂
/Y
04-07-2017 02:44 AM
For fps, drop a Tick count outside the 2nd loop and one inside, subtract the difference after the loop (use Last value mode) and divide by N, then you'll have time/frame, which should be close to 20, unless the drawing is slower than the wait.
/Y
04-07-2017 02:53 AM
Yamaeda,
Thank you for the additional suggestions. I have been working on it the past couple of days. How does this look? I also changed my pictures from .jpg to .png files. This has resulted in a significant speed up in the loop execution time.
I added the tick function in with shift registers to time the for loop in milliseconds. I am a little miffed, because if I set the wait time to 20ms, and I display 100 pictures in the for loop, then I expect a time of 2000ms. However, the tick time is about 1000ms (it varies from 1000~1080ms). It seems the time is always halved. When I change the wait time to 50ms, the tick time is ~2500ms. Thoughts?
Thank you,