#include #include #include "cv/node.h" #ifdef USE_ORT #include "ort/node.h" #endif using namespace Napi; class TestWork : public AsyncWorker { public: TestWork(const Napi::Function &callback, int value) : Napi::AsyncWorker(callback), val_(value) {} ~TestWork() {} void Execute() { printf("the worker-thread doing! %d \n", val_); sleep(3); printf("the worker-thread done! %d \n", val_); } void OnOK() { Callback().Call({Env().Undefined(), Number::New(Env(), 0)}); } private: int val_; }; Value test(const CallbackInfo &info) { // ai::ORTSession(nullptr, 0); // Function callback = info[1].As(); // TestWork *work = new TestWork(callback, info[0].As().Int32Value()); // work->Queue(); return info.Env().Undefined(); } Object Init(Env env, Object exports) { //OpenCV NODE_INIT_OBJECT(cv, InstallOpenCVAPI); //OnnxRuntime #ifdef USE_ORT NODE_INIT_OBJECT(ort, InstallOrtAPI); #endif Napi::Number::New(env, 0); #define ADD_FUNCTION(name) exports.Set(Napi::String::New(env, #name), Napi::Function::New(env, name)) // ADD_FUNCTION(facedetPredict); // ADD_FUNCTION(facedetRelease); // ADD_FUNCTION(faceRecognitionCreate); // ADD_FUNCTION(faceRecognitionPredict); // ADD_FUNCTION(faceRecognitionRelease); // ADD_FUNCTION(getDistance); #undef ADD_FUNCTION return exports; } NODE_API_MODULE(addon, Init)