Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gcp_cloud_vision_lines

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gcp_cloud_vision_lines

This utility breaks down a full text annotation response from the Google cloud vision API into a neatly parsed Array with each element representing a single line of text, with coords and height and width dimensions.

  • 1.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

GCP cloud vision lines

A simple JS function for getting back lines of text with coords and dimensions from Google Cloud vision API.

Please note: This package is not affiliated with Google in any way. I saw a need for a service that provided parsing of the data returned from Google's Cloud Vision API so I filled it.

For more on the Google Cloud Vision API, please go here https://cloud.google.com/vision/docs/reference/rest/

How to Use

 
const vision = require('@google-cloud/vision');

const { cloudVisionLines } = require('gcp_cloud_vision_lines');

// This is the boiler plate for authing if you haven't
//used the gcloud CLI to authenticate to your service account

const client = new vision.ImageAnnotatorClient({
  projectId: <YOUR PROJECT ID HERE>,
  keyFilename: path.resolve(`YOUR/GCP_KEY_FILE_PATH}`)
});

const filePath = 'PATH/TO/THE/FILE/I/WANT/TO/ANALYZE';

const [result] = await client.documentTextDetection(filePath);

cloudVisionLines(result.fullTextAnnotation); // This is the function exported from the module :)


You should get a response that looks like the following

[ 
  { text: 'Wahaca ', // the text it found
    coords:
     { tl: {"x":516,"y":107}, // the top left coord of the line
       tr: {"x":636,"y":107}, // the top right coord of the line
       br: {"x":636,"y":155}, // the bottom right coord of the line
       bl: {"x":516,"y":155}, // the bottom left coord of the line
       w: 120, // the width dimension of the line
       h: 48 // the height dimension of the line
     } 
  },
  { text: '19 - 23 Charlotte Street ',
    coords:
     { tl: {"x":330,"y":156},
       tr: {"x":813,"y":156},
       br: {"x":813,"y":207},
       bl: {"x":330,"y":207},
       w: 483,
       h: 51 
     }
  }
];

Keywords

FAQs

Package last updated on 22 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc