필터 지우기
필터 지우기

Is it possible to use parallel computing with VideoReader?

조회 수: 7 (최근 30일)
Nathan Pucheril
Nathan Pucheril 2015년 7월 20일
댓글: Walter Roberson 2017년 7월 5일
I am trying to read frames from a video in a parallel fashion, possibly using parfor. But parfor states that it cannot be used do to the nature of VideoReader. Any ways around this?

답변 (1개)

Dinesh Iyer
Dinesh Iyer 2015년 7월 21일
Nathan, I am getting the following error:
Cannot call READ method after using READFRAME or HASFRAME methods or setting the CURRENTTIME property. Recreate the object to read a frame at a specific frame index.
when I execute:
vidObj = VideoReader('xylophone.mp4');
numFrames = vidObj.NumberOfFrames
parfor cnt = 1:numFrames
data = read(vidObj, cnt);
end
Are you getting the same error?
I think this is a bug that is addressed by the patch: Bug Report 1209823
Hope this helps.
  댓글 수: 6
Sam Duckerin
Sam Duckerin 2017년 7월 5일
Walter could you please give an example about how you might make a copy of a VideoReader object that would allow the frames to be read in parallel?
Walter Roberson
Walter Roberson 2017년 7월 5일
Hmmmm, it appears that VideoReader objects are handle class, and it appears that they do not have a copy semantics built in.
Ummm, it just might work to use https://www.mathworks.com/help/distcomp/parallel.pool.constant.html parallel.pool.Constant> from R2015b onwards
If you are doing a lot of reading from the same file, it might be worth using parfevalOnAll() to create the objects on each of the workers, which you would do once each time the file changed, rather than once for each parfor iteration.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by