Creating Image Datastore as a struct for codegen throwing an error

Hi,
I am trying to create an ImageDatastore object to initialize a bag of features and then run codegen on it. Documentation says I can create it as a struct but it still throws an error.
images = cell(numImages, 1);
labels = cell(numImages, 1);
for k = 0:numImages-1
filename = fullfile(imageFolder, sprintf('%04d.jpg', int32(k)));
images{k+1} = imread(filename);
labels{k+1} = sprintf('%04d.jpg', int32(k));
end
imds.Images = images;
imds.Labels = categorical(labels);
bag = bagOfFeatures(imds, 'CustomExtractor',CustomFeatureExtractor, ...
bowParams{:});
This is the error I get:
  • It no longer gives me an error on codegen.
  • It doesn't work with regular execution.
Error using bagOfFeatures/parseInputs (line 1005)
The value of 'imds' is invalid. Expected imds to be one of these types:
matlab.io.datastore.ImageDatastore
Instead its type was struct.
Error in
bagOfFeatures (line 119)
[imgSets, params] = bagOfFeatures.parseInputs(varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in
main_vSLAM_VisualHull_RaspPi (line 283)
bag = bagOfFeatures(imds, 'CustomExtractor',CustomFeatureExtractor, ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Am I doing something wrong here?

回答 (0 件)

製品

リリース

R2026a

質問済み:

2026 年 7 月 23 日 23:04

Community Treasure Hunt

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

Start Hunting!

Translated by