Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,038

HOME > PHP > PHP Forum > สอบถามว่า มีวิธีไหน ที่จะเอา Code Tesseract.js v2.1.4 จาก https://www.thaicreate.com/php/forum/135891.html ตรงที่ความคิดเห็นที่ 4 ที่แก้ปัญหาเรื่อง ค้างที่หน้า initialized api แล้ว มาใช้กับระบบ OCR เดิม ที่ใช้คู่กับ Tesseract.js v2.1.0 ได้ครับ


[PHP] สอบถามว่า มีวิธีไหน ที่จะเอา Code Tesseract.js v2.1.4 จาก https://www.thaicreate.com/php/forum/135891.html ตรงที่ความคิดเห็นที่ 4 ที่แก้ปัญหาเรื่อง ค้างที่หน้า initialized api แล้ว มาใช้กับระบบ OCR เดิม ที่ใช้คู่กับ Tesseract.js v2.1.0 ได้ครับ

 
Topic : 135900



โพสกระทู้ ( 131 )
บทความ ( 14 )



สถานะออฟไลน์



สอบถามว่า มีวิธีไหน ที่จะเอา Code Tesseract.js v2.1.4 จาก https://www.thaicreate.com/php/forum/135891.html ตรงที่ความคิดเห็นที่ 4 ที่แก้ปัญหาเรื่อง ค้างที่หน้า initialized api แล้ว มาใช้กับระบบ OCR เดิม ที่ใช้คู่กับ Tesseract.js v2.1.0 ได้ครับ

Code ทั้งหมด มีดังนี้ครับ

1. Code Tesseract.js v2.1.4 จาก https://www.thaicreate.com/php/forum/135891.html ตรงที่ความคิดเห็นที่ 4 ที่แก้ปัญหาเรื่อง ค้างที่หน้า initialized api แล้ว ที่ต้องการมาใช้กับระบบ OCR เดิม ที่ใช้คู่กับ Tesseract.js v2.1.0 ได้ครับ

01.<!doctype html>
02.<html>
03.<head>
04.  <title>ทดสอบ Tesseract.js 4</title>
05.</head>
06.<body>
07.<p id="status"></p>
09.<script>
10.    var sta = document.getElementById("status");
11.     
12.    /* Code to crossOrigin = anonymous */
13.    var recogImage = new Image;
14.    recogImage.crossOrigin = "anonymous"; /* THIS WILL MAKE THE IMAGE CROSS-ORIGIN */
15.    recogImage.src = "http://localhost/ocrtest2021/test-ocr-2021.jpg";
16. 
17.    const worker = Tesseract.createWorker({
18.      logger: m => sta.innerHTML = m.status
19.    });
20.    Tesseract.setLogging(true);
21.    work();
22. 
23.    async function work() {
24.      await worker.load();
25.      await worker.loadLanguage('eng+tha');
26.      await worker.initialize('eng+tha');
27. 
28.      //let result = await worker.detect(recogImage);
29.      //console.log(result.data);
30. 
31.      let result = await worker.recognize(recogImage);
32.      sta.innerHTML = result.data.text;
33. 
34.      await worker.terminate();
35.    }
36.     
38.</script>
39.</body>
40.</html>


2. ไฟล์ ocradd.php ที่เป็น Code ระบบ OCR เดิม ที่ใช้คู่กับ Tesseract.js v2.1.0 ครับ

