From 15cd10b35738bd61b653b951259d0b19ce99fc3b Mon Sep 17 00:00:00 2001 From: Guillaume Fauvet Date: Wed, 13 Sep 2017 17:30:03 +0200 Subject: [PATCH] Tesseract class --- build/service/Tesseract.php | 91 +++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 build/service/Tesseract.php diff --git a/build/service/Tesseract.php b/build/service/Tesseract.php new file mode 100755 index 0000000..e025f62 --- /dev/null +++ b/build/service/Tesseract.php @@ -0,0 +1,91 @@ + New Tesseract + * + ---------------------------------------------------------*/ + public function __construct($filename){ + $this->filename = $filename; + + return $this; + } + + + + /* (2) Read the image file + * + * @return this + * + ---------------------------------------------------------*/ + public function read(){ + + /* [1] Record the text from the image + =========================================================*/ + $filename = $this->filename; + $this->content = shell_exec("tesseract $filename stdout -l fra"); + + $lists = explode(chr(10), $this->content); + + if (count($lists) < 3) { + throw new \Exception('Result not interpreted'); + } + + $this->course = $lists[0]; + $this->teacher = $lists[1]; + $this->room = $lists[2]; + + return $this; + } + + /* (3) Return the text readed by the Tesseract OCR + * + * @return $this->content + * + ---------------------------------------------------------*/ + public function getContent() { + return $this->content; + } + + /* (4) Return the course readed by the Tesseract OCR + * + * @return $this->course + * + ---------------------------------------------------------*/ + public function getCourse() { + return $this->course; + } + + /* (5) Return the teacher readed by the Tesseract OCR + * + * @return $this->teacher + * + ---------------------------------------------------------*/ + public function getTeacher() { + return $this->teacher; + } + + /* (6) Return the room class readed by the Tesseract OCR + * + * @return $this->room + * + ---------------------------------------------------------*/ + public function getRoom() { + return $this->room; + } + + + } \ No newline at end of file