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

imagewordfinder

v1.3.4

Published

Wrapper library for Google vision OCR to find position of a word/line/para in a image.

Downloads

19

Readme

image-word-finder

Wrapper library for Google vision OCR to find position of a word/line/para in a image.

Start from here:

How to Use

Installation

npm install imagewordfinder

Include the module

const wordFinder = require('imagewordfinder');

To find a word in a image

let vertices = await wordFinder.findWord('imagepath.png', "birth");

To find multiple words in a image

let vertices = await wordFinder.findWord('imagepath.png', [
  "Name",
  "Current Address",
  "Contact Information",
]);

To find words in a image with case insensitivity (By default, it is case sensitive)

let options = {
  caseSensitive: false,
}

let vertices = await wordFinder.findWord('imagepath.png', [
  "Name",
  "Current Address",
  "Contact Information",
], options);

vertices = await wordFinder.findWord('imagepath.png', "birth", options);

The output of the word finder is as follows,

let vertices = await wordFinder.findWord('imagepath.png', "birth");

console.log(vertices);

==================================================================

{
	"para_text": "Alternate Names - List any names by which you are known or any names Date of Birth",
	"vertices": {
		"width": 17,
		"height": 9,
		"origin": {
			"x": 374,
			"y": 201
		}
	},
	"index": {
		"page_index": 0,
		"block_index": 5
	},
	"para_vertices": {
		"origin": {
			"x": 39,
			"y": 188
		},
		"height": 23,
		"width": 471
	},
	"word": "birth"
}

The above vertices can be used in various ways:

  1. To find exact position of word,
let vertices = await wordFinder.findWord('imagepath.png', "birth");

let x = vertices.vertices.origin.x;
let y = vertices.vertices.origin.y;

let xEnd = vertices.vertices.origin.x + vertices.vertices.width;
let yEnd = vertices.vertices.origin.y + vertices.vertices.height;
  1. To draw the boundary of word in javascript and css,
let element = document.createElement('div');

element.style.position = "absolute";
element.style.left = vertices.vertices.origin.x;
element.style.top = vertices.vertices.origin.y;
element.style.width = vertices.vertices.origin.x + vertices.vertices.width;
element.style.height = vertices.vertices.origin.y + vertices.vertices.height;

let body = document.getElementsByTagName('body')
body[0].appendChild(element);

To find distance between two words in a image

let distance = await wordFinder.findWord('imagepath.png', "Name", "Date of Birth");

The object format of distance object is as below,

{
	"distanceX": 306,
	"distanceY": 25,
	"word1": {
		"para_text": "Personal Information Name ( First , Middle , Last , Suffix )",
		"vertices": {
			"width": 24,
			"height": 11,
			"origin": {
				"x": 38,
				"y": 176
			}
		},
		"index": {
			"page_index": 0,
			"block_index": 5
		},
		"para_vertices": {
			"origin": {
				"x": 38,
				"y": 160
			},
			"height": 27,
			"width": 119
		},
		"word": "Name"
	},
	"word2": {
		"para_text": "Alternate Names - List any names by which you are known or any names Date of Birth",
		"vertices": {
			"width": 17,
			"height": 9,
			"origin": {
				"x": 344,
				"y": 201
			}
		},
		"index": {
			"page_index": 0,
			"block_index": 5
		},
		"para_vertices": {
			"origin": {
				"x": 39,
				"y": 188
			},
			"height": 23,
			"width": 471
		},
		"word": "Date of Birth"
	}
}

To get all paragraphs and words with position in a image

let paragraphs = await wordFinder.getParagraphs('imagepath.png');

Other Links