PHP Class Ansel_Faces_Base, horde

Copyright 2007-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (GPL). If you did not receive this file, see http://www.horde.org/licenses/gpl.
Author: Duck ([email protected])
Show file Open project: horde/horde

Public Methods

Method Description
allFaces ( integer $from, integer $count ) : array Get all faces
canAutogenerate ( )
countAllFaces ( ) Count all faces
countNamedFaces ( ) Get named faces
countOwnerFaces ( string $owner ) Get faces owned by owner
countSearchFaces ( string $name ) Seach faces for a name
createView ( integer $face_id, Ansel_Image $image, integer $x1, integer $y1, integer $x2, integer $y2 ) Create a face image from the given data.
getFaceById ( integer $face_id, boolean $full = false ) : array Get face data
getFaceImageObject ( integer $face_id ) : Horde_Image Get a Horde_Image object representing the requested face.
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.
getFaces ( Ansel_Image $image ) : mixed Get all the coordinates for faces in an image.
getFromGallery ( integer $gallery_id, boolen $create = false, boolen $force = false ) : array Get faces for all images in a gallery
getFromPicture ( mixed $image, boolen $create = false ) : array Look for and save faces in a picture, and optionally create the face image.
getGalleryFaces ( integer $gallery_id ) : array Get existing faces data for an entire gallery.
getImageFacesData ( integer $image_id, boolean $full = false ) : array Get existing faces data from storage for the given image.
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.
getSignatureMatches ( binary $signature, $face_id, integer $from, integer $count ) : binary Get possible matches from sql index
namedFaces ( integer $from, integer $count ) : array Get named faces
ownerFaces ( string $owner, integer $from, integer $count ) : array Get faces owned by user
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.
saveSignature ( integer $image_id, integer $face_id ) Get face signature from an existing face image.
searchFaces ( string $name, integer $from, integer $count ) Seach faces for a name
setName ( integer $face, string $name ) Set face name
viewExists ( integer $image_id, integer $face_id, boolean $create = true ) : boolean Checks to see that a given face image exists in the VFS.

Protected Methods

Method Description
_countFaces ( array $info ) : integer Count faces
_fetchFaces ( array $info, integer $from, integer $count ) : mixed Fetchs all faces from all galleries the current user has READ access to
_getFaces ( string $file ) Get faces
_getParamsArray ( $image, $rect )
_getSignatureMatches ( array $a, array $b ) Compare faces by similarity.

Method Details

_countFaces() protected method

Count faces
protected _countFaces ( array $info ) : integer
$info array Array of select criteria
return integer The count of faces

_fetchFaces() protected method

Fetchs all faces from all galleries the current user has READ access to
protected _fetchFaces ( array $info, integer $from, integer $count ) : mixed
$info array Array of select criteria
$from integer Offset
$count integer Limit
return mixed An array of face hashes containing face_id, gallery_id, image_id, face_name.

_getFaces() protected method

Get faces
protected _getFaces ( string $file )
$file string Picture filename

_getParamsArray() protected method

protected _getParamsArray ( $image, $rect )

_getSignatureMatches() protected method

Compare faces by similarity.
protected _getSignatureMatches ( array $a, array $b )
$a array
$b array

allFaces() public method

Get all faces
public allFaces ( integer $from, integer $count ) : array
$from integer Offset
$count integer Limit
return array Array of face hashes.

canAutogenerate() public method

public canAutogenerate ( )

countAllFaces() public method

Count all faces
public countAllFaces ( )

countNamedFaces() public method

Get named faces
public countNamedFaces ( )

countOwnerFaces() public method

Get faces owned by owner
public countOwnerFaces ( string $owner )
$owner string User

countSearchFaces() public method

Seach faces for a name
public countSearchFaces ( string $name )
$name string Search string

createView() public method

Create a face image from the given data.
public createView ( integer $face_id, Ansel_Image $image, integer $x1, integer $y1, integer $x2, integer $y2 )
$face_id integer Face id to generate
$image Ansel_Image Image face belongs to
$x1 integer The top left corner of the cropped image.
$y1 integer The top right corner of the cropped image.
$x2 integer The bottom left corner of the cropped image.
$y2 integer The bottom right corner of the cropped image.

