how to prepare the data set for boxLabelDatastore function using image labler APP
3 次查看(过去 30 天)
显示 更早的评论
I have a data set prepared by image labler APP. The format of the bounding box is different to the example showing on the matlab page.
I wrote some codes to convert them, but not very successful. There are either single or double quotation marks in my table and

The boxLabelDatastore report an error message as below:
Error using boxLabelDatastore>iAssertValidBBoxFormat
The size of bounding box data must be M-by-4, M-by-5, or M-by-9, where M is the number of boxes in each table element. The column in the training data table that contains the bounding boxes must be a cell array.
My questions are:
1) How could I convert them into a cell array without ' or ''
2) Is there a easy way to label image and produce the dataset that mataches the example data set?
Regards
data_snail = load('340Ann.mat');
imageFilename = data_snail.gTruth.DataSource;
% imageFilename = cell2table(imageFilename);
snaillist = data_snail.gTruth.LabelData.snail;
for i =1:length(snaillist)
tmp=snaillist{i};
rowStrings = arrayfun(@(row) strjoin(arrayfun(@(x) num2str(x), tmp(row, :), 'UniformOutput', false), ', '), 1:size(tmp, 1), 'UniformOutput', false);
if size(tmp,1)>1
resultString = strjoin(rowStrings, '; ');
else
resultString = rowStrings;
end
column(i,1) = string(imageFilename{i});
resultString = strcat('[', resultString, ']');
column(i,2) = string(resultString);
resultString=[];
end
snailDataset = array2table(column, 'VariableNames', {'imageFilename', 'snail'});
snailDataset.snail=cellstr(snailDataset.snail);
0 个评论
回答(1 个)
T.Nikhil kumar
2023-10-4
Hello Josh,
I understand that you want to create a “training Data” table from the “groundTruth” object generated by using the Image Labeler App to create a YOLOv2 object Detector.
This can be done in a simple way by using the “objectDetectorTrainingData” function that takes “groundTruth” type object and returns a “trainingDataTable” that can be used for implementation object detection using YOLOv2.
trainingDataTable = objectDetectorTrainingData(gTruth);
You can refer to the following documentation to understand about the “objectDetectorTrainingData” function.
Hope this helps!
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!