Overview

Packages

  • Ansel
  • None

Classes

  • Ansel
  • Ansel_Ajax_Application
  • Ansel_Ajax_Imple_EditCaption
  • Ansel_Ajax_Imple_EditFaces
  • Ansel_Ajax_Imple_EditGalleryFaces
  • Ansel_Ajax_Imple_Embed
  • Ansel_Ajax_Imple_GallerySlugCheck
  • Ansel_Ajax_Imple_ImageSaveGeotag
  • Ansel_Ajax_Imple_LocationAutoCompleter
  • Ansel_Ajax_Imple_MapLayerSelect
  • Ansel_Ajax_Imple_TagActions
  • Ansel_Ajax_Imple_ToggleGalleryActions
  • Ansel_Ajax_Imple_ToggleOtherGalleries
  • Ansel_Ajax_Imple_UploadNotification
  • Ansel_Api
  • Ansel_Exception
  • Ansel_Faces
  • Ansel_Faces_Base
  • Ansel_Faces_Facedetect
  • Ansel_Faces_User
  • Ansel_Factory_Faces
  • Ansel_Factory_Storage
  • Ansel_Factory_Styles
  • Ansel_Form_Ecard
  • Ansel_Form_Image
  • Ansel_Form_ImageDate
  • Ansel_Form_Upload
  • Ansel_Gallery
  • Ansel_Gallery_Decorator_Date
  • Ansel_GalleryMode_Base
  • Ansel_GalleryMode_Date
  • Ansel_GalleryMode_Normal
  • Ansel_Image
  • Ansel_ImageGenerator
  • Ansel_ImageGenerator_Mini
  • Ansel_ImageGenerator_PolaroidThumb
  • Ansel_ImageGenerator_PolaroidThumbStack
  • Ansel_ImageGenerator_RoundedThumb
  • Ansel_ImageGenerator_RoundedThumbStack
  • Ansel_ImageGenerator_Screen
  • Ansel_ImageGenerator_ShadowThumb
  • Ansel_ImageGenerator_ShadowThumbStack
  • Ansel_ImageGenerator_SquareThumb
  • Ansel_ImageGenerator_Thumb
  • Ansel_LoginTasks_SystemTask_Upgrade
  • Ansel_Report
  • Ansel_Report_letter
  • Ansel_Report_mail
  • Ansel_Report_tickets
  • Ansel_Search
  • Ansel_Search_exif
  • Ansel_Search_Tag
  • Ansel_Storage
  • Ansel_Style
  • Ansel_Tagger
  • Ansel_Test
  • Ansel_Tile_DateGallery
  • Ansel_Tile_Gallery
  • Ansel_Tile_Image
  • Ansel_View_Ansel
  • Ansel_View_Base
  • Ansel_View_EmbeddedRenderer_GalleryLink
  • Ansel_View_EmbeddedRenderer_Mini
  • Ansel_View_EmbeddedRenderer_Slideshow
  • Ansel_View_Gallery
  • Ansel_View_GalleryProperties
  • Ansel_View_GalleryRenderer_Base
  • Ansel_View_GalleryRenderer_Gallery
  • Ansel_View_GalleryRenderer_GalleryLightbox
  • Ansel_View_Image
  • Ansel_View_List
  • Ansel_View_Results
  • Ansel_View_Slideshow
  • Ansel_View_Upload
  • Ansel_Widget
  • Ansel_Widget_Actions
  • Ansel_Widget_Base
  • Ansel_Widget_GalleryFaces
  • Ansel_Widget_Geotag
  • Ansel_Widget_ImageFaces
  • Ansel_Widget_Links
  • Ansel_Widget_OtherGalleries
  • Ansel_Widget_OwnerFaces
  • Ansel_Widget_SimilarPhotos
  • Ansel_Widget_Tags
  • Ansel_XPPublisher
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Face_detect implementation
 4:  *
 5:  * @author  Duck <duck@obala.net>
 6:  * @package Ansel
 7:  */
 8: class Ansel_Faces_Facedetect extends Ansel_Faces_Base
 9: {
10:     /**
11:      * Where the face defintions are stored
12:      */
13:     private $_defs = '';
14: 
15:     /**
16:      * Create instance
17:      */
18:     public function __construct($params)
19:     {
20:         $this->_defs = $params['defs'];
21:     }
22: 
23:     /**
24:      *
25:      */
26:     public function canAutogenerate()
27:     {
28:         return true;
29:     }
30: 
31:     /**
32:      * Get faces
33:      *
34:      * @param string $file Picture filename
35:      * @throws Horde_Exception
36:      */
37:     protected function _getFaces($file)
38:     {
39:         if (!Horde_Util::loadExtension('facedetect')) {
40:             throw new Horde_Exception('You do not have the facedetect extension enabled in PHP');
41:         }
42: 
43:         return face_detect($file, $this->_defs);
44:     }
45: 
46:     /**
47:      * Check if a face in is inside anoter face
48:      *
49:      * @param array $face  Face we are cheking
50:      * @param array $faces Existing faces
51:      *
52:      * @param int Face ID containg passed face
53:      */
54:     protected function _isInFace($face, $faces)
55:     {
56:         foreach ($faces as $id => $rect) {
57:             if ($face['x'] > $rect['x'] && $face['x'] + $face['w'] < $face['x'] + $rect['w']
58:                 && $face['y'] > $rect['y'] && $face['y'] + $face['h'] < $face['y'] + $rect['h']) {
59:                 return $id;
60:             }
61:         }
62: 
63:         return false;
64:     }
65: 
66:     protected function _createView($face_id, $image, $rect)
67:     {
68:         return $this->createView(
69:             $face_id,
70:             $image,
71:             $rect['x'],
72:             $rect['y'],
73:             $rect['x'] + $rect['w'],
74:             $rect['y'] + $rect['h']);
75:     }
76: 
77: }
78: 
API documentation generated by ApiGen