001.<!DOCTYPE html>
002.<html>
003.<meta charset="UTF-8">
005.<script src="js/bootstrap.min.js"></script>
006.<script src="js/tesseract.js"></script>
007.<script>
008. 
009.    $(document).ready(function(){
010.     
011.      createorc($("#dataface").attr("src"));
012. 
013.    function readURL(input) {
014. 
015.        if (input[0].value != "") {
016.            var reader = new FileReader();
017.             
018.            reader.onload = function (e) {
019.                    createorc(e.target.result);
020.            }
021.             
022.            reader.readAsDataURL(input[0].files[0]);
023.          }
024.}
025. 
026.      function createorc(result){
027.       
028.       var img = '<img id="dataface" src="'+result+'" style="max-width:100%;">';
029.       
030.        $("#preview").html(img).promise().done(function(){
031.         
032.        Tesseract.recognize(result,{lang: $(".langdetect").val()})     
033.       .progress(function  (p) { $("#loading").show(); })
034.       .then(data => {
035.       
036.            $(".addvalue4").html(data.text.replace(/\n/g, ""));
037.             
038.       })
039.       .catch(err => {
040.        //console.log('catch\n', err);
041.        })
042.       .finally(e => {
043.  
044.       $("#loading").hide();
045.           
046.        });
047.        }
048.        )
049.        }
050. 
051.  $( "#imagebroswer" ).change(function() {
052.                readURL($(this));
053.    });
054.   });
055.</script>
056.<head>
057.<style type="text/css">
058.@font-face {
059.  font-family: THSarabun;
060.  src: url(thsarabunnew-webfont.woff);
061.}
062. 
063.html {
064.  font-family: THSarabun;
065.}
066. 
067.p {display:inline;}
068. 
069.details {display: inline-block;}
070. 
071.div.textpopup {
072.  border: 2px solid black;
073.  width: 670px;
074.  padding: 10px;
075.  margin: 20px;
076.}
077. 
078.#loading {
079.    display:none;
080.    top: 0;
081.    left: 0;
082.    background-color: rgba(255,255,255,.9);
083.    min-width: 100%;
084.    min-height: 100%;
085.    height: auto;
086.    position: fixed;
087.    z-index: 100000000;
088.}
089.     
090..abx{
091.    position: absolute;
092.    width:100%;
093.    text-align: center;
094.    top:25%;
095.}
096. 
097.details > summary {
098.  list-style: none;
099.}
100. 
101.details > summary::-webkit-details-marker {
102.  display: none;
103.}
104. 
105.</style>
106.</head>
107. 
108.<body>
109.<div id="loading">
110.  <div class="abx">
111.     <div align="center" style="font-size: 50px;"><strong>กำลัง Load รูปภาพ</strong></div><br><br>
112.     <div align="center"><img src="loading.gif"></div>
113.  </div>
114.</div>
115. 
116.<form action="save2.php" name="frmAdd" id="frmAdd" method="post" enctype="multipart/form-data">
117. 
118.<div class="textpopup">
119. 
120.<details>
121.<summary>ทดสอบระบบ OCR ครับ</summary>
122.<div id="form-group1" class="form-group">
123.  <div class="col-md-3">
124.  <label for="">เลือกภาษา</label>
125.  <select class="form-control langdetect" >
126.  <option value='eng' selected> English  </option>
127.  <option value='tha'> Thai </option>
128.  </select>
129.  </div>
130.    
131.  <div class="col-md-3">
132.  <label for="">เลือกรูป</label>
133.  <input class="form-control" name="imagebroswer" id="imagebroswer" type="file">
134.  </div>
135.   
136.  <div id="preview" class="col-md-6">     
137.  <img id="dataface" src="txtsample.png"  style="max-width:100%;">
138.  </div>
139. 
140.</div>
141.</details>
142. 
143.<textarea rows="1" cols="14" class="addvalue4 " name="addvalue4" style="border:none; resize:none;"></textarea>
144. 
145.</tbody>
146.</table>
147.</div>
148. 
149.</form>
150. 
151.<script>
152.    $(document).keypress(
153.  function(event){
154.    if (event.which == '13') {
155.      event.preventDefault();
156.    }
157.    });
158.</script>
159. 
160.<script>
161.  var today = new Date();
162.  var date = today.getDate()+'/'+(today.getMonth()+1)+'/'+(today.getFullYear()+543);
163.  document.getElementById("addvalue1").value = date;
164.</script>
165. 
166.</body>
167.</html>


3. Link โหลดไฟล์ Code ทั้งหมด เกี่ยวกับ ระบบ OCR เดิม ที่ใช้คู่กับ Tesseract.js v2.1.0 ได้ครับ

https://drive.google.com/file/d/14L2wFkzCeY3KRt3rksUKjs85wSZbpxdu/view?usp=sharing

4. VDO ยืนยัน เรื่อง Code ระบบ OCR เดิม ที่ใช้คู่กับ Tesseract.js v2.1.0 ได้ครับ

