How to label multiple objects in object detection with different names?

4 ビュー (過去 30 日間)
Banchon Sripanha
Banchon Sripanha 2018 年 12 月 17 日
コメント済み: Image Analyst 2024 年 8 月 24 日
Hi there!
I've a problem with labelling my objects in an image.
Let's have a look at the image:
TestFotoprobleem.PNG
This programme is detecting front/rear of the cars and a stop sign. I want the labels to say what they're looking at. For example: "Stop Sign Confidence: 1.0000", CarRear Confidence: 0.6446 and etc. As you may see, my programme adds the probability factors correctly. But there are still no strings/labelnames attached.
You can have a look at my code:
%%
% Read test image
testImage = imread('StopSignTest2.jpg');
% Detect stop signs
[bboxes,score,label] = detect(rcnn,testImage,'MiniBatchSize',128)
% Display detection results
label_str = cell(3,1);
conf_val = [score];
conf_lab = [label];
for ii=1:3
label_str{ii} = [ ' Confidence: ' num2str(conf_val(ii), '%0.4f')];
end
position = [bboxes];
outputImage = insertObjectAnnotation(testImage,'rectangle',position,label_str,...
'TextBoxOpacity',0.9,'FontSize',10);
figure
imshow(outputImage)
%%
I have NO clue in how to add strings in the label_str{ii} like the way I did with scores (num2str(conf_val(ii)).
Thanking you in advance!
  2 件のコメント
Sarannya Udhayakumar
Sarannya Udhayakumar 2020 年 4 月 7 日
編集済み: Sarannya Udhayakumar 2020 年 4 月 7 日
hello... how to detect multiple objects in RCNN???
pls rply
Image Analyst
Image Analyst 2020 年 4 月 23 日
Maybe there is only one object in your image.

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

採用された回答

Image Analyst
Image Analyst 2018 年 12 月 17 日
If insertObjectAnnotation() is not working, then use text().
  1 件のコメント
Banchon Sripanha
Banchon Sripanha 2018 年 12 月 18 日
Thanks for the response! Much appreciated.
I've fixed the problem by the following line code:
conf_val = [score];
conf_lab = [label];
for ii=1:3
label_str{ii} = [sprintf('%s', conf_lab(ii)) ' Confidence: ' num2str(conf_val(ii), '%0.4f')];

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

その他の回答 (2 件)

Quoc-Bao Ta
Quoc-Bao Ta 2019 年 9 月 25 日
編集済み: Quoc-Bao Ta 2019 年 9 月 25 日
Hello, How can i change the colors of bounding box?
  1 件のコメント
Image Analyst
Image Analyst 2024 年 8 月 24 日
@Quoc-Bao Ta, use the AnnotationColor option of insertObjectAnnotation.
outputImage = insertObjectAnnotation(testImage,'rectangle',position,label_str,...
'TextBoxOpacity',0.9,'FontSize',10, ...
'LineWidth', 2, 'AnnotationColor', 'r');

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


Onurcan
Onurcan 2024 年 8 月 23 日
hi, is it possible that you can share the code for multiple class detection. I've been trying but couldnt figure it out. I can only train one object but more than one doesnt work. please help

Community Treasure Hunt

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

Start Hunting!

Translated by