【发布时间】:2014-04-30 06:02:59
【问题描述】:
我正在尝试使用 Matlab(视觉工具箱)中的内置函数来训练级联对象检测器。但是,运行命令后出现以下消息。
*
Error using trainCascadeObjectDetector (line 245)
Error reading instance 1 from image 2, bounding box possibly out of image bounds.
*
我不明白为什么边界框会越界。我的正图像的所有参数都设置正确(起点 x、y、宽度和高度。我使用 createMask(h) 创建蒙版并找到 x 和 y 的最小坐标作为起点,max-min每个维度都是宽度和高度),负图像(据我所知)只是图像,不需要任何设置。
有人遇到过同样的问题吗?你是怎么解决的?
编辑: 这是代码。我没有训练“数据”结构的工具箱,所以我自己写了一个
positive_samples=struct;
list=dir('my_folder_name_which_I_took_out');
L=length(list)-3; %Set L to be the length of the image list.
for i=1:length(list)
positive_samples(i).imageFilename=list(i).name;
end
positive_samples(:,1)=[]; %first 3 lines do not contain file names
positive_samples(:,1)=[];
positive_samples(:,1)=[];
for j=1:1
imshow(positive_samples(j).imageFilename);
title(positive_samples(j).imageFilename);
h=imrect;
h1=createMask(h);
I=imread(positive_samples(j).imageFilename);
[le, wi, hi]=size(I);
tempmat=[];
count=1;
for l=1:le
for m=1:wi
if h1(l,m)==1
tempmat(count,1)=l;
tempmat(count,2)=m;
count=count+1;
end
end
end
positive_samples(j).objectBoundingBoxes(1,1)=min(tempmat(:,1));
positive_samples(j).objectBoundingBoxes(1,2)=min(tempmat(:,2));
positive_samples(j).objectBoundingBoxes(1,3)=max(tempmat(:,2))-min(tempmat(:,2));
positive_samples(j).objectBoundingBoxes(1,4)=max(tempmat(:,1))-min(tempmat(:,1));
imtool close all
end
trainCascadeObjectDetector('animalfinder.xml', positive_samples, 'my_neative_folder_name', 'FalseAlarmRate', 0.2, 'NumCascadeStages', 3);
如果弄乱了请见谅......
【问题讨论】:
-
请提供可以重现您的问题的代码。
标签: matlab object-detection vision matlab-cvst