https://www.youtube.com/watch?v=hh0eQjDiIEs&feature=youtu.be

5. รูปที่ใช้ในการทดสอบเรื่อง OCR ของ Code ตามข้อ 2 ครับ

thai ocr one line test



Tag : PHP, HTML, HTML5, JavaScript, XAMPP, Windows

Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2021-02-11 19:55:54 By : doanga2007 View : 1468 Reply : 4
 

 

No. 1



โพสกระทู้ ( 210 )
บทความ ( 0 )



สถานะออฟไลน์


ถ้า 2.1.0 ทำได้ 2.1.4 ก็น่าจะทำได้ เพราะเป็น gen 2.x เหมือนกัน

เปลี่ยนแค่ tesseract.js ไม่ได้หรือครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2021-02-12 13:41:33 By : lakornworld
 

 

No. 2



โพสกระทู้ ( 131 )
บทความ ( 14 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 1 เขียนโดย : lakornworld เมื่อวันที่ 2021-02-12 13:41:33
รายละเอียดของการตอบ ::
ได้ลอง เปลี่ยนแค่ Tesseract.js เป็นรุ่น 2.1.4 แล้ว Code ไม่ทำงาน ซึ่งสังเกตได้จาก หน้า Loading ไม่ทำงาน ครับ

Code ทั้งหมด มีดังนี้ครับ

1. Code Tesseract.js v2.1.4 ที่ได้ลอง เปลี่ยนแค่ Tesseract.js เป็นรุ่น 2.1.4 แล้ว Code ไม่ทำงานครับ

001.<!DOCTYPE html>
002.<html>
003.<meta charset="UTF-8">
005.<script src="js/bootstrap.min.js"></script>
006.<script src="js/tesseract214.min.js"></script>
007.<script>
008. 
009.    $(document).ready(function(){
010.     
011.      createorc($("#dataface").attr("src"));
012. 
013.    function readURL(input) {
014. 
015.        if (input[0].value != "") {
016.            var reader = new FileReader();
017.             
018.            reader.onload = function (e) {
019.                    createorc(e.target.result);
020.            }
021.             
022.            reader.readAsDataURL(input[0].files[0]);
023.          }
024.}
025. 
026.      function createorc(result){
027.       
028.       var img = '<img id="dataface" src="'+result+'" style="max-width:100%;">';
029.       
030.        $("#preview").html(img).promise().done(function(){
031.         
032.        Tesseract.recognize(result,{lang: $(".langdetect").val()})     
033.       .progress(function  (p) { $("#loading").show(); })
034.       .then(data => {
035.       
036.            $(".addvalue4").html(data.text.replace(/\n/g, ""));
037.             
038.       })
039.       .catch(err => {
040.        //console.log('catch\n', err);
041.        })
042.       .finally(e => {
043.  
044.       $("#loading").hide();
045.           
046.        });
047.        }
048.        )
049.        }
050. 
051.  $( "#imagebroswer" ).change(function() {
052.                readURL($(this));
053.    });
054.   });
055.</script>
056.<head>
057.<style type="text/css">
058.@font-face {
059.  font-family: THSarabun;
060.  src: url(thsarabunnew-webfont.woff);
061.}
062. 
063.html {
064.  font-family: THSarabun;
065.}
066. 
067.p {display:inline;}
068. 
069.details {display: inline-block;}
070. 
071.div.textpopup {
072.  border: 2px solid black;
073.  width: 670px;
074.  padding: 10px;
075.  margin: 20px;
076.}
077. 
078.#loading {
079.    display:none;
080.    top: 0;
081.    left: 0;
082.    background-color: rgba(255,255,255,.9);
083.    min-width: 100%;
084.    min-height: 100%;
085.    height: auto;
086.    position: fixed;
087.    z-index: 100000000;
088.}
089.     
090..abx{
091.    position: absolute;
092.    width:100%;
093.    text-align: center;
094.    top:25%;
095.}
096. 
097.details > summary {
098.  list-style: none;
099.}
100. 
101.details > summary::-webkit-details-marker {
102.  display: none;
103.}
104. 
105.</style>
106.</head>
107. 
108.<body>
109.<div id="loading">
110.  <div class="abx">
111.     <div align="center" style="font-size: 50px;"><strong>กำลัง Load รูปภาพ</strong></div><br><br>
112.     <div align="center"><img src="loading.gif"></div>
113.  </div>
114.</div>
115. 
116.<form action="save2.php" name="frmAdd" id="frmAdd" method="post" enctype="multipart/form-data">
117. 
118.<div class="textpopup">
119. 
120.<details>
121.<summary>ทดสอบระบบ OCR ครับ</summary>
122.<div id="form-group1" class="form-group">
123.  <div class="col-md-3">
124.  <label for="">เลือกภาษา</label>
125.  <select class="form-control langdetect" >
126.  <option value='tha' selected> Thai </option>
127.  <option value='eng'> English  </option>
128.  </select>
129.  </div>
130.    
131.  <div class="col-md-3">
132.  <label for="">เลือกรูป</label>
133.  <input class="form-control" name="imagebroswer" id="imagebroswer" type="file">
134.  </div>
135.   
136.  <div id="preview" class="col-md-6">     
137.  <img id="dataface" src="txtsample.png"  style="max-width:100%;">
138.  </div>
139. 
140.</div>
141.</details>
142. 
143.<textarea rows="1" cols="14" class="addvalue4 " name="addvalue4" style="border:none; resize:none;"></textarea>
144. 
145.</tbody>
146.</table>
147.</div>
148. 
149.</form>
150. 
151.<script>
152.    $(document).keypress(
153.  function(event){
154.    if (event.which == '13') {
155.      event.preventDefault();
156.    }
157.    });
158.</script>
159. 
160.<script>
161.  var today = new Date();
162.  var date = today.getDate()+'/'+(today.getMonth()+1)+'/'+(today.getFullYear()+543);
163.  document.getElementById("addvalue1").value = date;
164.</script>
165. 
166.</body>
167.</html>


2. ไฟล์ Tesseract.js v2.1.4 ครับ

https://pastebin.com/Ut2SK8AN

3. Link โหลดไฟล์ Code Tesseract.js v2.1.4 ทั้งหมด ที่ได้ลอง เปลี่ยนแค่ Tesseract.js เป็นรุ่น 2.1.4 แล้ว Code ไม่ทำงานครับ

https://drive.google.com/file/d/1j6uQ_FJA-qyHDkzKRSSGgt8hZQszH154/view?usp=sharing

4. VDO ยืนยัน เรื่อง Code Tesseract.js v2.1.4 ทั้งหมด ที่ได้ลอง เปลี่ยนแค่ Tesseract.js เป็นรุ่น 2.1.4 แล้ว Code ไม่ทำงานครับ

https://www.youtube.com/watch?v=apKXmK1FiPw&feature=youtu.be




ประวัติการแก้ไข
2021-02-13 20:58:08
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2021-02-13 20:51:44 By : doanga2007
 

 

No. 3



โพสกระทู้ ( 210 )
บทความ ( 0 )



สถานะออฟไลน์


ผมโดนต้มซะเปื่อยเลย ของเดิมเป็น tesseract.js 1.0.10 นะครับไม่ใช่ 2.1.0 มันคนละ gen กัน ถึงว่าทำไมเปลี่ยนแค่ js ไม่ได้

