This is an example of how to use opencv4nodejs with electron to build cross-platform desktop apps.
Note that there is an additional npm script to rebuild the package for electron, which is called from the install script:
"electron-rebuild": "electron-rebuild -w opencv4nodejs"
This example shows how to use opencv4nodejs with electron and plain HTML + Javascript without any bundler.
npm install
npm start
This example shows how to use opencv4nodejs with webpack and react, requires node-loader to load the native addon.
npm i node-loader
If you are using the autobuild on windows, you have to append the path to the binaries to the path env of main process manually as follows (in main.js):
if (process.platform === 'win32' && !process.env.OPENCV4NODEJS_DISABLE_AUTOBUILD) {
process.env.path += ';' + require('../renderer/node_modules/opencv-build').opencvBinDir
}
In the root directory:
npm install
npm start
In another terminal cd into ./renderer and run the dev server:
npm install
npm start
If you are receiving the following error on windows during electron-rebuild:
AttributeError: 'MSVSProject' object has no attribute 'iteritems'
Delete fsevents from your node_modules folder and rerun:
npm run electron-rebuild