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

gcp_cloud_vision_lines

v1.0.7

Published

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.

Downloads

119

Readme

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 
     }
  }
];