建立测试模块代码FaceRecognition.cpp
#include
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Value;
void CAMOpen(const FunctionCallbackInfo& args) {
Isolate* isolate = args.GetIsolate();
args.GetReturnValue().Set(String::NewFromUtf8(isolate, "cam_open..."));
}
void init(Local
建立编译文件binding.gyp
{
"targets": [
{
"target_name": "FaceRecognition",
"sources": [ "FaceRecognition.cpp" ]
}
]
}
安装编译环境
npm install -g node-gyp
安装python
conda create -name python27 python=2.7
activate python27
编译器
本人的编译环境是vs2015
编译模块
node-gyp configure build
创建测试文件test.js
const FaceRecognition = require('./build/Release/FaceRecognition');
console.log(FaceRecognition.CAMOpen());
开发NodeJS扩展模块也可以使用Native Abstractions for Node.js
https://github.com/nodejs/nan