npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dta-vision-ocr

v17.0.9

Published

```md # DTA VISION OCR

Downloads

579

Readme

# DTA VISION OCR

Biblioteca para facilitar a extração de texto de qualquer imagem, parametrizada pelo formulário para extrair um JSON.

## Como instalar

```bash
npm install dta-vision-ocr --save

ou

yarn add dta-vision-ocr --save

Como usar

É necessário possuir um código de projeto para uso. Após obtenção do código do projeto, basta seguir os passos abaixo.

Uso no HTML

<po-button p-label="Abrir DTA Vision QrCode" (p-click)="abrirDtaVision()" p-icon="ph ph-qr-code"></po-button>

  @if(this.habilitarModalOcr) {
    <dta-vision-ocr #webAppModal
      [idDTAVision]="idTotvsVision"
      [idProjeto]="idProjeto"
      [user]="user"
      [contingency]="contingency"
      [listButtonsDocument]="buttonList"
      (informacaoEnviada)="receberInformacao({ menssagem
        : $event.menssagem, uniqueKey: $event.uniqueKey})">
    </dta-vision-ocr>
  }

Para TypeScript

idDta = "";
idProjeto = "";
habilitarModalOcr = false;
user = "";
contingency = "";

@ViewChild('webAppModal') webAppModal?: DTAVisionOCRComponent;


abrirDtaVision() {
  this.habilitarModalOcr = true;
  this.webAppModal?.ngOnInit();
}

// Exemplo de buttonList
   buttonList : ButtonDocumentModel[] = [
    {
      "idButton": "01",
      "nameButton": "Dados Pessoais",
      "imageReturn": true,
      "canUserSet": true,
      "userFields": [
        {
          "fieldLabel": "Teste",
          "fieldName": "name",
          "fieldType": "string"
        },
        {
          "fieldLabel": "CPF",
          "fieldName": "cpf",
          "fieldType": "string"
        },
        {
          "fieldLabel": "validade",
          "fieldName": "validade",
          "fieldType": "string"
        },
        {
          "fieldLabel": "data de nascimento",
          "fieldName": "dataNascimento",
          "fieldType": "string"
        }
      ]
    },
    {
      "idButton": "02",
      "nameButton": "Historico Escolar",
      "imageReturn": false,
      "userFields": [
        {
          "fieldName": "alunoInfo",
          "fieldType": "object",
          userArray: [
            {
              "fieldName": "nomeAluno",
              "fieldType": "string"
            },
            {
              "fieldName": "matricula",
              "fieldType": "string"
            }
          ]
        },
        {
          "fieldName": "disciplinas",
          "fieldType": "array",
           userArray: [
            {
              "fieldName": "disciplina",
              "fieldType": "string"
            },
            {
              "fieldName": "nota",
              "fieldType": "string"
            },
            {
              "fieldName": "cargaHoraria",
              "fieldType": "string"
            },
            {
              "fieldName": "credito",
              "fieldType": "string"
            }
          ]
        }
      ]
    }
  ]
  

receberInformacao(informacao: { menssagem: DocumentResponse; uniqueKey: number; }) {
  let parsedResponse;
  try {
    parsedResponse = JSON.parse(informacao.menssagem.ocrResponse);
  } catch (error) {
    console.error(`Erro ao desserializar ${informacao.menssagem.idButton}:`, error);
    return;
  }

  switch (informacao.menssagem.idButton) {
    case "1":
      const dadosPessoais = parsedResponse as DadosPessoais;
      // Preencher os dados pessoais no formulário
      break;
    case "2":
      const historicoEscolar = parsedResponse as HistoricoEscolar;
      // Preencher o histórico escolar no formulário
      break;
    default:
      console.warn(`Não existe o ID do botão: ${informacao.menssagem.idButton}`);
      break;
  }

  //Limpa e fechar modal assim que recebe os dados.
    this.habilitarModalOcr = false;
}

Explicação do buttonList

  • idButton: Identificador único para o botão. Através dele vai ser usado para recupera o botão com switch
  • nameButton: Nome exibido no botão.
  • imageReturn: Define se a imagem deve ser retornada.
  • userFields: Lista de campos que serão extraídos pela OCR.
    • fieldName: Nome do campo.
    • fieldType: Tipo de dado esperado.

Dados experados no exemplo


export interface DadosPessoais {
    name: string;
    cpf: string;
}

export interface HistoricoEscolar {
  alunoInfo: AlunoInfo;
  disciplinas: Disciplina[];
}

export interface AlunoInfo {
  nomeAluno: string;
  curso: string;
}

export interface Disciplina {
  disciplina: string;
  nota: string;
  cargaHoraria: string;
  credito: string;
}