fddb数据集的下载地址为fddb
其中的标签格式如下:
<major_axis_radius minor_axis_radius angle center_x center_y 1>.
标签文件里面给出的是个椭圆,其中的angle 是角度,在程序中将其作为偏向左边或者右边的角度(单位为弧度),效果基本吻合。
下面是matlab可视化的一个小程序和效果图。
clear all;
close all;
imgSourceFolder='E:/WorkSpace/matlab/NN/DataSet/face collection/FDDB face/';
for k=1:10
if k<10
filePath=[imgSourceFolder 'FDDB-folds/FDDB-fold-0' num2str(k) '-ellipseList.txt' ];
else
filePath=[imgSourceFolder 'FDDB-folds/FDDB-fold-' num2str(k) '-ellipseList.txt' ];
end
fileIDIn=fopen(filePath,'r');
while (~feof(fileIDIn))
tempName=textscan(fileIDIn,'%s',1,'Delimiter','\n'); %read the file name and path 读文件名和路径
rectnum=cell2mat(textscan(fileIDIn,'%f',1,'Delimiter','\n')); %read the rect number 读取矩形的个数
rect=cell2mat(textscan(fileIDIn,'%f',rectnum*6,'Delimiter','\n')); %read the rect data 读取矩形数据
rectOut=(reshape(rect,6,rectnum))';
tempName=cell2mat(tempName{1});
imgFileName=[imgSourceFolder tempName '.jpg'];
I=imread(imgFileName);
imInfo=imfinfo(imgFileName);
imshow(I);
hold on;
angle = rectOut(:,3); % 角度
angle=sign(angle).*(pi/2-abs(angle));
r = 0:0.01:2*pi; % 转一圈
for s=1:rectnum
p = [(rectOut(s,2)*cos(r))' (rectOut(s,1)*sin(r))']; % 未旋转
alpha = [cos(angle(s)) -sin(angle(s))
sin(angle(s)) cos(angle(s))];
p1 = p*alpha; % 转后
p1=[p1(:,1)+rectOut(s,4) p1(:,2)+rectOut(s,5)];
plot(p1(:,1),p1(:,2),'r');
posx=minmax(p1(:,1)');
posy=minmax(p1(:,2)');
rectangle('Position',[posx(1) posy(1) posx(2)-posx(1) posy(2)-posy(1)],'EdgeColor','b');
end
hold off
hold off;
pause;
end
fclose(fileIDIn);
end
效果图如下:
因为是个带倾斜角度的椭圆,所以画了一个椭圆,然后用简单的最大最小值方法在外面外接了一个矩形框。
posx=minmax(p1(:,1)');
posy=minmax(p1(:,2)');
rectangle('Position',[posx(1) posy(1) posx(2)-posx(1) posy(2)-posy(1)],'EdgeColor','b');
程序里面没有加判断矩形框是否落在了图像外面。
其中imgSourceFolder是Fddb数据集的位置目录,结构如下: