Importing labeled ground truth data using Image Labeler

12 ビュー (過去 30 日間)
Amin Assadzadeh
Amin Assadzadeh 2019 年 10 月 12 日
編集済み: MathWorks Support Team 2024 年 6 月 17 日
I have labeled some data using Image Labeler. However, when I load gTruth labels and try to use the objectDetectorTrainingData(gTruth), I get the following error:
Error using boxLabelDatastore (line 216) Incorrect bounding box format. Bounding box must be an M-by-4 numeric matrix, where M specifies the number of boxes in a row. The column in the training data table that contains the bounding boxes must be a cell array.
data= load('exportedLabels.mat');
[imds,bxds] = objectDetectorTrainingData(data.gTruth);
Image Labeler seems to store bounding boxes as struct instead of Mx4 matrices, I reckon this might be the issue. How can I load the gTruth obj the right way?
How can I get gTruth data in the following format?
Any help will be much appreciated.
  1 件のコメント
Rohan Sanghavi
Rohan Sanghavi 2020 年 4 月 28 日
I too had the same question However I want to convert the full table into the bounding box format mentioned. I can’t do it individually And if I loop it then the data having more than 1 bounding box gets concatenated as a 1 by 8 array Please help in this regard as well

サインインしてコメントする。

採用された回答

Rajani Mishra
Rajani Mishra 2019 年 10 月 15 日
編集済み: MathWorks Support Team 2024 年 6 月 17 日
Update: Image Labeler is compatible with objectDetectorTrainingData() as of R2020a.
Please contact Technical Support if you are facing any specific issues.
**************************************************************************************************
Hi,
You can export the labeled ground truth to a MAT-file or to a variable in the MATLAB workspace. In both the cases the labeled ground truth is stored as groundTruth object. The values in that object are stored as structures. You can access the fields by using the commands like:
gTruthInterval(1,:).Car{1}.Position
where gTruthInterval is the labeled data. You can access various fields of that object as well. Please refer to the following documentation for more information:
About groundTruth object:
Hope this helps!
  2 件のコメント
Thijs Langius
Thijs Langius 2022 年 8 月 24 日
I have (almost) the same question. I downloaded labeled images. I now have .jpg (images) and .txt files (coordinates of the box).
Example 123_456.jpg, and 123_456.txt.
Txt files contain:
0 0.578964870010237 0.553121683650408 0.130052151238592 0.24380704041721.
How do I make a groundTruth out of this?
Marjan Trutschl
Marjan Trutschl 2022 年 12 月 18 日
This is something that bugs me as well. For each image, I have several polygons, represeting the region of interest (ROI). The data is stored in a delimited text file, so I can get it into any format that is required. What bugs me is that the image labeler offers, among other shapes, a polygonal ROI. The example in the Matlab documentation mentions only rectangular ROI defined with [x,y,width, height]. There is no mention of polygons, lines, pixel labels, and projected cuboids that supported by the image labeler.
Aditionally, the training data table shown in the documentation (WWW) looks straightforward. However, there is no mention (or at least I cannot find it) of how to import my ROIs into the image labeler.The image labeler creates a binary .mat file, making it hard(er) to create my own training table using a program/script. Honestly, I am not excited about the idea of importing the ROIs (if at all possible) using a GUI interface because I have a very large number of images (this is to be expected when dealing weith deep learning).
Therefore, it would probably help many if someone posted a solution to this question. Thank you.
Generally speaking, there is a disconnect between what Matlab is [supposedly] able to do and what is actually documented. Is this because the documentation is written by the tech writers and not by those who actually wrote te code? I would not be writing if this was a free software package. However, I do pay a hefty annual license/maintenance fee for Matlab and various toolboxes.

サインインしてコメントする。

その他の回答 (1 件)

Ali Ozturk
Ali Ozturk 2023 年 3 月 26 日
編集済み: Ali Ozturk 2023 年 3 月 26 日
In the ImageLabeler tool, choose "To Workspace" from Export and select "table" as the "Export Format" instead of "ground truth" within "Export to workspace" window. Then, if you use that variable within Matlab, you may encounter less problem. The groundtruth data is too complicated to use in the Matlab code.

Community Treasure Hunt

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

Start Hunting!

Translated by