combine the string and number

hello, I have the coordinates of objects in the image and the path of the image and I want to combine all these in the cell array
trainingData = combine(bldsTrainT,bldsTrainW); % this function to combine
when adding the path of the image, display the error
how can instead this function with others to accept the path

 Risposta accettata

Walter Roberson
Walter Roberson il 2 Feb 2023

1 voto

Are you referring to combine for augmented image data store?
If so then each element you combine, such as bldsTrainT, must be a data store, not a path itself. You would imageDatastore to wrap the path into an image data store and combine.

8 Commenti

weam
weam il 2 Feb 2023
thank you very much for explaining
Sorry, another question: when complete the combine, i want to read the trainingData and then specify the path and the coordinate of two objects.
An image is supposed to appear via the path (I) and specify the two objects
data = read(trainingData);
I = data{1}
Tbox1 = data{2};
Wbox2 = data{3};
RGB = insertShape(I,'Rectangle', {bbox1, bbox2} );
Image = imresize(RGB,2);
figure
imshow(Image)
the erro in RGB coudn't recognize the I
Error in insertShape
validateAndParseInputs(I, shape, position, varargin{:});
What shows up for
class(data)
size(data)
weam
weam il 5 Feb 2023
Modificato: weam il 5 Feb 2023
After read the data appears in the same picture. and before the read the data (data gTruth and consists of DataSource, LabelDefinitions, and label data
What is the error message you are receiving in the insertShape?
the message error
Error using insertShape>errIf1
The POSITION must not be cell array for shape rectangle.
Error in insertShape>crossCheckShapePosition (line 471)
errIf1(errCond, 'vision:insertShape:positionCell', shape);
Error in insertShape>crossCheckInputs (line 444)
crossCheckShapePosition(shape, position);
Error in insertShape>validateAndParseInputs (line 290)
crossCheckInputs(shape2, positionNew, color2);
Error in insertShape (line 129)
validateAndParseInputs(I, shape, position, varargin{:});
Error in recognitionThree (line 77)
RGB = insertShape(I,'Rectangle', {bbox1, bbox2} );
insertShape only permits a cell array for "line", "polygon", or "filled-polygon". If you want to plot more than one rectangle you need to use a numeric array
RGB = insertShape(I,'Rectangle', [bbox1; bbox2] );
weam
weam il 6 Feb 2023
Thank you so much

Accedi per commentare.

Più risposte (1)

Aylin
Aylin il 2 Feb 2023
Modificato: Aylin il 2 Feb 2023
Hi, I wanted to second Walter's answer which will work best if you want to read the filenames as image data.
However if you do really want the raw filenames in the CombinedDatastore, you can use ArrayDatastore to wrap the filenames before calling combine:
filenames = {'file1.png' 'file2.png'}';
filenameDs = arrayDatastore(filenames, OutputType="same");
trainingData = combine(bldsTrainT,bldsTrainW, filenameDs);
% Or use "transform" to get more control over the combination method
trainingData = transform(bldsTrainT, bldsTrainW, filenameDs, ...
@(trainT, trainW, filename) {trainT trainW filename});
Is this what you're looking for?

Prodotti

Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by