/usr/share/horde/ansel/lib/Faces/Facedetect.php is in php-horde-ansel 3.0.5+debian0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | <?php
/**
* Face_detect implementation
*
* @author Duck <duck@obala.net>
* @package Ansel
*/
class Ansel_Faces_Facedetect extends Ansel_Faces_Base
{
/**
* Where the face defintions are stored
*/
private $_defs = '';
/**
* Create instance
*/
public function __construct($params)
{
$this->_defs = $params['defs'];
}
/**
*
*/
public function canAutogenerate()
{
return true;
}
/**
* Get faces
*
* @param string $file Picture filename
* @throws Horde_Exception
*/
protected function _getFaces($file)
{
if (!Horde_Util::loadExtension('facedetect')) {
throw new Ansel_Exception('You do not have the facedetect extension enabled in PHP');
}
return face_detect($file, $this->_defs);
}
/**
* Check if a face in is inside anoter face
*
* @param array $face Face we are cheking
* @param array $faces Existing faces
*
* @param int Face ID containg passed face
*/
protected function _isInFace($face, $faces)
{
foreach ($faces as $id => $rect) {
if ($face['x'] > $rect['x'] && $face['x'] + $face['w'] < $face['x'] + $rect['w']
&& $face['y'] > $rect['y'] && $face['y'] + $face['h'] < $face['y'] + $rect['h']) {
return $id;
}
}
return false;
}
protected function _createView($face_id, $image, $rect)
{
return $this->createView(
$face_id,
$image,
$rect['x'],
$rect['y'],
$rect['x'] + $rect['w'],
$rect['y'] + $rect['h']);
}
}
|