function output()
  outtxt = fopen('D:\AR database\kz.txt','wt');
  :
     imgpath= strcat('D:\AR database\kz\',int2str(i) , '.jpg');
     img = im2uint8(imread(imgpath));
     shapepath = strcat(imgpath(:end-), 'pts');
     shape = double(loadshape(shapepath));
     bbox = getbbox(shape);
     region = enlargingbbox(bbox, 1.25);
     out(outtxt, imgpath, region, shape);
     %drawshapes(img, shape);
     %rectangle(),bbox(),bbox(),bbox()]);
     %rectangle(),region(),region(),region()]);
     %i
     %w = waitforbuttonpress;

  end
  fclose(outtxt);
end
function out(outtxt, imgpath, region, shape)
fprintf(outtxt, '%s ', imgpath);
fprintf(outtxt, ),region(),region(),region());
fprintf(outtxt, , );
:
    shapes2(i, ) = shape(i, ) - region();
    shapes2(i, ) = shape(i, ) - region();
    fprintf(outtxt, ), shapes2(i, ));
end
fprintf(outtxt, '\n');
end

function shape = loadshape(path)
% function: load shape from pts file
file = fopen(path);

if ~isempty(strfind(path, 'COFW'))
    shape = textscan(file, , );
else
    shape = textscan(file, , );
end
fclose(file);

shape = shape{};
end

function drawshapes(img, shapes)
%DRAWSHAPE Summary of this function goes here
%   Function: draw face landmarks on img
%   Detailed explanation goes here
%   Input:
%       img: input image
%       shapes: given face shapes

imshow(img);
hold on;

colors = {'r.' 'g.' 'b.' 'c.' 'm.' 'y.' 'k.'};

:size(shapes, )/ %
:size(shapes, )  %
    scatter(shapes(*(s-) + ), shapes(*s),'w.');
    scatter(shapes(*(s-) + ), shapes(*s),'k');
    %text(shapes(*(s-) + ),shapes(*s),{is},'color','r');
end
end

end

function bbox = getbbox(shape)
%GETBBOX Summary of this function goes here
%   Function: get the bounding box of given shape
%   Detailed explanation goes here
%   Input:
%      shape: the shape of face
%   Output:
%      bbox: the bounding box of given face shape

bbox = zeros(, );

left_x   = min(shape(:, ));
right_x  = max(shape(:, ));
top_y    = min(shape(:, ));
bottom_y = max(shape(:, ));

bbox()  = left_x;
bbox()  = top_y;
bbox()  = right_x - left_x + ;
bbox()  = bottom_y - top_y + ;

end

function region = enlargingbbox(bbox, scale)

region() = floor(bbox() - (scale - )/*bbox());
region() = floor(bbox() - (scale - )/*bbox());

region() = floor(scale*bbox());
region() = floor(scale*bbox());

% region.right_x = floor(region.left_x + region.width - );
% region.bottom_y = floor(region.top_y + region.height - );

end

人脸pts文件检查及人脸框输出的更多相关文章

  1. 将Mat类型坐标数据生成pts文件

    前言 获取人脸特征点的坐标信息之后,想要将坐标信息shape保存为pts/asf/txt等文件格式,本文就对此进行实现. 实现过程 1.确定pts文件的书写格式: 以要生成的文件为例,书写格式如下: ...

  2. 百度人脸识别api及face++人脸识别api测试(python)

    一.百度人脸识别服务 1.官方网址:http://apistore.baidu.com/apiworks/servicedetail/464.html 2.提供的接口包括: 2.1 多人脸比对:请求多 ...

  3. ASP.NET MVC 4 (十一) Bundles和显示模式--asp.net mvc中 @Scripts.Render("~/bundles/jquery")是什么意思? 在布局文件中使用Scripts.Render()输出脚本包,Styles.Render()输出风格包:

    ASP.NET MVC 4 (十一) Bundles和显示模式 ASP.NET MVC 4 引入的js打包压缩功能.打包压缩jquery目录下的文件,在布局文件中使用Scripts.Render()输 ...

  4. opencv实现人脸识别(二) 人脸图像采集模块

    这一步我们开始搭建第一个模块,用来检测到图像中的人脸位置,并将它拍下来保存在指定路径 流程图: 代码实现: import cv2 def pic(cam): # 调用笔记本内置摄像头,所以参数为0,如 ...

  5. .gho文件检查

    虽然目前windows10的接受程度越来越广泛,但我接触到的一些非IT人士还是钟爱于windows7系统,本文记录一下在使用ghost还原系统遇到的问题. gho还原失败 在还原ghost系统过程中, ...

  6. jQuery检查复选框是否被选

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  7. 转《trackingjs+websocket+百度人脸识别API,实现人脸签到》流程

    先用websocket与后台建立通讯:用trackingjs在页面调用电脑摄像头,监听人脸,发现有人脸进入屏幕了,就把图片转成base64字符串,通过websocket发送到后端:后端拿到图片,调用百 ...

  8. python工具 - alert弹框输出姓名年龄、求和

    使用python自带的tkinter库进行GUI编程,完成两个功能: (1)要求用户输入姓名和年龄然后打印出来 (2)要求用户输入一个数字,然后计算1到该数字之间的和 代码部分: # 导入tkinte ...

  9. python筛选特定文件的信息按照格式输出到txt

    最近搞数据库,为了把图片文件的信息导入数据库表中,我开始研究python列出图片文件,其中发现因为IE临时文件里有非常多的不需要的图片,就需要筛选掉一些文件. 最终用python输出了所有需要的图片文 ...

随机推荐

  1. Cobar_基于MySQL的分布式数据库服务中间件

    Cobar是阿里巴巴研发的关系型数据的分布式处理系统,是提供关系型数据库(MySQL)分布式服务的中间件,该产品成功替代了原先基于Oracle的数据存储方案,它可以让传统的数据库得到良好的线性扩展,并 ...

  2. SQL Server 中 with tmp 临时表的用法

    SQL Server 中 with tmp 临时表的用法 ----------with临时表用法,有时候采用临时表比采用in的效率更高,避免了全表扫描. 实例中实现了查询普通题.大题.子题目的sql ...

  3. 给NSString增加Java风格的方法

    给NSString增加Java风格的方法 文章目录 我实在受不了 NSString 冗长的方法调用了,每次写之前都要查文档.特别是那个去掉前后多余的空格的方法,长得离谱.与之对应的别的语言,拿 jav ...

  4. A线段树

    线段树专题 顾琪坤 1.简介: 打acm的时候,经常会碰到一类问题,比方给你n个数的序列,然后动态的更改某些数的值,然后又动态地询问某个区间的值的和或者其它乱七八糟的东西,对于单个更改或者询问,也许很 ...

  5. 如何使用数据库保存session的方法简介

    使用数据库保存session的方法 php的session默认是以文件方式保存在服务器端,并且在客户端使用cookie保存变量,这就会出现一个问题,当一个用户由于某种安全原因关闭了浏览器的cookie ...

  6. 使用System.out.print/prilntln() 输出时存在的问题

    刚学习Java时第一个接触的method就是System.out.println() 方法.但是最近在使用它输出一些变量时出现了我不理解的现象,首先上代码: /* * * using method S ...

  7. maven--私服的搭建(Nexus的使用)

    Nexus常用功能就是:指定私服的中央地址.将自己的Maven项目指定到私服地址.从私服下载中央库的项目索引.从私服仓库下载依赖组件.将第三方项目jar上传到私服供其他项目组使用. 开启Nexus服务 ...

  8. fail2ban 保护

    Fail2ban是一款非常使用的软件,它能够监控系统日志,能够有效的防止ssh被暴力破解,下面小编将针对Fail2ban在Linux下的安装和使用给大家做个介绍,一起来了解下吧. https://gi ...

  9. 【转】Java跨平台原理

    原文地址:http://www.cnblogs.com/gw811/archive/2012/09/09/2677386.html 1.是么是平台 Java是可以跨平台的编程语言,那我们首先得知道什么 ...

  10. 程序设计第二次作业<1>

    面向对象程序设计第二次作业<1> Github 链接:https://github.com/Wasdns/object-oriented 题目: <1>第一次尝试 我立马认识到 ...