\Ansel_Faces_User

Face recognition class

Copyright 2007-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (GPL). If you did not receive this file, see http://www.horde.org/licenses/gpl.

Summary

Methods
Properties
Constants
canAutogenerate()
getFaces()
getImageFacesData()
getGalleryFaces()
allFaces()
namedFaces()
ownerFaces()
searchFaces()
countOwnerFaces()
countAllFaces()
countNamedFaces()
countSearchFaces()
viewExists()
getFaceImageObject()
getFaceUrl()
saveCustomFace()
getFromPicture()
createView()
saveSignature()
getSignatureFromFile()
getFromGallery()
setName()
getFaceById()
getSignatureMatches()
No public properties found
No constants found
_getFaces()
_fetchFaces()
_countFaces()
_getParamsArray()
_getSignatureMatches()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

canAutogenerate()

canAutogenerate() 

getFaces()

getFaces(mixed  $image) : mixed

Get all the coordinates for faces in an image.

Parameters

mixed $image

The Ansel_Image or a path to the image to check.

Returns

mixed —

Array of face data

getImageFacesData()

getImageFacesData(integer  $image_id, boolean  $full = false) : array

Get existing faces data from storage for the given image.

Used if we need to build the face image at some point after it is detected.

Parameters

integer $image_id

The image_id of the Ansel_Image these faces are for.

boolean $full

Get full face data or just face_id and face_name.

Throws

\Ansel_Exception

Returns

array —

An array of faces data.

getGalleryFaces()

getGalleryFaces(integer  $gallery_id) : array

Get existing faces data for an entire gallery.

Parameters

integer $gallery_id

gallery_id to get data for.

Throws

\Ansel_Exception

Returns

array —

An array of faces data.

allFaces()

allFaces(integer  $from, integer  $count) : array

Get all faces

Parameters

integer $from

Offset

integer $count

Limit

Returns

array —

Array of face hashes.

namedFaces()

namedFaces(integer  $from, integer  $count) : array

Get named faces

Parameters

integer $from

Offset

integer $count

Limit

Returns

array —

An array of face hashes

ownerFaces()

ownerFaces(string  $owner, integer  $from, integer  $count) : array

Get faces owned by user

Parameters

string $owner

User

integer $from

Offset

integer $count

Limit

Returns

array —

An array of face hashes.

searchFaces()

searchFaces(string  $name, integer  $from, integer  $count) 

Seach faces for a name

Parameters

string $name

Search string

integer $from

Offset

integer $count

Limit

countOwnerFaces()

countOwnerFaces(string  $owner) 

Get faces owned by owner

Parameters

string $owner

User

countAllFaces()

countAllFaces() 

Count all faces

countNamedFaces()

countNamedFaces() 

Get named faces

countSearchFaces()

countSearchFaces(string  $name) 

Seach faces for a name

Parameters

string $name

Search string

viewExists()

viewExists(integer  $image_id, integer  $face_id, boolean  $create = true) : boolean

Checks to see that a given face image exists in the VFS.

If $create is true, the image is created if it does not exist. Otherwise false is returned if the image does not exist. True is returned both if the image already existed OR if it did not exist, but was successfully created.

Parameters

integer $image_id

The image_id the face belongs to.

integer $face_id

The face_id we are checking for.

boolean $create

Automatically create the image if it is not found.

Returns

boolean —

True if image exists at end of function call, false otherwise.

getFaceImageObject()

getFaceImageObject(integer  $face_id) : \Horde_Image

Get a Horde_Image object representing the requested face.

Parameters

integer $face_id

The requested face_id

Throws

\Ansel_Exception

Returns

\Horde_Image —

The requested Horde_Image object

getFaceUrl()

getFaceUrl(integer  $image_id, integer  $face_id, boolean  $full = false) : string

Get a URL for a face image suitable for using as the src attribute in an image tag.

Parameters

integer $image_id

Image ID to get url for

integer $face_id

Face ID to get url for

boolean $full

Should we generate a full URL?

Returns

string —

The URL for the face image suitable for use as the src attribute in an tag.

