% 1get the filename
dataSource = groundTruthDataSource(MoisImageset.imageFilename);
%2 table your class
ldc = labelDefinitionCreator();
addLabel(ldc,'Moisture',labelType.Rectangle);
addLabel(ldc,'Joint',labelType.Rectangle);
labelDefs = create(ldc)
%3 data,only two classes
MoistureTruth =MoisImageset.Moisture;
JointTruth=MoisImageset.Joint;
labelNames = {'Moisture';'Joint'};
labelData = table(MoistureTruth,JointTruth,'VariableNames',labelNames);
%4 get ground truth ,then you can use
gTruth = groundTruth(dataSource,labelDefs,labelData);
.
Besides
Change the table to datasource
%Add Rebar here ......Oct.22,2021
% Create an image datastore for loading the images.
imdsTrain =imageDatastore(RebarTrain227.filename); %imageDatastore(trainingDataTbl.imageFilename);
imdsTest =imageDatastore(RebarTest227.filename);%imageDatastore(testDataTbl.imageFilename);
%Create a datastore for the ground truth bounding boxes.
bldsTrain =boxLabelDatastore(RebarTrain227(:,2:end));% boxLabelDatastore(trainingDataTbl(:, 2:end));
bldsTest = boxLabelDatastore(RebarTest227(:,2:end));%boxLabelDatastore(testDataTbl(:, 2:end));
%Combine the image and box label datastores.
trainingData = combine(imdsTrain, bldsTrain);
testData = combine(imdsTest, bldsTest);