getFaceById() public method

Get face data
public getFaceById ( integer $face_id, boolean $full = false ) : array
$face_id integer Face id
$full boolean Retreive full face data?
return array A face information hash

getFaceImageObject() public method

Get a Horde_Image object representing the requested face.
public getFaceImageObject ( integer $face_id ) : Horde_Image
$face_id integer The requested face_id
return Horde_Image The requested Horde_Image object

getFaceUrl() public method

Get a URL for a face image suitable for using as the src attribute in an image tag.
public getFaceUrl ( integer $image_id, integer $face_id, boolean $full = false ) : string
$image_id integer Image ID to get url for
$face_id integer Face ID to get url for
$full boolean Should we generate a full URL?
return string The URL for the face image suitable for use as the src attribute in an tag.

getFaces() public method

Get all the coordinates for faces in an image.
public getFaces ( Ansel_Image $image ) : mixed
$image Ansel_Image The Ansel_Image or a path to the image to check.
return mixed Array of face data

getFromGallery() public method

Get faces for all images in a gallery
public getFromGallery ( integer $gallery_id, boolen $create = false, boolen $force = false ) : array
$gallery_id integer The share_id/gallery_id of the gallery to check.
$create boolen Create faces and signatures or just store coordniates?
$force boolen Force recreation even if image has faces
return array Faces found

getFromPicture() public method

Look for and save faces in a picture, and optionally create the face image.
public getFromPicture ( mixed $image, boolen $create = false ) : array
$image mixed Image Object/ID to check
$create boolen Create images or store data?
return array Faces found

getGalleryFaces() public method

Get existing faces data for an entire gallery.
public getGalleryFaces ( integer $gallery_id ) : array
$gallery_id integer gallery_id to get data for.
return array An array of faces data.

getImageFacesData() public method

Used if we need to build the face image at some point after it is detected.
public getImageFacesData ( integer $image_id, boolean $full = false ) : array
$image_id integer The image_id of the Ansel_Image these faces are for.
$full boolean Get full face data or just face_id and face_name.
return array An array of faces data.

getSignatureFromFile() public method

Get an image signature from an arbitrary file. Currently used when searching for faces that appear in a user-supplied image.
public getSignatureFromFile ( integer $filename ) : binary
$filename integer Image filename to check
return binary vector signature

getSignatureMatches() public method

Get possible matches from sql index
public getSignatureMatches ( binary $signature, $face_id, integer $from, integer $count ) : binary
$signature binary Image signature
$from integer Offset
$count integer Limit
return binary vector signature

namedFaces() public method

Get named faces
public namedFaces ( integer $from, integer $count ) : array
$from integer Offset
$count integer Limit
return array An array of face hashes

ownerFaces() public method

Get faces owned by user
public ownerFaces ( string $owner, integer $from, integer $count ) : array
$owner string User
$from integer Offset
$count integer Limit
return array An array of face hashes.

saveCustomFace() public method

Associates a given rectangle with the given image and creates the face image. Used for setting a face range explicitly.
public saveCustomFace ( integer $face_id, integer $image_id, integer $x1, integer $y1, integer $x2, integer $y2, string $name = '' ) : array
$face_id integer Face id to save
$image_id integer Image face belongs to
$x1 integer The top left corner of the cropped image.
$y1 integer The top right corner of the cropped image.
$x2 integer The bottom left corner of the cropped image.
$y2 integer The bottom right corner of the cropped image.
$name string Face name
return array Faces found

saveSignature() public method

Get face signature from an existing face image.
public saveSignature ( integer $image_id, integer $face_id )
$image_id integer Image ID face belongs to
$face_id integer Face ID to check

searchFaces() public method

Seach faces for a name
public searchFaces ( string $name, integer $from, integer $count )
$name string Search string
$from integer Offset
$count integer Limit

setName() public method

Set face name
public setName ( integer $face, string $name )
$face integer Face id
$name string Face name

viewExists() public method

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.
public viewExists ( integer $image_id, integer $face_id, boolean $create = true ) : boolean
$image_id integer The image_id the face belongs to.
$face_id integer The face_id we are checking for.
$create boolean Automatically create the image if it is not found.
return boolean True if image exists at end of function call, false otherwise.