LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Display Series of Images at 60Hz in "Slideshow Mode"

Solved!
Go to solution

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 

block1.PNG

 

(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.

fig00.jpg

0 Kudos
Message 1 of 18
(3,823 Views)

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

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 18
(3,771 Views)

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

0 Kudos
Message 3 of 18
(3,763 Views)
Solution
Accepted by topic author agin

Hi agin,

 

how to load all images into memory first?

Well, use an additional loop to load all images.

Then start the current loop iterating over all images…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 18
(3,757 Views)

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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 5 of 18
(3,754 Views)

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:

block2.PNG

 

0 Kudos
Message 6 of 18
(3,735 Views)

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?


GCentral
Message 7 of 18
(3,726 Views)

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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 8 of 18
(3,694 Views)

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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 9 of 18
(3,693 Views)

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,

block3.PNG

0 Kudos
Message 10 of 18
(3,688 Views)