필터 지우기
필터 지우기

Cant able to display bounding box from detector on the image ?

조회 수: 20 (최근 30일)
Sahik Ha.adi
Sahik Ha.adi 2024년 2월 12일
답변: Drishti 2024년 9월 23일 9:02
I = imread(testDataTbl.imageFilename{3});
I = imresize(I,inputSize(1:2));
[bboxes,scores] = detect(detector,I);
I = insertObjectAnnotation(I,'rectangle',bboxes,scores);
figure
imshow(I)
I am using the above code to display the results from object detector. I can see just picture but I can't get the bounding box with the score. Both were showing empty with no values in those. How can this problem can be solved ?
  댓글 수: 2
Image Analyst
Image Analyst 2024년 2월 12일
I don't know. Give us the image and the rest of the code.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Udit06
Udit06 2024년 2월 19일
Hi Sahik,
If both bboxes and scores are empty on running the detect function, it means no objects were detected in the image. This could be due to multiple reasons like object to be detected not present in the original image, detector not trained properly, etc.
If you want any specific help, please share the image and detector that you are using which will be helpful for others to reproduce the issue that you are facing on their end.

댓글을 달려면 로그인하십시오.

답변 (1개)

Drishti
Drishti 2024년 9월 23일 9:02
Hi Sahik,
The issue of 'No bounding box' can be resolved by taking the following points into consideration:
  • The image format should be checked to maintain the compatibility with the ‘imresize’ function. Refer to the MATLAB Documentation of the ‘imresize’ function for better understanding.
  • Verify if the 'detect' function is returning any values for 'bboxes' and 'scores', as this depends on the type of ‘detector’ utilized in the code.
You can refer to the modified code snippet below for a better understanding. For this example, I have made certain assumptions, and these are setting the ‘inputSize’ vector to ‘[416, 416]’ and using the ‘detector’ as ‘yolov2ObjectDetector('tiny-yolov2-coco')’.
I have utilized sample image to validate the code.
% Load a pre-trained YOLO v2 object detector
detector = yolov2ObjectDetector('tiny-yolov2-coco');
% Define the input size for the detector
inputSize = [416, 416];
% Read the image from the table
I = imread(testDataTbl.imageFilename{3});
% Resize the image to match the input size of the detector
I = imresize(I, inputSize(1:2));
% Perform object detection
[bboxes, scores] = detect(detector, I);
% Check if any objects were detected
if ~isempty(bboxes)
I = insertObjectAnnotation(I, 'rectangle', bboxes, scores);
else
disp('No objects detected.');
end
% Display the annotated image
figure;
imshow(I);
I have attached the received output image on sample data for reference.
You can also refer to the MATLAB Documentation of ‘detect’ function for more information.
I hope this helps in resolving your query.

Community Treasure Hunt

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

Start Hunting!

Translated by