fileDatastore read: Index exceeds the number of array elements (0).

조회 수: 1 (최근 30일)
I am attempting to set up a fileDatastore (vds, for video datastore) that will send 1 video file at a time to a modified version of the MotionBasedMultiObjectTrackingExamples.m. I have the following code:
loc = "C:\Users\Christine Deer\Downloads\02242021-SV\02242021-SV";
vds = fileDatastore(loc, 'ReadFcn', @videoReader, 'IncludeSubfolders', ...
true, 'FileExtensions', '.mp4')
data=read(vds);
function v = videoReader(file)
v = videoReader(file);
end
Which generates the following output:
vds =
FileDatastore with properties:
Files: {
' ...\Camera 1 - 192.168.0.105 (FLIR A400) - 14-20210216-210329.mp4';
' ...\Camera 1 - 192.168.0.105 (FLIR A400) - 14-20210218-012228.mp4';
' ...\Camera 1 - 192.168.0.105 (FLIR A400) - 14-20210218-232125(1).mp4'
... and 1 more
}
Folders: {
'C:\Users\Christine Deer\Downloads\02242021-SV\02242021-SV'
}
UniformRead: 0
ReadMode: 'file'
BlockSize: Inf
PreviewFcn: @videoReader
SupportedOutputFormats: [1×16 string]
ReadFcn: @videoReader
AlternateFileSystemRoots: {}
Error using matlab.io.datastore.FileDatastore/read (line 29)
Index exceeds the number of array elements (0).
Error in DatastoreLoad (line 5)
data=read(vds);
This looks like vds is populated with the correct data. What I am confused by is that the data is in vds, but I cant seem to call the read properly to not get an error. Any help understanding this error and its resolution is greatly appreciated and thoroughly welcome,
Christine D

채택된 답변

Kojiro Saito
Kojiro Saito 2021년 7월 2일
videoReader function should be VideoReader.
Also, for avoiding function name conflict, it's better to use another name to custom function than videoReader.
vds = fileDatastore(loc, 'ReadFcn', @myVideoReader, 'IncludeSubfolders', ...
true, 'FileExtensions', '.mp4')
function v = myVideoReader(file)
v = VideoReader(file);
end
Or, simply, you don't need to use custom function in this case.
vds = fileDatastore(loc, 'ReadFcn', @VideoReader, 'IncludeSubfolders', ...
true, 'FileExtensions', '.mp4')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Camera Calibration에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by