Error in vid.CurrentTime: Expected CurrentTime to be a scalar with value <= 0.

3 views (last 30 days)
I wrote a simple function to read specific frame or a sequence of frames from the video using "readFrame" instead of read since Matlab is phasing "read" out. From time to time I get the following error:
Error using read_frame_video (line 4)
Expected CurrentTime to be a scalar with value <= 0.
I know I'm trying to assign a negative value to CurrentTime property since I'm printing them out. What else could be the source of this error ?
Here's my function: it just reads either one frame or a sequence of frames same way as read used to.
function mov = read_frame_video( vid, frame )
if length(frame)==1
beg=(frame-1)/vid.FrameRate
vid.CurrentTime = beg;
mov=readFrame(vid);
return;
elseif length(frame)==2
if frame(1)<=frame(2)
beg=(frame(1)-1)/vid.FrameRate;
vid.CurrentTime = beg;
I=readFrame(vid);
mov=uint8(zeros(size(I,1),size(I,2),size(I,3),frame(2)-frame(1)+1));
mov(:,:,:,1)=I;
for i=1:frame(2)-frame(1)
mov(:,:,:,i+1)=readFrame(vid);
end
else
display('Incorrect frame indexing');
return;
end
elseif length(frame)>2
display('Array frame has more than 2 elements');
return;
end
end

Answers (0)

Categories

Find more on MATLAB Support Package for IP Cameras in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!