Fddb数据集人脸label可视化(matlab)

    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

    效果图如下:
图1
图2
    因为是个带倾斜角度的椭圆,所以画了一个椭圆,然后用简单的最大最小值方法在外面外接了一个矩形框。

            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数据集的位置目录,结构如下:
图3

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值