LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Record and playback video in slow motion

Hi

 

I am COMPLETELY new to labview and am having some trouble.

I would like to record a video using a USB camera and be able to play it back on multiple occasions at different speeds.

The file attached is what I have so far. The signal generated at the top is controlling the equipment I am recording. Currently, I am saving the video to the hard drive in AVI format and retreiving it to watch again. However I would like to be able to play this at different speeds and be able to pause/rewind. Is this possible? I would also prefer not to have to save and retreive the file and much prefer it to stay within the system memory.

 

Thanks in Advance

 

Alex

0 Kudos
Message 1 of 6
(3,267 Views)

Hi!

 

In your program you set the "frames per second" input on the "Init AVI" Vi to 50. If your camera is set up to acquire 50 frames/sec this is ok. But your "playback" loop will (as it is) run at much higher rate, since it is not limited in speed. You need to control the playback rate with a delay function (maybe the Wait (ms)-vi). If the acq-rate is 50Hz, you need to limit the playback loop to 50 iterations per sec -> 20ms delay.

Set the delay to a lower value for a faster playback, or higher value for slow motion playback.

 

If you decide to use the AVI-vi:s you need to associate the video with a file. You can however keep the frames in memory by simply create an array of images and write to them instead of to the AVI-file. Modify your code like this:

 

1) Create an array of IMAQ-images, Note that you need diffrent images on each index in the array.

 

2) In your acqure-loop. Instead of writing to the AVI-file, write to the array at index "i". Note that you must modify this image, so retreive the image-ref at array index "i", then modify it by writing to it, the put the image-ref back in the array.

 

3) In your playback loop.Read image-ref to display from the array by index "i".

 

Done

 

Best regards

 

Dan

Message 2 of 6
(3,243 Views)

Hi Dan! Thank you very much for your reply! The quality of the plaback video is now much better quality and I am now able to choose different playback speeds depending on the delay!

 

Could you please explain the process of creating an array, inputting the video and then retreiving it again.

It would be of great use if I didn't have to save to AVI!

 

Thanks again!

 

Alex

0 Kudos
Message 3 of 6
(3,217 Views)

Hi!

 

I described the steps you needed in the last post. However, since I was curious on how to achieve this in the simplest way. I wrote the complete program for you. Have a look at the snippet below (Save the image to file and then drag it on to an empty labVIEW block diagram).

 

Feel free to use it as a base for your program if you find it suitable.

 

Grab frames to array of images.png

 

I didn't have time to put all the comment in, but you might want to fill in the blanks.

 

Notes

  • Change the array size in the "init case".
  • The camera must be selected before the vi is started.
  • Don't press "play" if you are currently recording. Press "stop" first.

 

Best regards

 

Dan

 

Best regards

0 Kudos
Message 4 of 6
(3,200 Views)

Hi Dan

 

Is there a way to alter the frames per second in this program?

 

Thanks again

 

Alex

0 Kudos
Message 5 of 6
(3,130 Views)

Yes, you can change the rate by changing the timeout for the event structure. please see the timeout case.

 

The "speed" Control is connected to this function. You can simply select playback speed on the front panel!

 

//Dan

0 Kudos
Message 6 of 6
(3,119 Views)