第一步建立一个DLL
int WINAPI CAM_Open(char *pIn, char* pOut);第二步安装ffi
npm install --save ffi
针对electron版本重新编译
cd node_modules\ffi
node-gyp rebuild -target=1.6.11 -arch=x64 -dist-url=https://atom.io/download/atom-shellcd node_modules\ref
node-gyp rebuild -target=1.6.11 -arch=x64 -dist-url=https://atom.io/download/atom-shell第三步修改electron应用的index.html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>人脸识别测试程序</title> </head> <body> <button id="CAMOpen" name="CAMOpen">调用人脸识别DLL</button> </body> <script> //var addon = require("facerecognitiondll") //document.write(addon.CAMOpen()) var ffi = require("ffi") var DLL = ffi.Library('FaceRecognition.dll', { 'CAM_Open' : ['int', ['string', 'string']] }); var result = DLL.CAM_Open("", ""); document.write("CAM_Open return "+ result) </script> </html>
