How to estimate particle velocity with video input not image?

classic Classic list List threaded Threaded
2 messages Options
Hamed Hamed
Reply | Threaded
Open this post in threaded view
|

How to estimate particle velocity with video input not image?

I'm new to PTV. I have a video file and also a text file of sensor data (accelerometer) of a particle movement (angular and linear movement) through a channel. If I want to use PIVlab can I have video or text file input? or PIVlab get just images? What do you suggest? Do I need to capture image frames of the video file ?
Thank in advance for any help
Collier Collier
Reply | Threaded
Open this post in threaded view
|

Re: How to estimate particle velocity with video input not image?

As far as I know, you must first extract the frames you are interested in then feed these into PIVLab. The PIV analysis generally works by correlating a pair of images to find the most likely displacement of bright points within the image (both image noise and particles). You can use MATLAB to pull out all the frames from your video I have included results from a quick google search:
https://www.youtube.com/watch?v=AI-1ch6CHkI
https://www.mathworks.com/matlabcentral/answers/48797-how-to-extract-frames-of-a-video.

A tip if you have many frames in your video, pad the frame numbering with zeros to ensure that the files are ordered correctly when PIVLab imports them. This is shown in my example code below as '%04d'. This means the file name will be padded with zeros and 4 total digits displayed since I had over 1000 frames to extract. You can modify this to whatever works for you.

My Example (works but I am sure this is not optimal):

a = VideoReader('F:\PIV_Files\MovieFileName.mp4');
for img = 1:a.NumberOfFrames
    filename = sprintf('Frame_%04d.bmp', img);
    b = read(a, img);
    imwrite(b, filename);
end

Note: According to MATLAB R2016, they are phasing out both .NumberOfFrames and read, but I did not get their replacements to work easily, so I left it in this form. I hope this helps you or someone!