saveCustomFace()

saveCustomFace(integer  $face_id, integer  $image_id, integer  $x1, integer  $y1, integer  $x2, integer  $y2, string  $name = '') : array

Associates a given rectangle with the given image and creates the face image. Used for setting a face range explicitly.

Parameters

integer $face_id

Face id to save

integer $image_id

Image face belongs to

integer $x1

The top left corner of the cropped image.

integer $y1

The top right corner of the cropped image.

integer $x2

The bottom left corner of the cropped image.

integer $y2

The bottom right corner of the cropped image.

string $name

Face name

Throws

\Ansel_Exception,

Horde_Exception_PermissionDenied

Returns

array —

Faces found

getFromPicture()

getFromPicture(mixed  $image, \boolen  $create = false) : array

Look for and save faces in a picture, and optionally create the face image.

Parameters

mixed $image

Image Object/ID to check

\boolen $create

Create images or store data?

Throws

\Horde_Exception_PermissionDenied
\Ansel_Exception

Returns

array —

Faces found

createView()

createView(integer  $face_id, \Ansel_Image  $image, integer  $x1, integer  $y1, integer  $x2, integer  $y2) 

Create a face image from the given data.

Parameters

integer $face_id

Face id to generate

\Ansel_Image $image

Image face belongs to

integer $x1

The top left corner of the cropped image.

integer $y1

The top right corner of the cropped image.

integer $x2

The bottom left corner of the cropped image.

integer $y2

The bottom right corner of the cropped image.

Throws

\Ansel_Exception

saveSignature()

saveSignature(integer  $image_id, integer  $face_id) 

Get face signature from an existing face image.

Parameters

integer $image_id

Image ID face belongs to

integer $face_id

Face ID to check

Throws

\Ansel_Exception

getSignatureFromFile()

getSignatureFromFile(integer  $filename) : \binary

Get an image signature from an arbitrary file. Currently used when searching for faces that appear in a user-supplied image.

Parameters

integer $filename

Image filename to check

Returns

\binary —

vector signature

getFromGallery()

getFromGallery(integer  $gallery_id, \boolen  $create = false, \boolen  $force = false) : array

Get faces for all images in a gallery

Parameters

integer $gallery_id

The share_id/gallery_id of the gallery to check.

\boolen $create

Create faces and signatures or just store coordniates?

\boolen $force

Force recreation even if image has faces

Returns

array —

Faces found

setName()

setName(integer  $face, string  $name) 

Set face name

Parameters

integer $face

Face id

string $name

Face name

Throws

\Ansel_Exception

getFaceById()

getFaceById(integer  $face_id, boolean  $full = false) : array

Get face data

Parameters

integer $face_id

Face id

boolean $full

Retreive full face data?

Throws

\Ansel_Exception

Returns

array —

A face information hash

getSignatureMatches()

getSignatureMatches(\binary  $signature,   $face_id, integer  $from, integer  $count) : \binary

Get possible matches from sql index

Parameters

\binary $signature

Image signature

$face_id
integer $from

Offset

integer $count

Limit

Throws

\Ansel_Exception

Returns

\binary —

vector signature

_getFaces()

_getFaces(string  $file) 

Get faces

Parameters

string $file

Picture filename

_fetchFaces()

_fetchFaces(array  $info, integer  $from, integer  $count) : mixed

Fetchs all faces from all galleries the current user has READ access to

Parameters

array $info

Array of select criteria

integer $from

Offset

integer $count

Limit

Throws

\Ansel_Exception

Returns

mixed —

An array of face hashes containing face_id, gallery_id, image_id, face_name.

_countFaces()

_countFaces(array  $info) : integer

Count faces

Parameters

array $info

Array of select criteria

Throws

\Ansel_Exception

Returns

integer —

The count of faces

_getParamsArray()

_getParamsArray(  $image,   $rect) 

Parameters

$image
$rect

_getSignatureMatches()

_getSignatureMatches(array  $a, array  $b) 

Compare faces by similarity.

Parameters

array $a
array $b