이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Multiple Labels in an Image
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello, I am currently doing a project and inventory categorization and I can detect each type of inventory, but I can only output each detected image labeled on separate images. I want to know how to label all the detected images on one image. I am currently using insertObjectAnnotation to label my detected items. Can someone please shed some light on how I can put all the labeled products on one image. Thank you.
채택된 답변
sixwwwwww
2013년 12월 3일
you can store labels for all of your items in a cell array of strings and then you can use this cell array of strings in place of single label. For more information see:
I hope it helps. Good luck!
댓글 수: 20
Cady
2013년 12월 3일
Thanks for your quick response. Can you explain in more detail how this would be done with something like this:
detectedImg = insertObjectAnnotation(img, 'rectangle', bbox, 'Orbit');
detectedImg1 = insertObjectAnnotation(img, 'rectangle', bbox1, 'Monster');
detectedImg2 = insertObjectAnnotation(img, 'rectangle', bbox2, 'GobStoppers');
detectedImg3 = insertObjectAnnotation(img, 'rectangle', bbox3, 'Jolly Ranchers');
detectedImg4 = insertObjectAnnotation(img, 'rectangle', bbox4, 'M&Ms');
sixwwwwww
2013년 12월 3일
I assume that bbox, bbox1 ... are 1x4 vectors since they are referring to rectangle. In this case you can do like this:
BoxPositions = [bbox; bbox1; bbox2; bbox3; bbox4];
BoxLabels = {'Orbit', 'Monster', 'GobStoppers', 'Jolly Ranchers', 'M&Ms'};
detectedImg = insertObjectAnnotation(img, 'rectangle', BoxPositions, BoxLabels);
Good luck!
Cady
2013년 12월 3일
Thank you very much for your help. Receiving this error for some reason though:
Error using insertObjectAnnotation>crossCheckInputs (line 254)
The length of LABEL must be equal to the number of rows in POSITION.
Cady
2013년 12월 3일
Example for bbox:
detector = vision.CascadeObjectDetector('OrbitNew.xml');
img = imread(image);
bbox = step(detector, img);
sixwwwwww
2013년 12월 3일
what value you get for bbox in the workspace? is it 1x4 vector of double values?
sixwwwwww
2013년 12월 3일
in this case you have to do as follows:
count = 0;
count = count + size(bbox, 1);
BoxLabels(1:count) = {'Orbit'};
prevCount = count;
count = count + size(bbox1, 1);
BoxLabels(prevCount:count) = {'Monster'};
prevCount = count;
count = count + size(bbox2, 1);
BoxLabels(prevCount:count) = {'GobStoppers'};
prevCount = count;
count = count + size(bbox3, 1);
BoxLabels(prevCount:count) = {'Jolly Ranchers'};
prevCount = count;
count = count + size(bbox4, 1);
BoxLabels(prevCount:count) = {'M&Ms'};
BoxPositions = [bbox; bbox1; bbox2; bbox3; bbox4];
detectedImg = insertObjectAnnotation(img, 'rectangle', BoxPositions, BoxLabels);
Cady
2013년 12월 3일
works great thank you very for your time, but now its incorrectly labeling some products. For example, it will detect 3 m&ms in the photo but the 4th m&m will be detected as jolly ranchers, etc.
sixwwwwww
2013년 12월 3일
Basically it all depends upon your bbox, bbox1 stuff. If you share your complete code then maybe I can look at it a bit
Cady
2013년 12월 3일
편집: Cady
2013년 12월 4일
clc;clear
imnumber = {'Newsstand56.jpg', 'Newsstand30.jpg', 'Newsstand48.jpg'};
for i=1:length(imnumber)
image=imnumber{i};
%Orbit
detector = vision.CascadeObjectDetector('OrbitNew.xml');
img = imread(image);
bbox = step(detector, img);
detectedImg = insertObjectAnnotation(img, 'rectangle', bbox, 'Orbit');
numBox = size(bbox, 1);
Orb = 8 - numBox;
%figure; imshow(detectedImg);
%Monster
detector = vision.CascadeObjectDetector('Monster.xml');
img = imread(image);
bbox1 = step(detector, img);
detectedImg1 = insertObjectAnnotation(img, 'rectangle', bbox1, 'Monster');
numBox1 = size(bbox1, 1);
Mon = 6-numBox1;
%figure; imshow(detectedImg1);
%GobStoppers
detector = vision.CascadeObjectDetector('GobStopp.xml');
img = imread(image);
bbox2 = step(detector, img);
detectedImg2 = insertObjectAnnotation(img, 'rectangle', bbox2, 'GobStoppers');
numBox2 = size(bbox2, 1);
Gob = 6-numBox2;
%figure; imshow(detectedImg2);
%Jolly Ranchers
detector = vision.CascadeObjectDetector('Jolly.xml');
img = imread(image);
bbox3 = step(detector, img);
detectedImg3 = insertObjectAnnotation(img, 'rectangle', bbox3, 'Jolly Ranchers');
numBox3 = size(bbox3, 1);
Jolly = 6 - numBox3;
%figure; imshow(detectedImg3);
%M&Ms
detector = vision.CascadeObjectDetector('M&Ms.xml');
img = imread(image);
bbox4 = step(detector, img);
detectedImg4 = insertObjectAnnotation(img, 'rectangle', bbox4, 'M&Ms');
numBox4 = size(bbox4, 1);
MM = 6 - numBox4;
%figure; imshow(detectedImg4);
OrderLog(i,2)=Orb;
OrderLog(i,3)=Gob;
OrderLog(i,4)=Mon;
OrderLog(i,5)=Jolly;
OrderLog(i,6)=MM;
OrderLog(i,1)=i;
end
OrderLog
Cady
2013년 12월 3일
When I detect them separately in the image, it works fine. But when using what you supplied, it detects incorrectly
sixwwwwww
2013년 12월 4일
can you send me files as well? Also try this code and I am suggesting same thing in your case:
faceDetector = vision.CascadeObjectDetector;
I = imread('visionteam.jpg');
bboxes = step(faceDetector, I);
IFaces = insertObjectAnnotation(I, 'rectangle', bboxes, 'Face');
figure, imshow(IFaces), title('Detected faces');
bodyDetector = vision.CascadeObjectDetector('UpperBody');
bodyDetector.MinSize = [60 60];
bodyDetector.ScaleFactor = 1.05;
bboxBody = step(bodyDetector, I);
IBody = insertObjectAnnotation(I, 'rectangle',bboxBody,'Upper Body');
figure, imshow(IBody), title('Detected upper bodies');
BoxPositions = [bboxes; bboxBody];
BoxLabels(1:6) = {'Face'};
BoxLabels(7:18) = {'Upper Body'};
a = insertObjectAnnotation(I, 'rectangle', BoxPositions,BoxLabels);
figure, imshow(a)
you can directly run this code and thats the ans you should also according to the suggested manner
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)