Clear Filters
Clear Filters

How to upload groundTruth?

1 view (last 30 days)
Thijs Langius
Thijs Langius on 24 Aug 2022
Answered: Saffan on 7 Sep 2023
I have a question regarding my image recognition project.
I downloaded labeled images. I now have a filemap containg .jpg (images) and .txt files (coordinates of the box).
Example 123_456.jpg, and 123_456.txt.
Txt files contain for ex.:
0 0.578964870010237 0.553121683650408 0.130052151238592 0.24380704041721.
Furthermore I have a structure containing the following info:
Name, Folder, Date, Bytses, Isdir and datenum
How can I merge all coordinates and all names into one struct/matrix?
I want to make a groundTruth with the following function:
gTruth = groundTruth(dataSource,labelDefs,labelData);

Answers (1)

Saffan
Saffan on 7 Sep 2023
Hi Thijs,
You can use “readmatrix method to extract the coordinates from the text files and “fileparts” method to extract the name of the images and store them in a structure. Here is an example code snippet:
for i = 1:numberOfFiles
% Read the .txt file and extract the coordinates
coordinates = readmatrix(txtFilePath(i));
% Extract the image name from the file path
[~, imageName, ~] = fileparts(imageFilePath(i));
% Append the name and coordinates to the mergedData struct
mergedData(end+1).Name = imageName;
mergedData(end).Coordinates = coordinates;
end
Please refer this for more information:

Categories

Find more on Convert Image Type in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!