-
Notifications
You must be signed in to change notification settings - Fork 10
/
possibleChar.php
44 lines (35 loc) · 997 Bytes
/
possibleChar.php
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
<?php
use function CV\boundingRect;
class possibleChar
{
public $contour;
/**
* @var \CV\Rect
*/
public $boundingRect;
/**
* @var int
*/
public $intCenterX;
/**
* @var int
*/
public $intCenterY;
/**
* @var double
*/
public $dblDiagonalSize;
/**
* @var double
*/
public $dblAspectRatio;
public function __construct(array $contour)
{
$this->contour = $contour;
$this->boundingRect = boundingRect($contour);
$this->intCenterX = intval(($this->boundingRect->x + $this->boundingRect->x + $this->boundingRect->width) / 2);
$this->intCenterY = intval(($this->boundingRect->y + $this->boundingRect->y + $this->boundingRect->height) / 2);
$this->dblDiagonalSize = sqrt(pow($this->boundingRect->width, 2) + pow($this->boundingRect->height, 2));
$this->dblAspectRatio = (float)$this->boundingRect->width / (float)$this->boundingRect->height;
}
}