Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

brunocechet

Ajuda com OCR/ICR

Recommended Posts

Estou trabalhando com Python3 e tentando reconhecer essas imagens, mas sem resultados satisfeitos ainda.

 

Eu tentei pytesseract e a Google Vision API seguindo este tutorial.

 

Eu não sei o que eu poderia fazer para obter melhores resultados

 

Alguém poderia tentar me ajudar?

 

Obrigado antecipadamente

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá Bruno,

 

Com ICR eu nunca trabalhei e acredito que seja bem trabalhoso mesmo, pois das poucas vezes que tentei, meus resultados foram muito desastrosos. Mas OCR tem uma taxa de acerto maior. 

 

Desconheço essa API do Google, mas se tratando de Tesseract, dá uma lida aqui.

https://github.com/this-is-ari/python-tesseract-3.02-training

Compartilhar este post


Link para o post
Compartilhar em outros sites

  • Conteúdo Similar

    • Por erissonamorim
      Olá pessoal, tudo certo?!

      Estou com um código que está funcionando bem. Mas gostaria de que a câmera traseira do celular fosse a padrão.
      Abaixo segue o código, caso possam me ajudar a efetuar esta alteração.
      Desde já, agradeço!
      (function () { var video = document.querySelector('video'); var pictureWidth = 640; var pictureHeight = 360; var fxCanvas = null; var texture = null; function checkRequirements() { var deferred = new $.Deferred(); //Check if getUserMedia is available if (!Modernizr.getusermedia) { deferred.reject('Your browser doesn\'t support getUserMedia (according to Modernizr).'); } //Check if WebGL is available if (Modernizr.webgl) { try { //setup glfx.js fxCanvas = fx.canvas(); } catch (e) { deferred.reject('Sorry, glfx.js failed to initialize. WebGL issues?'); } } else { deferred.reject('Your browser doesn\'t support WebGL (according to Modernizr).'); } deferred.resolve(); return deferred.promise(); } function searchForRearCamera() { var deferred = new $.Deferred(); //MediaStreamTrack.getSources seams to be supported only by Chrome if (MediaStreamTrack && MediaStreamTrack.getSources) { MediaStreamTrack.getSources(function (sources) { var rearCameraIds = sources.filter(function (source) { return (source.kind === 'video' && source.facing === 'environment'); }).map(function (source) { return source.id; }); if (rearCameraIds.length) { deferred.resolve(rearCameraIds[0]); } else { deferred.resolve(null); } }); } else { deferred.resolve(null); } return deferred.promise(); } function setupVideo(rearCameraId) { var deferred = new $.Deferred(); var videoSettings = { video: { optional: [ { width: { min: pictureWidth } }, { height: { min: pictureHeight } } ] } }; //if rear camera is available - use it if (rearCameraId) { videoSettings.video.optional.push({ sourceId: rearCameraId }); } navigator.mediaDevices.getUserMedia(videoSettings) .then(function (stream) { //Setup the video stream video.srcObject = stream; video.addEventListener("loadedmetadata", function (e) { //get video width and height as it might be different than we requested pictureWidth = this.videoWidth; pictureHeight = this.videoHeight; if (!pictureWidth && !pictureHeight) { //firefox fails to deliver info about video size on time (issue #926753), we have to wait var waitingForSize = setInterval(function () { if (video.videoWidth && video.videoHeight) { pictureWidth = video.videoWidth; pictureHeight = video.videoHeight; clearInterval(waitingForSize); deferred.resolve(); } }, 100); } else { deferred.resolve(); } }, false); }).catch(function () { deferred.reject('There is no access to your camera, have you denied it?'); }); return deferred.promise(); } function step1() { checkRequirements() .then(searchForRearCamera) .then(setupVideo) .done(function () { //Enable the 'take picture' button $('#takePicture').removeAttr('disabled'); //Hide the 'enable the camera' info $('#step1 figure').removeClass('not-ready'); }) .fail(function (error) { showError(error); }); } function step2() { var canvas = document.querySelector('#step2 canvas'); var img = document.querySelector('#step2 img'); //setup canvas canvas.width = pictureWidth; canvas.height = pictureHeight; var ctx = canvas.getContext('2d'); //draw picture from video on canvas ctx.drawImage(video, 0, 0); //modify the picture using glfx.js filters texture = fxCanvas.texture(canvas); fxCanvas.draw(texture) .hueSaturation(-1, -1)//grayscale .unsharpMask(20, 2) .brightnessContrast(0.2, 0.9) .update(); window.texture = texture; window.fxCanvas = fxCanvas; $(img) //setup the crop utility .one('load', function () { if (!$(img).data().Jcrop) { $(img).Jcrop({ onSelect: function () { //Enable the 'done' button $('#adjust').removeAttr('disabled'); } }); } else { //update crop tool (it creates copies of <img> that we have to update manually) $('.jcrop-holder img').attr('src', fxCanvas.toDataURL()); } }) //show output from glfx.js .attr('src', fxCanvas.toDataURL()); } function step3() { var canvas = document.querySelector('#step3 canvas'); var step2Image = document.querySelector('#step2 img'); var cropData = $(step2Image).data().Jcrop.tellSelect(); var scale = step2Image.width / $(step2Image).width(); //draw cropped image on the canvas canvas.width = cropData.w * scale; canvas.height = cropData.h * scale; var ctx = canvas.getContext('2d'); ctx.drawImage( step2Image, cropData.x * scale, cropData.y * scale, cropData.w * scale, cropData.h * scale, 0, 0, cropData.w * scale, cropData.h * scale); var spinner = $('.spinner'); spinner.show(); $('blockquote p').text(''); $('blockquote footer').text(''); // do the OCR! Tesseract.recognize(ctx).then(function (result) { var resultText = result.text ? result.text.trim() : ''; //show the result spinner.hide(); $('blockquote p').html('&bdquo;' + resultText + '&ldquo;'); $('blockquote footer').text('(' + resultText.length + ' characters)'); }); } /********************************* * UI Stuff *********************************/ //start step1 immediately step1(); $('.help').popover(); function changeStep(step) { if (step === 1) { video.play(); } else { video.pause(); } $('body').attr('class', 'step' + step); $('.nav li.active').removeClass('active'); $('.nav li:eq(' + (step - 1) + ')').removeClass('disabled').addClass('active'); } function showError(text) { $('.alert').show().find('span').text(text); } //handle brightness/contrast change $('#brightness, #contrast').on('change', function () { var brightness = $('#brightness').val() / 100; var contrast = $('#contrast').val() / 100; var img = document.querySelector('#step2 img'); fxCanvas.draw(texture) .hueSaturation(-1, -1) .unsharpMask(20, 2) .brightnessContrast(brightness, contrast) .update(); img.src = fxCanvas.toDataURL(); //update crop tool (it creates copies of <img> that we have to update manually) $('.jcrop-holder img').attr('src', fxCanvas.toDataURL()); }); $('#takePicture').click(function () { step2(); changeStep(2); }); $('#adjust').click(function () { step3(); changeStep(3); }); $('#go-back').click(function () { changeStep(2); }); $('#start-over').click(function () { changeStep(1); }); $('.nav').on('click', 'a', function () { if (!$(this).parent().is('.disabled')) { var step = $(this).data('step'); changeStep(step); } return false; }); })();  
    • Por splemes1970
      Nome: Fulano de Tal     Texto_1 Olá bom dia, bla bla bla                   Email: Fulano@gmail.com     Texto_2 Olá boa tarde, bla bla bla                             Texto_3 Olá boa noite, bla bla bla                                     Seleção do Texto a enviar  ()                             Email a enviar   :  Digite o email  
       
           
      Preciso de um formulário  que o usuário possa enviar emails com textos predefinidos por eles, onde ele possa criar o seu cadastro com seu nome, seu email e seus textos predefinidos, e para enviar os email ele possa escolher o texto dentre os que ele predefiniu e emails que ele digite na hora do envio no formulário
    • Por ghostdancing
      Olá pessoal! Juro que quebrei a cabeça, mas como sempre, não estou enxergando algo. Se puderem me ajudar agradeço. Gostaria de apertar na <label> Entrar e aparecer o <form id="formlogin">, ao clicar novamente ele desaparecesse, e eu consegui fazer isso, mas eu quero também que ao clicar na <label> Cadastrar, o #formlogin desaparecesse e ficasse o #formcadas e vice-versa. Eis o código:

       
      <head>
      <style type="text/css">
       * { margin:0; padding:0; box-sizing:border-box; }
      button {
        border: none;
        background-color: white;
        display:inline;} 
        #folo{
            position: relative; 
            top: 3px;
            left: 30px;
            background-color:lightgrey;
            max-width: 133px;
        }  
      </style>
      <head>
       
      <body>
          <div id="folo" >
              <label id="entrarbtn" onclick="mostra();">Entrar</label> |<label onclick="mostra();"id="cadasbtn" onclick=""> Cadastro</label>
          </div>    
          <form id="formlogin" style="position: relative; top: 3px; left: 30px; display:none;">
              nome/e-mail:<br/>
              <input type="" name=""><br/>
              senha:<br/>
              <input type="" name=""><br/>
              <button>entrar</button>
          </form>
          <form id="formcadas" style="position: relative; top: 3px; left: 30px; display:none;">
              nome/e-mail:<br/>
              <input type="" name=""><br/>
              senha:<br/>
              <input type="" name=""><br/>
              <button>cadastrar</button>
          </form>
       
      <script type="text/javascript">
          function mostra(){
              var login = document.getElementById("formlogin");
              if (login.style.display ==="none"){login.style.display = "inline-block";}
              else{ login.style.display ="none"}
          }
          function mostraum(){
              var cadas = document.getElementById("formcadas");
              if (cadas.style.display === "none"){cadas.style.display = "inline-block";}
              else{cadas.style.display = "none";}
          }
       
      </script>
      </hmtl>

      Desse jeito funciona, mas as divs aparecem uma ao lado da outra e não é isso que eu queria. Agradeço desde já!
    • Por marsolim
      feras, eu tô com uma dúvida aqui faz uns dias. vi uma pessoa falar sobre criar um aplicativo pra reconhecer quando um carro com um determinado numero de placa passar e avisar o sistema que o carro passou. pra isso a ideia é usar uma camera que vai ficar filmando os carro e esse ocr ler as placas. a pergunta é se isso é legal ou se pode dar problema pro cara que criar esse programa. tipo acho que isso só pode ser feito por deparamento de justiça ou a prefeitura sei lá... ou um cara civil que não trabalha pra policia nem estado e nem nada pode criar uma coisa assim e usar?
       
      obrigado a todos
    • Por Julle
      Porquê esse erro estar acontecendo?
       
       
       
      Notice: Undefined index: action in C:\xampp\htdocs\PhpProject1\index.php on line 4
      Nome:  
      Idade:  
      E-mail: 
      sexo:  > Masculino  >Feminino 
      Curso:               > selecione...              > Ciência da Computação                > Bacharelando em Informática              > Engenharia da Computação   
                
      Conhecimento:  >Microdoft Word  >HTML  >JavaScript  >PHP 
       
       
       
      Código: 
      <!DOCTYPE html>
      <?php
          if($_REQUEST["action"] =="save")
          { 
              
              
              $formValid = True;
              
              $tamanho_nome = strlen($_POST["CAMPO_NOME"]);
              if($tamanho_nome < 5|| $tamanho_nome > 64)
              {
                  echo("O campo  'NOME' deve ter entre 5 e 64 caracteres.".$tamanho_nome);
                  $formValid = FALSE;
              }
              
              $idade = (int)$_POST["CAMPO_IDADE"];
              if(is_NaN($idade)|| $idade < 4 || $idade > 120)
              {
                  echo("O campo 'Idade' deve ter preenchido corretamente."); 
                  $formValid = false; 
              }
              $email = $_POST["CAMPO_EMAIL"];
              $regex = 
              "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/";
              if(!preg_match($regex, $email))
              {
                  echo("O campo 'E-mail' deve ter preenchido corretamente.");
                  $formValid = FALSE;
              }
              $sexo = $_POST["CAMPO_SEXO"];        
              if($sexo != "M" && $sexo != "F")
              {
                  echo("O campo 'sexo' deve ser preenchido.");
                  $formValid = FALSE;
              }
              $curso = $_POST["CAMPO_CURSO"];
              if($curso == "" || $curso == "Selecione . . .")
              {
                  echo("A campo 'curso' deve ser preenchido.");
                  $formValid = FALSE;
              }
              $conhecimento = $_POST["CAMPO_CONHECIMENTO"];
              if(sizeof($conhecimento)!= 2)
              {
                  echo("É necessário marcar 2 conhecimento.");
                  $formValid = FALSE;
              }
              if($formValid)
              {
                  echo("Formulário validado com sucesso");
                  exit();
              }
              
          }
          
        ?>
      <html>
          <head>
              <title>EXEMPLO - formulário</title>
              <script language=" JavaScrip">
              function validaForm()
              {
                  var tamanho_nome = document.forms["meuForm"].CAMPO_NOME.value.length;
                  if(tamanho_nome <5 || tamanho_nome >64)
                  {
                      alert("O campo 'nome' deve ter entre 5 e 64 caracteres");
                      return false;
                  }
                  var idade = document.forms["meuForm"].CAMPO_IDADE.value;
                  if(is_NaN($idade)|| $idade < 4 || $idade > 120)
                  {
                      echo("O campo 'Idade' deve ter preenchido corretamente."); 
                      return false;
                  }
                  var email = document.forms["meuForm"].CAMPO_EMAIL.value;
                  if(email.length<5 || email.length > 128 ||email.index0f(@) = = -1 ||
                  email.index0f('.') == -1){
                      alert("O campo 'Email' deve ter preenchido corretamente.");
                      return false;
                  }
                  var campo_sexo = document.forms["meuForm"].CAMPO_SEXO;
                  var sexo = false; 
                  for(i=0; i<campo_sexo.length;i++){
                      if(campo_sexo.checked == true)
                      {
                          sexo = campo_sexo.value;
                          brack;
                      }
                  }
                  if(sexo == false)
                  {
                      alert("O campo 'sexo' deve ser preenchido.");
                      return false;
                  }
                  var opcao_curso = document.forms["meuForm"].CAMPO_CURSO.selectedIndex;
                  if(opcao_curso == 0)
                  {
                      alert("O campo 'curso' deve ser preenchhido");
                      return false;
                  }
                  var conhecimento = document.forms["meuForm"].elements['CAMPO_CONHECIMENTOS[]'];
                  var conhecimentosMarcados =0;
                  for(i=0; i<conhecimentos.length; i++)
                  {
                      if(conhecimento.checked == true)
                      {
                          conhecimentosMarcados++;
                      }
                  }
                  if(conhecimentosMarcados != 2)
                  {
                      alert("É necessário marcar 2 conhecimento");
                      return false;
                  }
                  document.forms["meuForm"].submit();
                  
              }
              </script>
          </head>
          <body>
              
          <form method="POST" action="?action=save" name="meuForm">
                  
                  Nome:  <input type=TEXT name= "CAMPO_NOME" value=" <? echo $_POST[' CAMPO_NOME'];?>">
              <br>Idade: <input type=TEXT name="CAMPO_IDADE"  value="<? echo $_POST['CAMPO_IDADE'];?>">
              <br>E-mail:<input type=TEXT name="CAMPO_EMAIL"  value="<? echo $_POST['CAMPO_EMAIL'];?>">
              <br>sexo: <input type=RADIO name="CAMPO_SEXO" value="M"
                          <? if($_POST['CAMPO_SEXO']== "M"){echo "checked";}?> > Masculino
                          <input type=RADIO nome="CAMPO_SEXO" value="F"
                          <? if($_POST['CAMPO_SEXO']== "F"){echo "checked";}?> >Feminino
                  
                  
              <br>Curso: <select name= "CAMPO_CURSO">
                  <option <? if($_POST['CAMPO_CURSO']=="selecione . . . ")
                      { echo "selected";}?> > selecione...</option>
                  <option <? if($_POST['CAMPO_CURSO'] == "Ciência da Computação")
                      { eecho "selected";}?> > Ciência da Computação </option>
                  <option <? if($_POST['CAMPO_CURSO']=="Bacharelando em Informática")
                      { echo "selected";}?>  > Bacharelando em Informática</option>
                  <option <? if($_POST['CAMPO_CURSO']== " Engenharia da Computação")
                      {echo "selected";}?> > Engenharia da Computação </option>
              </select>
              
              <br>Conhecimento:
              <input type =checkbox name=CAMPO_CONHECIMENTOS[] value="Word" 
                     <?if(in_aray("Word", $_POST['CAMPO_CONHECIMENTOS[]') != FALSE){echo "checked"; }?> >Microdoft Word
              <input type =checkbox name=CAMPO_CONHECIMENTOS[] value="HTML"
                  <?if(in_aray("HTML",  $_POST['CAMPO_CONHECIMENTOS[]') != FALSE)
                  {echo "checked"; }?> >HTML
              <input type =checkbox name=CAMPO_CONHECIMENTOS[] value="JS"
                   <?if(in_aray("JS",  $_POST['CAMPO_CONHECIMENTOS[]') != FALSE)
                  {echo "checked"; }?> >JavaScript
              <input type =checkbox name=CAMPO_CONHECIMENTOS[] value="PHP"
                   <?if(in_aray("PHP",  $_POST['CAMPO_CONHECIMENTOS[]') != FALSE)
                  {echo "checked"; }?> >PHP
                  
              <br>
              <input type=RESET value="Limpar">
              <input type=BUTTON onClick="validaform();"value="Enviar">
          </form>     
              
                  
                           
          </body>
      </html>
×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.