ทดสอบ tesseract.js 2.1.4
001.<!DOCTYPE html>
002.<html>
003.  <head>
004.    <meta charset="UTF-8">
005.    <link rel="stylesheet" href="css/bootstrap.min.css">
006.    <style type="text/css">
007.      @font-face {
008.        font-family: THSarabun;
009.        src: url(thsarabunnew-webfont.woff);
010.      }
011.       
012.      html,
013.      body {
014.        font-family: THSarabun;
015.      }
016.       
017.      p {
018.        display: inline;
019.      }
020.       
021.      details {
022.        display: inline-block;
023.        line-height: normal;
024.      }
025.       
026.      div.textpopup {
027.        border: 2px solid black;
028.        width: 50%;
029.        padding: 10px;
030.        margin: 20px;
031.      }
032.       
033.      #loading {
034.        display: none;
035.        top: 0;
036.        left: 0;
037.        background-color: rgba(255, 255, 255, .9);
038.        min-width: 100%;
039.        min-height: 100%;
040.        height: auto;
041.        position: fixed;
042.        z-index: 100000000;
043.      }
044.       
045.      .abx {
046.        position: absolute;
047.        width: 100%;
048.        text-align: center;
049.        top: 25%;
050.      }
051.       
052.      details>summary {
053.        list-style: none;
054.      }
055.       
056.      details>summary::-webkit-details-marker {
057.        display: none;
058.      }
059.       
060.      select {
061.        padding: 3px 12px !important;
062.      }
063.       
064.      label {
065.        margin-top: 5px;
066.        margin-bottom: 0;
067.      }
068.       
069.      #preview {
070.        margin-top: 15px;
071.      }
072.       
073.      #process {
074.        font-size: 24px !important;
075.      }
076.    </style>
078.    <script src="js/bootstrap.min.js"></script>
079.    <script src="js/tesseract214.min.js"></script>
080.    <script>
081.      $(document).ready(function () {
082.        createorc($("#dataface").attr("src"));
083.       
084.        function readURL(input) {
085.          if (input[0].value != "") {
086.            var reader = new FileReader();
087.            reader.onload = function (e) {
088.              createorc(e.target.result);
089.            }
090.            reader.readAsDataURL(input[0].files[0]);
091.          }
092.        }
093.       
094.        function createorc(result) {
095.          var img = '<img id="dataface" src="' + result + '" style="max-width:100%;">';
096.       
097.          var recogImage = result;
098.       
099.          const worker = Tesseract.createWorker({
100.            logger: m => $("#process").html(m.status)
101.          });
102.          Tesseract.setLogging(true);
103.          $("#loading").show();
104.          work();
105.       
106.          async function work() {
107.            await worker.load();
108.            await worker.loadLanguage($(".langdetect").val());
109.            await worker.initialize($(".langdetect").val());
110.       
111.            //let result = await worker.detect(recogImage);
112.            //console.log(result.data);
113.       
114.            let result = await worker.recognize(recogImage);
115.            if ($(".langdetect").val() === "tha") {
116.              $(".addvalue4").val(result.data.text.replaceAll(' ',''));
117.            } else {
118.              $(".addvalue4").val(result.data.text);
119.            }
120.            $("#preview").html(img)
121.       
122.            await worker.terminate();
123.            $("#loading").hide();
124.          }
125.        }
126.       
127.        $("#imagebroswer").change(function () {
128.          readURL($(this));
129.        });    
130.      
131.      });
132.    </script>
133.  </head>
134.  <body>
135.    <div id="loading">
136.      <div class="abx">
137.        <div align="center" style="font-size: 50px;"><strong>กำลัง Load รูปภาพ</strong></div>
138.        <br><span id="process"></span><br><br>
139.        <div align="center"><img src="loading.gif"></div>
140.      </div>
141.    </div>
142.    <form action="save2.php" name="frmAdd" id="frmAdd" method="post" enctype="multipart/form-data" style="margin-left: 30%;">
143.      <div class="textpopup">
144.        <details>
145.          <summary>ทดสอบระบบ OCR ครับ</summary>
146.          <div id="form-group1" class="form-group">
147.            <div class="col-md-6">
148.              <label for="">เลือกภาษา</label>
149.              <select class="form-control langdetect" >
150.                <option value='eng' selected> English  </option>
151.                <option value='tha'> Thai </option>
152.                <option value='eng+tha'> English + Thai </option>
153.              </select>
154.              <label for="">เลือกรูป</label>
155.              <input class="form-control" name="imagebroswer" id="imagebroswer" type="file">
156.            </div>
157.            <div id="preview" class="col-md-6">     
158.              <img id="dataface" src="txtsample.png"  style="max-width:100%;">
159.            </div>
160.            <textarea class="addvalue4 " name="addvalue4" style="border:none; resize:none; width:90%; margin:15px 5px 0px 20px; padding: 5px;"></textarea>
161.          </div>
162.        </details>
163.        </tbody>
164.        </table>
165.      </div>
166.    </form>
167.    <script>
168.      $(document).keypress(
169.       function(event){
170.         if (event.which == '13') {
171.           event.preventDefault();
172.         }
173.      });
174.    </script>
175.    <script>
176.      var today = new Date();
177.      var date = today.getDate()+'/'+(today.getMonth()+1)+'/'+(today.getFullYear()+543);
178.      document.getElementById("addvalue1").value = date;
179.    </script>
180.  </body>
181.</html>



