Why do I get these error message ?

2 ビュー (過去 30 日間)
Chidiebere Ike
Chidiebere Ike 2019 年 6 月 28 日
コメント済み: Chidiebere Ike 2019 年 6 月 30 日
EyeDetect = vision.CascadeObjectDetector('EyePairBig');
% Read input image
I = imread('Photo.jpg');
subplot(1,2,1), imshow(I);
% Create bounding box
BB = step(EyeDetect, I);
rectangle('Position', BB, 'LineWidth', 3, 'LineStyle', '-', 'EdgeColor','r');
title('Eyes Detection');
Eyes = imcrop(I,BB);
subplot(1,2,2), imshow(Eyes);
title('Cropped Eyes')
Error message
>> EyeDetection
Error using rectangle
Value must be a 4 element vector
Error in EyeDetection (line 9)
rectangle('Position', BB, 'LineWidth', 3, 'LineStyle', '-', 'EdgeColor','r');
  1 件のコメント
dpb
dpb 2019 年 6 月 28 日
Because the returned region isn't a 4-vector in BB.
We have no way to know what it actually is -- perhaps either empty if the algorithm failed to find the desired features or alternatively, an Mx4 array if there were more than one region detected.
Set a breakpoint and use the debugger to see or display the image and label the regions returned as in the example in the documentation to see what actually was found...

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

回答 (1 件)

Himanshu tripathi
Himanshu tripathi 2019 年 6 月 28 日
編集済み: Himanshu tripathi 2019 年 6 月 28 日
Try this
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',3,'LineStyle','-','EdgeColor','r');
end
  1 件のコメント
Chidiebere Ike
Chidiebere Ike 2019 年 6 月 30 日
% Object Detector
EyeDetect = vision.CascadeObjectDetector('EyePairBig');
% Read input image
I = imread('Photo.jpg');
subplot(1,2,1), imshow(I);
% Create bounding box
BB = step(EyeDetect, I);
for i = 1:size(BB,1)
rectangle('Position',BB(i,:),'LineWidth',3,'LineStyle','-','EdgeColor','r');
end
title('Eyes Detection');
Eyes = imcrop(I,BB);
subplot(1,2,2), imshow(Eyes);
title('Cropped Eyes')
Thanks for your feedback, I appreciate. I still get an error. See attached photo. Thanks

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

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by