How to create a box label datastore?
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lorenzo Tonelli
el 11 de Feb. de 2022
Comentada: Lorenzo Tonelli
el 11 de Feb. de 2022
Hello, I've been trying to create a box label datastore using the blds function.
What I understood, is that I need to create a table with the first column containing a type 'double' array, coordinates of bounding boxes, and a string variable with its class.
Now, how can I assign a 1x4 'double' vector into 1 single cell? In this 'fake' case, coordinates of bb are all the same, so is the class. I would need something like:
[0, 0, 300, 300] 'stopSignal'
[0, 0, 300, 300] 'stopSignal'
bbox = [0 0 300 300]; %images: 4170
maxSamples = 4170;
varTypes = {'double', 'string'};
size = [4170 2];
T = table('size',size, 'VariableTypes', varTypes);
for i = 1:maxSamples
T (i,1) = {bbox};
end
The error occurs because bbox is a 1x4 double vector, while MATLAB expects only a 1x1 variable to be stored in one single cell.
What am I missing?
0 comentarios
Respuesta aceptada
Abolfazl Chaman Motlagh
el 11 de Feb. de 2022
you can easily create and edit a cell. then convert it to table.
here is an example:
boxes = cell(10,2); %number of images x 2=(coordinates of box , labels)
% fill boxes :
for i=1:10
n = randi(3); % number of box in i-th image, it maybe diffrenent so i consider it
boxes{i,1} = rand(n,4); % nx4 each row coordinate of a box
boxes{i,2} = string(randi(2,n,1)); % here i create n label for every image between 2 possible labels
end
% Convert to table
boxes = cell2table(boxes,'VariableNames',{'Boxes','Labels'});
blds = boxLabelDatastore(boxes)
Remember if this blds is gonna use for a deep learning applications, values of each box should be checked. 0 is invalid for deep learning. and sum of 3-th element and first one shouldn't be more than image width, and sum of 4th and 2th element shouldn't be more than image height.
3 comentarios
Abolfazl Chaman Motlagh
el 11 de Feb. de 2022
Oh yes. when all boxes are 1x4, the cell2table automatically change the table first column to double not cell.
so here's the solution:
create boxes as cell, then use table function.
for i=1:10
boxes(i,1) = {[2 2 298 298]};
end
labels = num2cell(string(randi(2,10,1)));
boxes = table(boxes,labels);
blds = boxLabelDatastore(boxes)
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!