- 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
How to create a matrice or array that store the water surface elevation for all frame of a video ?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
darova
2021년 7월 28일
Did you try to read only part of frames?
for i = 1:3:50
v = read(vid.Frame(i));
imshow(v)
pause(.1)
end
답변 (1개)
Shadaab Siddiqie
2021년 7월 30일
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.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!