@@ -9,80 +9,80 @@ |
||
9 | 9 | $paper = new PaperSheet(38, 54); |
10 | 10 | |
11 | 11 | for ($i = 29; $i <= 35; $i++) { |
12 | - $field = new Field('id'); |
|
13 | - $field->addMark(new Mark(19, $i, 1)); |
|
14 | - $field->addMark(new Mark(20, $i, 2)); |
|
15 | - $field->addMark(new Mark(21, $i, 3)); |
|
16 | - $field->addMark(new Mark(22, $i, 4)); |
|
17 | - $field->addMark(new Mark(23, $i, 5)); |
|
18 | - $field->addMark(new Mark(24, $i, 6)); |
|
19 | - $field->addMark(new Mark(25, $i, 7)); |
|
20 | - $field->addMark(new Mark(26, $i, 8)); |
|
21 | - $field->addMark(new Mark(27, $i, 9)); |
|
22 | - $field->addMark(new Mark(28, $i, 0)); |
|
23 | - $paper->addField($field); |
|
12 | + $field = new Field('id'); |
|
13 | + $field->addMark(new Mark(19, $i, 1)); |
|
14 | + $field->addMark(new Mark(20, $i, 2)); |
|
15 | + $field->addMark(new Mark(21, $i, 3)); |
|
16 | + $field->addMark(new Mark(22, $i, 4)); |
|
17 | + $field->addMark(new Mark(23, $i, 5)); |
|
18 | + $field->addMark(new Mark(24, $i, 6)); |
|
19 | + $field->addMark(new Mark(25, $i, 7)); |
|
20 | + $field->addMark(new Mark(26, $i, 8)); |
|
21 | + $field->addMark(new Mark(27, $i, 9)); |
|
22 | + $field->addMark(new Mark(28, $i, 0)); |
|
23 | + $paper->addField($field); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | $fieldId = 1; |
27 | 27 | |
28 | 28 | for ($i = 31; $i <= 50; $i++) { |
29 | - $field = new Field(str_pad($fieldId, 2, '0', STR_PAD_LEFT)); |
|
30 | - $field->addMark(new Mark($i, 3, 'A')); |
|
31 | - $field->addMark(new Mark($i, 4, 'B')); |
|
32 | - $field->addMark(new Mark($i, 5, 'C')); |
|
33 | - $field->addMark(new Mark($i, 6, 'D')); |
|
34 | - $field->addMark(new Mark($i, 7, 'E')); |
|
35 | - $paper->addField($field); |
|
29 | + $field = new Field(str_pad($fieldId, 2, '0', STR_PAD_LEFT)); |
|
30 | + $field->addMark(new Mark($i, 3, 'A')); |
|
31 | + $field->addMark(new Mark($i, 4, 'B')); |
|
32 | + $field->addMark(new Mark($i, 5, 'C')); |
|
33 | + $field->addMark(new Mark($i, 6, 'D')); |
|
34 | + $field->addMark(new Mark($i, 7, 'E')); |
|
35 | + $paper->addField($field); |
|
36 | 36 | |
37 | - $fieldId++; |
|
37 | + $fieldId++; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | for ($i = 31; $i <= 50; $i++) { |
41 | - $field = new Field(str_pad($fieldId, 2, '0', STR_PAD_LEFT)); |
|
42 | - $field->addMark(new Mark($i, 10, 'A')); |
|
43 | - $field->addMark(new Mark($i, 11, 'B')); |
|
44 | - $field->addMark(new Mark($i, 12, 'C')); |
|
45 | - $field->addMark(new Mark($i, 13, 'D')); |
|
46 | - $field->addMark(new Mark($i, 14, 'E')); |
|
47 | - $paper->addField($field); |
|
41 | + $field = new Field(str_pad($fieldId, 2, '0', STR_PAD_LEFT)); |
|
42 | + $field->addMark(new Mark($i, 10, 'A')); |
|
43 | + $field->addMark(new Mark($i, 11, 'B')); |
|
44 | + $field->addMark(new Mark($i, 12, 'C')); |
|
45 | + $field->addMark(new Mark($i, 13, 'D')); |
|
46 | + $field->addMark(new Mark($i, 14, 'E')); |
|
47 | + $paper->addField($field); |
|
48 | 48 | |
49 | - $fieldId++; |
|
49 | + $fieldId++; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | for ($i = 31; $i <= 50; $i++) { |
53 | - $field = new Field(str_pad($fieldId, 2, '0', STR_PAD_LEFT)); |
|
54 | - $field->addMark(new Mark($i, 17, 'A')); |
|
55 | - $field->addMark(new Mark($i, 18, 'B')); |
|
56 | - $field->addMark(new Mark($i, 19, 'C')); |
|
57 | - $field->addMark(new Mark($i, 20, 'D')); |
|
58 | - $field->addMark(new Mark($i, 21, 'E')); |
|
59 | - $paper->addField($field); |
|
53 | + $field = new Field(str_pad($fieldId, 2, '0', STR_PAD_LEFT)); |
|
54 | + $field->addMark(new Mark($i, 17, 'A')); |
|
55 | + $field->addMark(new Mark($i, 18, 'B')); |
|
56 | + $field->addMark(new Mark($i, 19, 'C')); |
|
57 | + $field->addMark(new Mark($i, 20, 'D')); |
|
58 | + $field->addMark(new Mark($i, 21, 'E')); |
|
59 | + $paper->addField($field); |
|
60 | 60 | |
61 | - $fieldId++; |
|
61 | + $fieldId++; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | for ($i = 31; $i <= 50; $i++) { |
65 | - $field = new Field(str_pad($fieldId, 2, '0', STR_PAD_LEFT)); |
|
66 | - $field->addMark(new Mark($i, 24, 'A')); |
|
67 | - $field->addMark(new Mark($i, 25, 'B')); |
|
68 | - $field->addMark(new Mark($i, 26, 'C')); |
|
69 | - $field->addMark(new Mark($i, 27, 'D')); |
|
70 | - $field->addMark(new Mark($i, 28, 'E')); |
|
71 | - $paper->addField($field); |
|
65 | + $field = new Field(str_pad($fieldId, 2, '0', STR_PAD_LEFT)); |
|
66 | + $field->addMark(new Mark($i, 24, 'A')); |
|
67 | + $field->addMark(new Mark($i, 25, 'B')); |
|
68 | + $field->addMark(new Mark($i, 26, 'C')); |
|
69 | + $field->addMark(new Mark($i, 27, 'D')); |
|
70 | + $field->addMark(new Mark($i, 28, 'E')); |
|
71 | + $paper->addField($field); |
|
72 | 72 | |
73 | - $fieldId++; |
|
73 | + $fieldId++; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | for ($i = 31; $i <= 50; $i++) { |
77 | - $field = new Field(str_pad($fieldId, 2, '0', STR_PAD_LEFT)); |
|
78 | - $field->addMark(new Mark($i, 31, 'A')); |
|
79 | - $field->addMark(new Mark($i, 32, 'B')); |
|
80 | - $field->addMark(new Mark($i, 33, 'C')); |
|
81 | - $field->addMark(new Mark($i, 34, 'D')); |
|
82 | - $field->addMark(new Mark($i, 35, 'E')); |
|
83 | - $paper->addField($field); |
|
77 | + $field = new Field(str_pad($fieldId, 2, '0', STR_PAD_LEFT)); |
|
78 | + $field->addMark(new Mark($i, 31, 'A')); |
|
79 | + $field->addMark(new Mark($i, 32, 'B')); |
|
80 | + $field->addMark(new Mark($i, 33, 'C')); |
|
81 | + $field->addMark(new Mark($i, 34, 'D')); |
|
82 | + $field->addMark(new Mark($i, 35, 'E')); |
|
83 | + $paper->addField($field); |
|
84 | 84 | |
85 | - $fieldId++; |
|
85 | + $fieldId++; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $reader = new Reader('openomr.jpg', $paper, 4); |
@@ -3,8 +3,8 @@ |
||
3 | 3 | |
4 | 4 | final class ReadingStatus |
5 | 5 | { |
6 | - const INITIAL = 0; |
|
7 | - const BLANK = 1; |
|
8 | - const SUCCESS = 2; |
|
9 | - const FAILURE = 3; |
|
6 | + const INITIAL = 0; |
|
7 | + const BLANK = 1; |
|
8 | + const SUCCESS = 2; |
|
9 | + const FAILURE = 3; |
|
10 | 10 | } |
11 | 11 | \ No newline at end of file |
@@ -8,85 +8,85 @@ |
||
8 | 8 | |
9 | 9 | class Reader |
10 | 10 | { |
11 | - private $paperSheet; |
|
12 | - private $scannedImage; |
|
13 | - private $errorMargin; |
|
11 | + private $paperSheet; |
|
12 | + private $scannedImage; |
|
13 | + private $errorMargin; |
|
14 | 14 | |
15 | - public function __construct($imageFile, PaperSheet $paperSheet, $edgeDislocation = 0, $errorMargin = 0.5) |
|
16 | - { |
|
17 | - if (!extension_loaded('imagick')) { |
|
18 | - throw new Exception\ImagickExtensionNotFoundException('Imagick extension is not loaded.'); |
|
19 | - } |
|
15 | + public function __construct($imageFile, PaperSheet $paperSheet, $edgeDislocation = 0, $errorMargin = 0.5) |
|
16 | + { |
|
17 | + if (!extension_loaded('imagick')) { |
|
18 | + throw new Exception\ImagickExtensionNotFoundException('Imagick extension is not loaded.'); |
|
19 | + } |
|
20 | 20 | |
21 | - $this->paperSheet = $paperSheet; |
|
22 | - $this->scannedImage = $this->createScannedImage($imageFile, $this->paperSheet->getMatrixLength(), $edgeDislocation); |
|
23 | - $this->errorMargin = $errorMargin; |
|
24 | - } |
|
21 | + $this->paperSheet = $paperSheet; |
|
22 | + $this->scannedImage = $this->createScannedImage($imageFile, $this->paperSheet->getMatrixLength(), $edgeDislocation); |
|
23 | + $this->errorMargin = $errorMargin; |
|
24 | + } |
|
25 | 25 | |
26 | - public function getResults() |
|
27 | - { |
|
28 | - $imageToCompare = $this->createImageWithBlackBackground($this->scannedImage->getCellWidthForComparison(), $this->scannedImage->getCellHeightForComparison()); |
|
26 | + public function getResults() |
|
27 | + { |
|
28 | + $imageToCompare = $this->createImageWithBlackBackground($this->scannedImage->getCellWidthForComparison(), $this->scannedImage->getCellHeightForComparison()); |
|
29 | 29 | |
30 | - $result = []; |
|
30 | + $result = []; |
|
31 | 31 | |
32 | - foreach ($this->paperSheet as $field) { |
|
33 | - if (!isset($result[$field->getIdentifier()])) { |
|
34 | - $result[$field->getIdentifier()] = ['status' => ReadingStatus::INITIAL, 'value' => '', 'error_margin' => 1]; |
|
35 | - } |
|
32 | + foreach ($this->paperSheet as $field) { |
|
33 | + if (!isset($result[$field->getIdentifier()])) { |
|
34 | + $result[$field->getIdentifier()] = ['status' => ReadingStatus::INITIAL, 'value' => '', 'error_margin' => 1]; |
|
35 | + } |
|
36 | 36 | |
37 | - $fieldStatus = &$result[$field->getIdentifier()]['status']; |
|
38 | - $fieldErrorMargin = &$result[$field->getIdentifier()]['error_margin']; |
|
37 | + $fieldStatus = &$result[$field->getIdentifier()]['status']; |
|
38 | + $fieldErrorMargin = &$result[$field->getIdentifier()]['error_margin']; |
|
39 | 39 | |
40 | - //if marked with wrong don't search next path |
|
41 | - if ($fieldStatus === ReadingStatus::FAILURE) { |
|
42 | - continue; |
|
43 | - } |
|
40 | + //if marked with wrong don't search next path |
|
41 | + if ($fieldStatus === ReadingStatus::FAILURE) { |
|
42 | + continue; |
|
43 | + } |
|
44 | 44 | |
45 | - //if a next char from field reset status |
|
46 | - if ($fieldStatus === ReadingStatus::SUCCESS) { |
|
47 | - $fieldStatus = ReadingStatus::INITIAL; |
|
48 | - } |
|
45 | + //if a next char from field reset status |
|
46 | + if ($fieldStatus === ReadingStatus::SUCCESS) { |
|
47 | + $fieldStatus = ReadingStatus::INITIAL; |
|
48 | + } |
|
49 | 49 | |
50 | - foreach ($field as $mark) { |
|
51 | - if ($fieldStatus === ReadingStatus::INITIAL) { |
|
52 | - $fieldStatus = ReadingStatus::BLANK; |
|
53 | - } |
|
50 | + foreach ($field as $mark) { |
|
51 | + if ($fieldStatus === ReadingStatus::INITIAL) { |
|
52 | + $fieldStatus = ReadingStatus::BLANK; |
|
53 | + } |
|
54 | 54 | |
55 | - $regionToCompare = $this->scannedImage->extractRegion($mark->getX(), $mark->getY()); |
|
55 | + $regionToCompare = $this->scannedImage->extractRegion($mark->getX(), $mark->getY()); |
|
56 | 56 | |
57 | - $differenceBetweenImages = $regionToCompare->compareImages($imageToCompare, Imagick::METRIC_ROOTMEANSQUAREDERROR); |
|
58 | - $metricResult = $differenceBetweenImages[1]; |
|
57 | + $differenceBetweenImages = $regionToCompare->compareImages($imageToCompare, Imagick::METRIC_ROOTMEANSQUAREDERROR); |
|
58 | + $metricResult = $differenceBetweenImages[1]; |
|
59 | 59 | |
60 | - if ($metricResult < $fieldErrorMargin) { |
|
61 | - $fieldErrorMargin = $metricResult; |
|
62 | - } |
|
60 | + if ($metricResult < $fieldErrorMargin) { |
|
61 | + $fieldErrorMargin = $metricResult; |
|
62 | + } |
|
63 | 63 | |
64 | - if ($metricResult <= $this->errorMargin) { |
|
65 | - //code doesn't exists difference between black square and region marked concatenate the value |
|
66 | - $result[$field->getIdentifier()]['value'] .= $mark->getValue(); |
|
64 | + if ($metricResult <= $this->errorMargin) { |
|
65 | + //code doesn't exists difference between black square and region marked concatenate the value |
|
66 | + $result[$field->getIdentifier()]['value'] .= $mark->getValue(); |
|
67 | 67 | |
68 | - $fieldStatus = ($fieldStatus === ReadingStatus::SUCCESS) ? ReadingStatus::FAILURE : ReadingStatus::SUCCESS; |
|
69 | - } |
|
68 | + $fieldStatus = ($fieldStatus === ReadingStatus::SUCCESS) ? ReadingStatus::FAILURE : ReadingStatus::SUCCESS; |
|
69 | + } |
|
70 | 70 | |
71 | - $regionToCompare->clear(); |
|
72 | - } |
|
73 | - } |
|
71 | + $regionToCompare->clear(); |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - $imageToCompare->clear(); |
|
75 | + $imageToCompare->clear(); |
|
76 | 76 | |
77 | - return $result; |
|
78 | - } |
|
77 | + return $result; |
|
78 | + } |
|
79 | 79 | |
80 | - protected function createScannedImage($imageFile, array $matrixLength, $edgeDislocation) |
|
81 | - { |
|
82 | - return new ScannedImage($imageFile, $matrixLength, $edgeDislocation); |
|
83 | - } |
|
80 | + protected function createScannedImage($imageFile, array $matrixLength, $edgeDislocation) |
|
81 | + { |
|
82 | + return new ScannedImage($imageFile, $matrixLength, $edgeDislocation); |
|
83 | + } |
|
84 | 84 | |
85 | - protected function createImageWithBlackBackground($cols, $rows) |
|
86 | - { |
|
87 | - $image = new Imagick(); |
|
88 | - $image->newImage($cols, $rows, new ImagickPixel('black')); |
|
85 | + protected function createImageWithBlackBackground($cols, $rows) |
|
86 | + { |
|
87 | + $image = new Imagick(); |
|
88 | + $image->newImage($cols, $rows, new ImagickPixel('black')); |
|
89 | 89 | |
90 | - return $image; |
|
91 | - } |
|
90 | + return $image; |
|
91 | + } |
|
92 | 92 | } |
93 | 93 | \ No newline at end of file |
@@ -5,104 +5,104 @@ |
||
5 | 5 | |
6 | 6 | class ScannedImage extends Imagick |
7 | 7 | { |
8 | - private $matrixLength; |
|
9 | - |
|
10 | - private $cellWidth; |
|
11 | - private $cellHeight; |
|
12 | - private $cellWidthForComparison; |
|
13 | - private $cellHeightForComparison; |
|
14 | - |
|
15 | - private $edgeDislocation; |
|
16 | - |
|
17 | - public function __construct($files, array $matrixLength, $edgeDislocation) |
|
18 | - { |
|
19 | - parent::__construct(realpath($files)); |
|
20 | - |
|
21 | - $this->adaptImageForReading(); |
|
22 | - |
|
23 | - $this->edgeDislocation = $edgeDislocation; |
|
24 | - $this->matrixLength = $matrixLength; |
|
25 | - } |
|
26 | - |
|
27 | - public function getCellWidth() |
|
28 | - { |
|
29 | - if (empty($this->cellWidth)) { |
|
30 | - $this->cellWidth = $this->getGeometryInfo()['width'] / $this->matrixLength[0]; |
|
31 | - } |
|
32 | - |
|
33 | - return $this->cellWidth; |
|
34 | - } |
|
35 | - |
|
36 | - public function getCellWidthForComparison() |
|
37 | - { |
|
38 | - if (empty($this->cellWidthForComparison)) { |
|
39 | - $this->cellWidthForComparison = $this->getCellWidth() - ($this->edgeDislocation * 2); |
|
40 | - } |
|
41 | - |
|
42 | - return $this->cellWidthForComparison; |
|
43 | - } |
|
44 | - |
|
45 | - public function getCellHeight() |
|
46 | - { |
|
47 | - if (empty($this->cellHeight)) { |
|
48 | - $this->cellHeight = $this->getGeometryInfo()['height'] / $this->matrixLength[1]; |
|
49 | - } |
|
50 | - |
|
51 | - return $this->cellHeight; |
|
52 | - } |
|
53 | - |
|
54 | - public function getCellHeightForComparison() |
|
55 | - { |
|
56 | - if (empty($this->cellHeightForComparison)) { |
|
57 | - $this->cellHeightForComparison = $this->getCellHeight() - ($this->edgeDislocation * 2); |
|
58 | - } |
|
59 | - |
|
60 | - return $this->cellHeightForComparison; |
|
61 | - } |
|
62 | - |
|
63 | - public function extractRegion($row, $col) |
|
64 | - { |
|
65 | - $width = $this->getCellWidthForComparison(); |
|
66 | - $height = $this->getCellHeightForComparison(); |
|
67 | - $x = ($col * $this->getCellWidth()) + $this->edgeDislocation; |
|
68 | - $y = ($row * $this->getCellHeight()) + $this->edgeDislocation; |
|
69 | - |
|
70 | - $image = $this->getImageRegion($width, $height, $x, $y); |
|
71 | - $image->setImagePage(0, 0, 0, 0); |
|
72 | - |
|
73 | - return $image; |
|
74 | - } |
|
75 | - |
|
76 | - protected function getGeometryInfo() |
|
77 | - { |
|
78 | - return $this->identifyImage()['geometry']; |
|
79 | - } |
|
80 | - |
|
81 | - protected function adaptImageForReading() |
|
82 | - { |
|
83 | - $this->enhanceImageQuality(); |
|
84 | - $this->turnImageIntoBlackAndWhite(); |
|
85 | - $this->removeEdges(); |
|
86 | - } |
|
87 | - |
|
88 | - protected function enhanceImageQuality() |
|
89 | - { |
|
90 | - $this->normalizeImage(); |
|
91 | - $this->enhanceImage(); |
|
92 | - $this->despeckleImage(); |
|
93 | - } |
|
94 | - |
|
95 | - protected function turnImageIntoBlackAndWhite() |
|
96 | - { |
|
97 | - $this->blackThresholdImage('#808080'); |
|
98 | - $this->whiteThresholdImage('#808080'); |
|
99 | - } |
|
100 | - |
|
101 | - protected function removeEdges() |
|
102 | - { |
|
103 | - $this->trimImage(85); |
|
104 | - $this->deskewImage(15); |
|
105 | - $this->trimImage(85); |
|
106 | - $this->setImagePage(0, 0, 0, 0); |
|
107 | - } |
|
8 | + private $matrixLength; |
|
9 | + |
|
10 | + private $cellWidth; |
|
11 | + private $cellHeight; |
|
12 | + private $cellWidthForComparison; |
|
13 | + private $cellHeightForComparison; |
|
14 | + |
|
15 | + private $edgeDislocation; |
|
16 | + |
|
17 | + public function __construct($files, array $matrixLength, $edgeDislocation) |
|
18 | + { |
|
19 | + parent::__construct(realpath($files)); |
|
20 | + |
|
21 | + $this->adaptImageForReading(); |
|
22 | + |
|
23 | + $this->edgeDislocation = $edgeDislocation; |
|
24 | + $this->matrixLength = $matrixLength; |
|
25 | + } |
|
26 | + |
|
27 | + public function getCellWidth() |
|
28 | + { |
|
29 | + if (empty($this->cellWidth)) { |
|
30 | + $this->cellWidth = $this->getGeometryInfo()['width'] / $this->matrixLength[0]; |
|
31 | + } |
|
32 | + |
|
33 | + return $this->cellWidth; |
|
34 | + } |
|
35 | + |
|
36 | + public function getCellWidthForComparison() |
|
37 | + { |
|
38 | + if (empty($this->cellWidthForComparison)) { |
|
39 | + $this->cellWidthForComparison = $this->getCellWidth() - ($this->edgeDislocation * 2); |
|
40 | + } |
|
41 | + |
|
42 | + return $this->cellWidthForComparison; |
|
43 | + } |
|
44 | + |
|
45 | + public function getCellHeight() |
|
46 | + { |
|
47 | + if (empty($this->cellHeight)) { |
|
48 | + $this->cellHeight = $this->getGeometryInfo()['height'] / $this->matrixLength[1]; |
|
49 | + } |
|
50 | + |
|
51 | + return $this->cellHeight; |
|
52 | + } |
|
53 | + |
|
54 | + public function getCellHeightForComparison() |
|
55 | + { |
|
56 | + if (empty($this->cellHeightForComparison)) { |
|
57 | + $this->cellHeightForComparison = $this->getCellHeight() - ($this->edgeDislocation * 2); |
|
58 | + } |
|
59 | + |
|
60 | + return $this->cellHeightForComparison; |
|
61 | + } |
|
62 | + |
|
63 | + public function extractRegion($row, $col) |
|
64 | + { |
|
65 | + $width = $this->getCellWidthForComparison(); |
|
66 | + $height = $this->getCellHeightForComparison(); |
|
67 | + $x = ($col * $this->getCellWidth()) + $this->edgeDislocation; |
|
68 | + $y = ($row * $this->getCellHeight()) + $this->edgeDislocation; |
|
69 | + |
|
70 | + $image = $this->getImageRegion($width, $height, $x, $y); |
|
71 | + $image->setImagePage(0, 0, 0, 0); |
|
72 | + |
|
73 | + return $image; |
|
74 | + } |
|
75 | + |
|
76 | + protected function getGeometryInfo() |
|
77 | + { |
|
78 | + return $this->identifyImage()['geometry']; |
|
79 | + } |
|
80 | + |
|
81 | + protected function adaptImageForReading() |
|
82 | + { |
|
83 | + $this->enhanceImageQuality(); |
|
84 | + $this->turnImageIntoBlackAndWhite(); |
|
85 | + $this->removeEdges(); |
|
86 | + } |
|
87 | + |
|
88 | + protected function enhanceImageQuality() |
|
89 | + { |
|
90 | + $this->normalizeImage(); |
|
91 | + $this->enhanceImage(); |
|
92 | + $this->despeckleImage(); |
|
93 | + } |
|
94 | + |
|
95 | + protected function turnImageIntoBlackAndWhite() |
|
96 | + { |
|
97 | + $this->blackThresholdImage('#808080'); |
|
98 | + $this->whiteThresholdImage('#808080'); |
|
99 | + } |
|
100 | + |
|
101 | + protected function removeEdges() |
|
102 | + { |
|
103 | + $this->trimImage(85); |
|
104 | + $this->deskewImage(15); |
|
105 | + $this->trimImage(85); |
|
106 | + $this->setImagePage(0, 0, 0, 0); |
|
107 | + } |
|
108 | 108 | } |
109 | 109 | \ No newline at end of file |
@@ -6,31 +6,31 @@ |
||
6 | 6 | |
7 | 7 | class PaperSheet implements IteratorAggregate |
8 | 8 | { |
9 | - private $matrixLength = []; |
|
10 | - private $fields = []; |
|
9 | + private $matrixLength = []; |
|
10 | + private $fields = []; |
|
11 | 11 | |
12 | - public function __construct($x, $y) |
|
13 | - { |
|
14 | - $this->matrixLength = [(int) $x, (int) $y]; |
|
15 | - } |
|
12 | + public function __construct($x, $y) |
|
13 | + { |
|
14 | + $this->matrixLength = [(int) $x, (int) $y]; |
|
15 | + } |
|
16 | 16 | |
17 | - public function addField(Field $field) |
|
18 | - { |
|
19 | - $this->fields[] = $field; |
|
20 | - } |
|
17 | + public function addField(Field $field) |
|
18 | + { |
|
19 | + $this->fields[] = $field; |
|
20 | + } |
|
21 | 21 | |
22 | - public function getMatrixLength() |
|
23 | - { |
|
24 | - return $this->matrixLength; |
|
25 | - } |
|
22 | + public function getMatrixLength() |
|
23 | + { |
|
24 | + return $this->matrixLength; |
|
25 | + } |
|
26 | 26 | |
27 | - public function getFields() |
|
28 | - { |
|
29 | - return $this->fields; |
|
30 | - } |
|
27 | + public function getFields() |
|
28 | + { |
|
29 | + return $this->fields; |
|
30 | + } |
|
31 | 31 | |
32 | - public function getIterator() |
|
33 | - { |
|
34 | - return new ArrayIterator($this->fields); |
|
35 | - } |
|
32 | + public function getIterator() |
|
33 | + { |
|
34 | + return new ArrayIterator($this->fields); |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | \ No newline at end of file |
@@ -3,29 +3,29 @@ |
||
3 | 3 | |
4 | 4 | class Mark |
5 | 5 | { |
6 | - private $x; |
|
7 | - private $y; |
|
8 | - private $value; |
|
6 | + private $x; |
|
7 | + private $y; |
|
8 | + private $value; |
|
9 | 9 | |
10 | - public function __construct($x, $y, $value) |
|
11 | - { |
|
12 | - $this->x = (int) $x; |
|
13 | - $this->y = (int) $y; |
|
14 | - $this->value = $value; |
|
15 | - } |
|
10 | + public function __construct($x, $y, $value) |
|
11 | + { |
|
12 | + $this->x = (int) $x; |
|
13 | + $this->y = (int) $y; |
|
14 | + $this->value = $value; |
|
15 | + } |
|
16 | 16 | |
17 | - public function getX() |
|
18 | - { |
|
19 | - return $this->x; |
|
20 | - } |
|
17 | + public function getX() |
|
18 | + { |
|
19 | + return $this->x; |
|
20 | + } |
|
21 | 21 | |
22 | - public function getY() |
|
23 | - { |
|
24 | - return $this->y; |
|
25 | - } |
|
22 | + public function getY() |
|
23 | + { |
|
24 | + return $this->y; |
|
25 | + } |
|
26 | 26 | |
27 | - public function getValue() |
|
28 | - { |
|
29 | - return $this->value; |
|
30 | - } |
|
27 | + public function getValue() |
|
28 | + { |
|
29 | + return $this->value; |
|
30 | + } |
|
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -6,31 +6,31 @@ |
||
6 | 6 | |
7 | 7 | class Field implements IteratorAggregate |
8 | 8 | { |
9 | - private $identifier; |
|
10 | - private $marks = []; |
|
9 | + private $identifier; |
|
10 | + private $marks = []; |
|
11 | 11 | |
12 | - public function __construct($identifier) |
|
13 | - { |
|
14 | - $this->identifier = $identifier; |
|
15 | - } |
|
12 | + public function __construct($identifier) |
|
13 | + { |
|
14 | + $this->identifier = $identifier; |
|
15 | + } |
|
16 | 16 | |
17 | - public function addMark(Mark $mark) |
|
18 | - { |
|
19 | - $this->marks[] = $mark; |
|
20 | - } |
|
17 | + public function addMark(Mark $mark) |
|
18 | + { |
|
19 | + $this->marks[] = $mark; |
|
20 | + } |
|
21 | 21 | |
22 | - public function getIdentifier() |
|
23 | - { |
|
24 | - return $this->identifier; |
|
25 | - } |
|
22 | + public function getIdentifier() |
|
23 | + { |
|
24 | + return $this->identifier; |
|
25 | + } |
|
26 | 26 | |
27 | - public function getMarks() |
|
28 | - { |
|
29 | - return $this->marks; |
|
30 | - } |
|
27 | + public function getMarks() |
|
28 | + { |
|
29 | + return $this->marks; |
|
30 | + } |
|
31 | 31 | |
32 | - public function getIterator() |
|
33 | - { |
|
34 | - return new ArrayIterator($this->marks); |
|
35 | - } |
|
32 | + public function getIterator() |
|
33 | + { |
|
34 | + return new ArrayIterator($this->marks); |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | \ No newline at end of file |