Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

211
Visualizações
Javascript OCR tesseract.js recognize and copy number after spaces

i want to use tesseract.js libaray to recognize a string like ("رقم العداد") and alert the number that is written after the string like (7038842 رقم العداد) << as you see i want to alert the number after the string from a png picture and copy another number from the picture ("نقطة الخدمة") this is what i have tried and it works fine if the [ text.match ] string was [القراءة] but if i change it to ("رقم العداد") or ("نقطة الخدمة") no alert pops up and gives me this error on console

Uncaught (in promise) TypeError: Cannot read properties of null (reading '1') at (index):25:63

code :-

Tesseract.recognize(
        'Uff.png',
        'ara',
  { logger: m => console.log(m) }
).then(({ data: { text } }) => {
    
    var number = 'رقم العداد'; or /*'نقطة الخدمة'*/
    var result = text.match(new RegExp(number + '\\s+(\\w+)'))[1];
    alert(result);
})
    </script>

picture or image link :- picture

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can test on jsfiddle

After some testing and observation for the same problem on Jsfiddle. It is the place where I can say that your problem is with the detected text where the tesseract fails to detect some Arabic letters as they are.

In order to solve this, you have to make sure from the strings output and use the same string to get your numbers.

For instance, in the example above I intended to get the number after matching the string

معرف العقار but tesseract does not give the same string. Rather, it gives محر العفار so in such a case you have to filter with respect to this and not the correct text.

var number = 'محر العفار';
var res = text.match(new RegExp(number + '\\s+(\\w+)'))[1];

This is the picture on the web that I am testing image

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda