永续合约及合约交易系统开发需求项目丨永续合约/合约交易所源码程序
web3.js是一个JavaScript API库。要让DApp在以太坊上运行,我们可以使用web3.js库提供的web3对象。web3.js通过RPC调用与本地节点通信,它可以与任何公开RPC层的以太坊节点一起使用。web3包含eth对象-web3.eth(用于与以太坊区块链交互)和shh对象-web3.shh(用于与Whisper交互)
class PFLD::Impl {
public:
Impl() {
device_ = 0;
precision_ = 0;
power_ = 0;
memory_ = 0;
initialized_ = false;
}
~Impl() {
landmarker_->releaseModel();
landmarker_->releaseSession(session_);
}
int LoadModel(const char* root_path);
int ExtractKeypoints(const cv::Mat& img_face, std::vector<cv::Point2f>* keypoints);
std::shared_ptr<MNN::Interpreter> landmarker_;
const int inputSize_ = 96;
int device_;
int precision_;
int power_;
int memory_;
MNN::Session* session_ = nullptr;
MNN::Tensor* input_tensor_ = nullptr;
bool initialized_;
};
int PFLD::Impl::LoadModel(const char* root_path) {
std::string model_file = std::string(root_path) + "/pfld-lite.mnn";
landmarker_ = std::shared_ptr<MNN::Interpreter>(MNN::Interpreter::createFromFile(model_file.c_str()));
MNN::ScheduleConfig config;
config.numThread = 1;
config.type = static_cast<MNNForwardType>(device_);
MNN::BackendConfig backendConfig;
backendConfig.precision = (MNN::BackendConfig::PrecisionMode)precision_;
backendConfig.power = (MNN::BackendConfig::PowerMode) power_;
backendConfig.memory = (MNN::BackendConfig::MemoryMode) memory_;
config.backendConfig = &backendConfig;
session_ = landmarker_->createSession(config);
// nhwc to nchw
std::vector<int> dims{1, inputSize_, inputSize_, 3};
input_tensor_ = MNN::Tensor::create<float>(dims, NULL, MNN::Tensor::TENSORFLOW);
initialized_ = true;
return 0;
}

