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

monkey-opencv

v1.0.1

Published

Provides methods (image search etc.) built upon opencv.

Downloads

18

Readme

MonkeyOpencv

Provides methods built upon opencv.

The following modules are included.

  • MonkeyOpencv (Main module)
  • Matrix (Wrapper for opencv cv::Mat)
  • Constants (Wrapper for opencv constrants)
  • ImageStream (Wrapper to create cv::Mat from Stream)
  • ImageDataStream (DataStream wrapper)

MonkeyOpencv

readImage(imagePath, callback)

Wrapper for cv::imread.

  • imagePath - Path of image file.
  • callback - returns 2 args (error, Matrix)

findSubImage(options, callback)

Finds positions of template matches in the source image. Can supply multiple template images.

  • options
    • source (filepath, Buffer or Matrix)
    • templates (Array of filepath, Buffer or Matrix)
    • matchPercent (default 70) - Confidence lelvel to pick matches(max 100)
    • maximumMatches (default 1) - Number of matches to pick for each template
    • downPyramids (default 0) - Scale down the images before matching (using cv::downPyr)
    • searchExpansion (default 10) - Way to adjust search ROI for optimiaztions.
    • method (default TM_SQDIFF_NORMED) - Method to perform cv::matchTemplate.
      • TM_SQDIFF
      • TM_SQDIFF_NORMED
      • TM_CCORR
      • TM_CCORR_NORMED
      • TM_CCOEFF
      • TM_CCOEFF_NORMED
  • callback - returns 1 arg (matches);
    • Optional. If not provided, a Promise will be returned;
    • matches - Array of match result objects with the following properties.
      • position: {x, y}
      • rect: {x, y, width, height}
      • confidence: 0~100
      • templateIndex: Index of template.
var MonkeyOpencv = require('monkey-opencv').MonkeyOpencv;
var Constants = require ('monkey-opencv').Constants;
var fs = require ('fs');

MonkeyOpencv.findSubImage({
  source: 'source.png',
  templates: ['template.png'],
  matchPercent: 70,
  maximumMatches: 1,
  downPyramids: 1,
  searchExpansion: 15,
  method: Constants.TM_CCORR_NORMED,
}, function(matches){
  console.log('Matches with callback: ',matches[0].position);
})

// Example with Matrix as a template
MonkeyOpencv.readImage('template.png', function(tmpl) {
  MonkeyOpencv.findSubImage({
    source: 'source.png',
    templates: [tmpl, 'invalid_template.png'],
  })
  .then(function(matches){
    console.log('Matches with Promise: ', matches[0].position);
  }, function(err){});
  });
});

// Example with Buffer as a template
var source = fs.readFileSync('template.png');
MonkeyOpencv.findSubImage({
  source: source,
  templates: ['template.png', 'invalid_template.png'],
})
.then(function(matches){
  console.log('Matches with Promise: ', matches[0].position);
}, function(err){});
});

Installation

npm install --save monkey-opencv

Requirements for building from source

node-gyp, node-pre-gyp

opencv

npm install node-gyp node-pre-gyp -g

Requirements for Mac

XCode

Requirements for windows

Install window build tools. Refer to https://github.com/nodejs/node-gyp.

npm install --global --production windows-build-tools

References

  1. https://github.com/Jmgr/actiona
  2. https://github.com/monai/node-imagesearch
  3. https://github.com/peterbraden/node-opencv