How to create a matrice or array that store the water surface elevation for all frame of a video ?

2 visualizaciones (últimos 30 días)
Hello everyone,
I want to save the data of the water surface elevation in a matrice or a table so that I can plot it in time domain for a specific location x or preferably create a simulation that display the water surface elevation in space with a time step equal to time between each frame of the video(i.e the frequency of my camera 60 Hz). The problem I am encountering is that I am not able to process several frame or an entire video at the same time, if i ask the code to process a list of frame it doesn't work because it's a lot of work to do for all of them the laptop is lacking of RAM. In the code I am asking Matlab to verify all column of pixel and detect all of the potential candidate point to be elected as the water surface but also this one should be continious and have certain amount freedom (i.e number of pixel allowed for the detection to move upward or downward) which represent a lot of data to process. Is there any way to do it in two step or do you have any recommendation/solution for this problem?
Please find attached my codes.
Thanking you in advance,
CJ
  3 comentarios
Cheikhna Aomar Boukhreiss
Cheikhna Aomar Boukhreiss el 28 de Jul. de 2021
I am not sure how to split with matlab but i can do it with the shell. It is possible but by splitting the video in frame it will take a enormous space in the disc. For a video of 2GB the unpacking will transform the video to a file of frames that have a size of 10GB. I have more than 1.7TB of video composed of video of 35min. The storage will represent a huge challenge but also the processing time will increase exponentially because I will be forced to use a external hardware storage.
This was the way i was doing it but i discovered that Matlab on Macintosh are able to read the frame of a video with a video as an input with the two function VideoReader() and v.read(i).
Even by doing it this way it will give me the plot of the water surface elevation for each picture. In other words the program will process each frame independantly whereas i want the code to process all frame and saving the water surface elevation for all the frame processed so that I can plot it as a simulation or time history domain.
Thankss
darova
darova el 28 de Jul. de 2021
Did you try to read only part of frames?
for i = 1:3:50
v = read(vid.Frame(i));
imshow(v)
pause(.1)
end

Iniciar sesión para comentar.

Respuestas (1)

Shadaab Siddiqie
Shadaab Siddiqie el 30 de Jul. de 2021
From my understanding you want to read a large video file. Whenever you read a video file the first call to "read" scans the entire file to accurately determine the exact location in the video file to seek to, given a specific frame index. This is what causes the large overhead of reading the first frame.
It is better to use the "readFrame" method of the "VideoReader" class. You can seek to a specific time by setting the "CurrentTime" property of the "VideoReader" object to the time that you wish to seek to. If you want to read frames sequentially from that specific point, you can set the "CurrentTime" once and call "readFrame" repeatedly. In this case, you do not have to pay a penalty for computing the total number of frames.
>> vidObj = VideoReader('filename');
>> vidObj.CurrentTime = timestamp;
>> img = vidObj.readFrame;
When you do this, the video starts decoding at the I-frame closest to the "CurrentTime". The time this takes depends on the number of key-frames in the video: if there are fewer key-frames, it takes more time. For example, if you want to read a frame at time t = 100 seconds, and the nearest key-frame is at 95 seconds, and the video is 30 fps, approximately 5*30 frames have to be decoded before getting to the frame. If you wish to read the video non-sequentially, you can keep setting the "CurrentTime" property, but the performance completely depends on the number of key-frames in the video.
Another thing that can make this process faster is to use AVI format with MJPEG compression for the videos.

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by