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

opencv4nodejs

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opencv4nodejs - npm Package Compare versions

Comparing version 2.38.0 to 3.0.0

appveyor.yml

28

lib/defines.js

@@ -1,14 +0,20 @@

const { modules, xmodules, getModulesHaveHeader, getLibs } = require('./utils');
const { modules, xmodules, getModulesHaveHeader, getLibs, opencvBuild } = require('./utils');
Promise.all([getModulesHaveHeader(), getLibs()]).then(([modulesHaveHeader, libs]) => {
if (libs.some(({ module: _m }) => _m === 'world')) {
modules.forEach(m => console.log(`HAVE_${m.toUpperCase()}`));
return;
}
if (opencvBuild.hasSelfBuild()) {
Promise.all([getModulesHaveHeader(), getLibs()]).then(([modulesHaveHeader, libs]) => {
if (libs.some(({ module: _m }) => _m === 'world')) {
modules.forEach(m => console.log(`HAVE_${m.toUpperCase()}`));
return;
}
modules.concat(xmodules).forEach(m => {
if (modulesHaveHeader.some(_m => _m === m) && libs.some(({ module: _m }) => _m === m)) {
console.log(`HAVE_${m.toUpperCase()}`);
}
modules.concat(xmodules).forEach(m => {
if (modulesHaveHeader.some(_m => _m === m) && libs.some(({ module: _m }) => _m === m)) {
console.log(`HAVE_${m.toUpperCase()}`);
}
});
});
});
return;
}
// set defines from auto build
opencvBuild.opencvModules.forEach(m => console.log(`HAVE_${m.toUpperCase()}`));

@@ -1,3 +0,9 @@

const { includeDir } = require('./utils');
const { includeDir, opencvBuild } = require('./utils');
console.log(includeDir);
if (opencvBuild.hasSelfBuild()) {
console.log(includeDir);
return;
}
// set include dir from auto build
opencvBuild.includes();

@@ -1,3 +0,10 @@

const { getLibs } = require('./utils');
const { getLibs, opencvBuild } = require('./utils');
getLibs().then(libs => libs.forEach(({ lib }) => console.log(lib)));
if (opencvBuild.hasSelfBuild()) {
getLibs().then(libs => libs.forEach(({ lib }) => console.log(lib)));
return;
}
// get libs from auto build
opencvBuild.libraries();
const path = require('path');
const { opencvBuild } = require('./utils');
// ensure binaries are added to path on windows
if (!opencvBuild.hasSelfBuild()) {
opencvBuild.ensureBinaries()
}
let cv;

@@ -4,0 +10,0 @@ if (process.env.BINDINGS_DEBUG) {

const fs = require('fs');
const path = require('path');
const opencvBuild = require('opencv-build');

@@ -42,3 +43,3 @@ const resolvePath = (filePath, file) => {

let includeDir = resolvePath(process.env.OPENCV_INCLUDE_DIR);
let libDir = resolvePath(process.env.OPENCV_LIB_DIR);
let libDir = resolvePath(process.env.OPENCV_LIB_DIR) || `${defaultDir}/lib`;

@@ -50,9 +51,10 @@ if (!includeDir) {

}
}
const opencv2Include = resolvePath(includeDir, 'opencv2');
const ensureDirsExist = () => {
if (!fs.existsSync(includeDir)) {
throw new Error(`not found: process.env.OPENCV_DIR | process.env.OPENCV_INCLUDE_DIR | ${includeDir}`);
}
}
if (!libDir) {
libDir = `${defaultDir}/lib`;
if (!fs.existsSync(libDir)) {

@@ -63,5 +65,5 @@ throw new Error(`not found: process.env.OPENCV_LIB_DIR | ${libDir}`);

const opencv2Include = resolvePath(includeDir, 'opencv2');
const getModulesHaveHeader = () => new Promise((resolve) => {
ensureDirsExist();
const getModulesHaveHeader = () => new Promise((resolve) => {
fs.readdir(opencv2Include, (err, files) => {

@@ -86,2 +88,4 @@ if (err) throw(err);

const getLibs = () => new Promise((resolve) => {
ensureDirsExist();
fs.readdir(resolvePath(libDir), (err, files) => {

@@ -135,3 +139,4 @@ if (err) throw(err);

getLibs,
resolvePath
resolvePath,
opencvBuild
};
{
"name": "opencv4nodejs",
"version": "2.38.0",
"version": "3.0.0",
"description": "Asynchronous OpenCV 3.x API for node.js",

@@ -51,4 +51,5 @@ "keywords": [

"macro-inferno": "^0.2.1",
"nan": "^2.7.0"
"nan": "^2.7.0",
"opencv-build": "0.0.0"
}
}

@@ -89,19 +89,30 @@ opencv4nodejs

## Requirements
- cmake (unless you are using a prebuilt OpenCV release)
### On Windows
On windows you will need Windows Build Tools to compile OpenCV and opencv4nodejs. If you don't have Visual Studio or Windows Build Tools installed, you can easily install the VS2015 build tools:
``` bash
npm install --global windows-build-tools
```
## Auto build
If you do not want to set up OpenCV on your own you can simply let this package auto install OpenCV 3.4 + <a href="https://github.com/opencv/opencv_contrib"><b>OpenCV contrib 3.4</b></a> (might take some time):
``` bash
$ npm install --save opencv4nodejs
```
Make sure to have OpenCV 3+ ( extra modules are optional ) installed on your System https://github.com/opencv/opencv/releases/. In case you are running on Windows or have OpenCV set up in a custom directory make sure to set the following environment variables:
1. OPENCV_DIR pointing to the root path containing include directory or set OPENCV_INCLUDE_DIR explicitly.
2. OPENCV_LIB_DIR pointing to the library dir containing the OpenCV .lib, .so or .dylib files.
## Manual build
Setting up OpenCV on your own will require you to set an environment variable: *OPENCV4NODEJS_DISABLE_AUTOBUILD=1*.
You can either install any of the OpenCV 3+ <a href="https://github.com/opencv/opencv/releases/"><b>releases</b></a> (note, this will come without contrib) or build OpenCV with or without <a href="https://github.com/opencv/opencv_contrib"><b>OpenCV contrib</b></a> from source on your own. On Linux and MacOSX the library should be installed under *usr/local* (which is the default).
### On Windows
On windows you will need the windows build tools to compile opencv4nodejs:
```
npm install --global windows-build-tools
```
If you choose to set up OpenCV on your own you have to set the following environment variables before installing opencv4nodejs:
- *OPENCV_INCLUDE_DIR* pointing to the directory with the subfolders *opencv* and *opencv2* containing the header files
- *OPENCV_LIB_DIR* pointing to the lib directory containing the OpenCV .lib files
Also you will need to add the OpenCV binaries to your system path:
- Add an environment variable OPENCV_BIN_DIR pointing to the library dir containing the OpenCV .dll files.
- Append `;%OPENCV_BIN_DIR%;` to your path variable.
- add an environment variable *OPENCV_BIN_DIR* pointing to the binary directory containing the OpenCV .dll files
- append `;%OPENCV_BIN_DIR%;` to your system path variable

@@ -108,0 +119,0 @@ Note: Restart your current console session after making changes to your environment.

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