フィルターのクリア

How can I update values from a variable that updates constantly to a table?

2 ビュー (過去 30 日間)
ESIDOR PASHAJ
ESIDOR PASHAJ 2018 年 2 月 1 日
コメント済み: Walter Roberson 2018 年 2 月 1 日
Basically, I am looking at a video with 1200 frames. I have a function which only picks out the frames of interest (e.g. frame 61,101,175,etc...). How do I plot all the values of 'frame' on a table? (Keep in mind that the value of 'frame' updates!)
  3 件のコメント
ESIDOR PASHAJ
ESIDOR PASHAJ 2018 年 2 月 1 日
Hi Bob. That's correct. I tried to do that but instead of saving all the different values of 'frame', it only saves one (the last one). I would appreciate if you could help with some code as I'm pretty new to Matlab. Thanks
Bob Thompson
Bob Thompson 2018 年 2 月 1 日
What Walter Roberson posted is basically what I was thinking. Essentially, within your for loop for all frames you will want to have a condition such that IF an interesting frame is found THEN an index value is increased, and the data for the frame is stored as that new increased index in your storage array.
By having the index increase within the if statement it should only increase when an interesting frame is found, rather than for all frames in the movie. This will help keep your array of interesting frames short, but the increasing index will ensure the data is added to the array, rather than overwriting.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 2 月 1 日
number_of_frames - 1200;
interesting_frames = cell(number_of_frames, 1);
interesting_frame_numbers = zeros(number_of_frames, 1);
interesting_frames_found = 0;
for frame_number = 1 : number_of_frames
thisframe = ... get frame #frame_number from video object
if frame_is_interesting(thisframe)
interesting_frames_found = interesting_frames_found + 1;
interesting_frames{interesting_frames_found} = thisframe;
interesting_frame_numbers(interesting_frames_found) = frame_number;
end
end
interesting_frames(interesting_frames_found+1:end) = [];
interesting_frame_numbers(interesting_frames_found+1:end) = [];
  1 件のコメント
Walter Roberson
Walter Roberson 2018 年 2 月 1 日
Note that I pre-allocate here to the maximum size, and then shorten down to the size actually used. If you knew a maximum smaller number of "interesting" frames you could use that. The overhead per cell entry is about 104 bytes so cells are not free -- but a wasted cell is a lot more efficient than having to copy all of the data around because you were expanding an array on the fly.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by