Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
gcp_cloud_vision_lines
Advanced tools
Readme
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/
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
}
}
];
FAQs
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.
The npm package gcp_cloud_vision_lines receives a total of 12 weekly downloads. As such, gcp_cloud_vision_lines popularity was classified as not popular.
We found that gcp_cloud_vision_lines demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.