人脸识别理论和Python实现


压缩文件里有一个PDF文档,人脸数据,Python代码,介绍了LDA,PCA,SVD技术在人脸识别中的理论和Python实现
资源截图
代码片段和文件信息
#!/usr/bin/env python
# Software License Agreement (BSD License)
#
# Copyright (c) 2012 Philipp Wagner
# All rights reserved.
#
# Redistribution and use in source and binary forms with or without
# modification are permitted provided that the following conditions
# are met:
#
#  * Redistributions of source code must retain the above copyright
#    notice this list of conditions and the following disclaimer.
#  * Redistributions in binary form must reproduce the above
#    copyright notice this list of conditions and the following
#    disclaimer in the documentation and/or other materials provided
#    with the distribution.
#  * Neither the name of the author nor the names of its
#    contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# “AS IS“ AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT
# LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT INDIRECT
# INCIDENTAL SPECIAL EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING
# BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY WHETHER IN CONTRACT STRICT
# LIABILITY OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

import sys math Image

def Distance(p1p2):
  dx = p2[0] - p1[0]
  dy = p2[1] - p1[1]
  return math.sqrt(dx*dx+dy*dy)

def ScaleRotateTranslate(image angle center = None new_center = None scale = None resample=Image.BICUBIC):
  if (scale is None) and (center is None):
    return image.rotate(angle=angle resample=resample)
  nxny = xy = center
  sx=sy=1.0
  if new_center:
    (nxny) = new_center
  if scale:
    (sxsy) = (scale scale)
  cosine = math.cos(angle)
  sine = math.sin(angle)
  a = cosine/sx
  b = sine/sx
  c = x-nx*a-ny*b
  d = -sine/sy
  e = cosine/sy
  f = y-nx*d-ny*e
  return image.transform(image.size Image.AFFINE (abcdef) resample=resample)

def CropFace(image eye_left=(00) eye_right=(00) offset_pct=(0.20.2) dest_sz = (7070)):
  # calculate offsets in original image
  offset_h = math.floor(float(offset_pct[0])*dest_sz[0])
  offset_v = math.floor(float(offset_pct[1])*dest_sz[1])
  # get the direction
  eye_direction = (eye_right[0] - eye_left[0] eye_right[1] - eye_left[1])
  # calc rotation angle in radians
  rotation = -math.atan2(float(eye_direction[1])float(eye_direction[0]))
  # distance between them
  dist = Distance(eye_left eye_right)
  # calculate the reference eye-width
  reference = dest_sz[0] - 2.0*offset_h
  # scale factor
  scale = float(dist)/float(reference)
  # rotate original around the left eye
  image 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-12-16 15:49  facerecognition_guide
     目录           0  2012-07-28 03:41  facerecognition_guideib
     文件       16001  2012-07-28 03:41  facerecognition_guideibfacerec.bib
     文件          14  2012-07-28 03:41  facerecognition_guidedefinitions.tex
     文件     1299605  2014-12-16 12:52  facerecognition_guidefacerec.pdf
     文件        2420  2012-07-28 03:41  facerecognition_guidefacerec.tex
     文件      887819  2012-07-28 03:41  facerecognition_guidefacerec_octave.pdf
     文件     1295314  2012-07-28 03:41  facerecognition_guidefacerec_python.pdf
     目录           0  2012-07-28 03:41  facerecognition_guideimg
     目录           0  2012-07-28 03:41  facerecognition_guideimgeigenfaces
     文件      160636  2012-07-28 03:41  facerecognition_guideimgeigenfacesoctave_pca_eigenfaces.pdf
     文件      105056  2012-07-28 03:41  facerecognition_guideimgeigenfacesoctave_pca_reconstruction.pdf
     文件      330249  2012-07-28 03:41  facerecognition_guideimgeigenfacespython_pca_eigenfaces.pdf
     文件      156461  2012-07-28 03:41  facerecognition_guideimgeigenfacespython_pca_reconstruction.pdf
     目录           0  2012-07-28 03:41  facerecognition_guideimgfisherfaces
     文件        7954  2012-07-28 03:41  facerecognition_guideimgfisherfacesmulticlasslda.pdf
     文件      163641  2012-07-28 03:41  facerecognition_guideimgfisherfacesoctave_fisherfaces_fisherfaces.pdf
     文件      102334  2012-07-28 03:41  facerecognition_guideimgfisherfacesoctave_fisherfaces_reconstruction.pdf
     文件      290898  2012-07-28 03:41  facerecognition_guideimgfisherfacespython_fisherfaces_fisherfaces.pdf
     文件      124754  2012-07-28 03:41  facerecognition_guideimgfisherfacespython_fisherfaces_reconstruction.pdf
     目录           0  2012-07-28 03:41  facerecognition_guideimglibfacerec
     目录           0  2012-07-28 03:41  facerecognition_guideimglibfacereccolormap
     文件       91814  2012-07-28 03:41  facerecognition_guideimglibfacereccolormaplena.jpg
     文件       89761  2012-07-28 03:41  facerecognition_guideimglibfacereccolormaplena_autumn.jpg
     文件       96182  2012-07-28 03:41  facerecognition_guideimglibfacereccolormaplena_bone.jpg
     文件       72090  2012-07-28 03:41  facerecognition_guideimglibfacereccolormaplena_cool.jpg
     文件      121763  2012-07-28 03:41  facerecognition_guideimglibfacereccolormaplena_hot.jpg
     文件      162097  2012-07-28 03:41  facerecognition_guideimglibfacereccolormaplena_hsv.jpg
     文件      230060  2012-07-28 03:41  facerecognition_guideimglibfacereccolormaplena_imshow_jet.jpg
     文件      153115  2012-07-28 03:41  facerecognition_guideimglibfacereccolormaplena_jet.jpg
     文件      134351  2012-07-28 03:41  facerecognition_guideimglibfacereccolormaplena_mkpj1.jpg
............此处省略227个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)