results



พวก html tag ปิดที่เกินมา (</tbody></table>) และ script ติดท้ายไฟล์ผมไม่ได้เคลียร์ให้


ประวัติการแก้ไข
2021-02-17 15:48:19
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2021-02-17 15:40:43 By : lakornworld
 

 

No. 4



โพสกระทู้ ( 131 )
บทความ ( 14 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 3 เขียนโดย : lakornworld เมื่อวันที่ 2021-02-17 15:40:43
รายละเอียดของการตอบ ::
ขอบคุณครับ สำหรับคำตอบ ผมจะกลับไปลอง Code ดูก่อนครับ

แจ้งข่าวเพิ่มเติม : ลอง Code แล้ว ใช้งานได้ 100% จึงขอบคุณ User ละครชีวิต ที่บอกทางสว่างให้ และส่งคำขอบคุณ ในระบบ Thaicreate ให้กับ User ละครชีวิต แล้วครับ

Code ทั้งหมด มีดังนี้ครับ

1. Code Tesseract.js v2.1.4 ที่ได้ต่อยอดจาก Code ที่ถูกต้อง ในความคิดเห็นที่ 3 ให้ดีขึ้น ครับ

001.<!DOCTYPE html>
002.<html>
003.  <head>
004.    <meta charset="UTF-8">
005.    <link rel="stylesheet" href="css/bootstrap.min.css">
006.    <style type="text/css">
007.      @font-face {
008.        font-family: THSarabun;
009.        src: url(thsarabunnew-webfont.woff);
010.      }
011.       
012.      html,
013.      body {
014.        font-family: THSarabun;
015.      }
016.       
017.      p {
018.        display: inline;
019.      }
020.       
021.      details {
022.        display: inline-block;
023.        line-height: normal;
024.      }
025.       
026.      div.textpopup {
027.        border: 2px solid black;
028.        width: 50%;
029.        padding: 10px;
030.        margin: 20px;
031.      }
032.       
033.      #loading {
034.        display: none;
035.        top: 0;
036.        left: 0;
037.        background-color: rgba(255, 255, 255, .9);
038.        min-width: 100%;
039.        min-height: 100%;
040.        height: auto;
041.        position: fixed;
042.        z-index: 100000000;
043.      }
044.       
045.      .abx {
046.        position: absolute;
047.        width: 100%;
048.        text-align: center;
049.        top: 25%;
050.      }
051.       
052.      details>summary {
053.        list-style: none;
054.      }
055.       
056.      details>summary::-webkit-details-marker {
057.        display: none;
058.      }
059.       
060.      select {
061.        padding: 3px 12px !important;
062.      }
063.       
064.      label {
065.        margin-top: 5px;
066.        margin-bottom: 0;
067.      }
068.       
069.      #preview {
070.        margin-top: 15px;
071.      }
072.       
073.      #process {
074.        font-size: 24px !important;
075.      }
076.    </style>
078.    <script src="js/bootstrap.min.js"></script>
079.    <script src="js/tesseract214.min.js"></script>
080.    <script>
081.      $(document).ready(function () {
082.        createorc($("#dataface").attr("src"));
083.       
084.        function readURL(input) {
085.          if (input[0].value != "") {
086.            var reader = new FileReader();
087.            reader.onload = function (e) {
088.              createorc(e.target.result);
089.            }
090.            reader.readAsDataURL(input[0].files[0]);
091.          }
092.        }
093.       
094.        function createorc(result) {
095.          var img = '<img id="dataface" src="' + result + '" style="max-width:100%;">';
096.       
097.          var recogImage = result;
098.       
099.          const worker = Tesseract.createWorker({
100.            logger: m => $("#process").html(m.status)
101.          });
102.          Tesseract.setLogging(true);
103.          $("#loading").show();
104.          work();
105.       
106.          async function work() {
107.            await worker.load();
108.            await worker.loadLanguage($(".langdetect").val());
109.            await worker.initialize($(".langdetect").val());
110.       
111.            //let result = await worker.detect(recogImage);
112.            //console.log(result.data);
113.       
114.            let result = await worker.recognize(recogImage);
115.            if ($(".langdetect").val() === "tha") {
116.              $(".addvalue4").val(result.data.text.replaceAll(' ',''));
117.            } else if ($(".langdetect").val() === "eng+tha") {
118.              $(".addvalue4").val(result.data.text.replaceAll(' ',''));
119.            } else {
120.              $(".addvalue4").val(result.data.text);
121.            }
122.            $("#preview").html(img)
123.       
124.            await worker.terminate();
125.            $("#loading").hide();
126.          }
127.        }
128.       
129.        $("#imagebroswer").change(function () {
130.          readURL($(this));
131.        });    
132.      
133.      });
134.    </script>
135.  </head>
136.  <body>
137.    <div id="loading">
138.      <div class="abx">
139.        <div align="center" style="font-size: 50px;"><strong>กำลัง Load รูปภาพ</strong></div>
140.        <br><span id="process"></span><br><br>
141.        <div align="center"><img src="loading.gif"></div>
142.      </div>
143.    </div>
144.    <form action="save2.php" name="frmAdd" id="frmAdd" method="post" enctype="multipart/form-data" style="margin-left: 30%;">
145.      <div class="textpopup">
146.        <details>
147.          <summary>ทดสอบระบบ OCR ครับ</summary>
148.          <div id="form-group1" class="form-group">
149.            <div class="col-md-6">
150.              <label for="">เลือกภาษา</label>
151.              <select class="form-control langdetect" >
152.                <option value='eng' selected> English  </option>
153.                <option value='tha'> Thai </option>
154.                <option value='eng+tha'> English + Thai </option>
155.              </select>
156.              <label for="">เลือกรูป</label>
157.              <input class="form-control" name="imagebroswer" id="imagebroswer" type="file">
158.            </div>
159.            <div id="preview" class="col-md-6">     
160.              <img id="dataface" src="txtsample.png"  style="max-width:100%;">
161.            </div>
162.            <textarea class="addvalue4 " name="addvalue4" style="border:none; resize:none; width:90%; margin:15px 5px 0px 20px; padding: 5px;"></textarea>
163.          </div>
164.        </details>
165.        </tbody>
166.        </table>
167.      </div>
168.    </form>
169.    <script>
170.      $(document).keypress(
171.       function(event){
172.         if (event.which == '13') {
173.           event.preventDefault();
174.         }
175.      });
176.    </script>
177.    <script>
178.      var today = new Date();
179.      var date = today.getDate()+'/'+(today.getMonth()+1)+'/'+(today.getFullYear()+543);
180.      document.getElementById("addvalue1").value = date;
181.    </script>
182.  </body>
183.</html>


2. ไฟล์ Tesseract.js v2.1.4 ครับ

https://pastebin.com/Ut2SK8AN

3. Link โหลดไฟล์ Code Tesseract.js v2.1.4 ที่ได้ต่อยอดจาก Code ที่ถูกต้อง ในความคิดเห็นที่ 3 ให้ดีขึ้น ครับ

https://drive.google.com/file/d/1Y1RGwwgtkGle78RIfT2GcJuZupYJ1LsD/view?usp=sharing

4. รูปที่ใช้ในการทดสอบเรื่อง OCR เพิ่มเติม ของ Code ตามข้อ 1 ครับ

english ocr one line test




ประวัติการแก้ไข
2021-02-20 19:56:39
2021-02-20 19:58:11
2021-02-20 20:02:10
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2021-02-18 09:21:29 By : doanga2007
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สอบถามว่า มีวิธีไหน ที่จะเอา Code Tesseract.js v2.1.4 จาก https://www.thaicreate.com/php/forum/135891.html ตรงที่ความคิดเห็นที่ 4 ที่แก้ปัญหาเรื่อง ค้างที่หน้า initialized api แล้ว มาใช้กับระบบ OCR เดิม ที่ใช้คู่กับ Tesseract.js v2.1.0 ได้ครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่