MNN/cpp/src/mnn_run.cpp
/**
 * @brief inference on mnn
 * 
 * @param image opencv image
 * @param output output float data
 */
@brief inference on mnn

@param image opencv image
@param output output float data
@brief inference on mnn @param image opencv image @param output output float data
void MNNModel::forward(const cv::Mat& image, vector<float>& output) {
    memcpy(this->hostInputTensor->host<float>(), image.data, this->hostInputTensor->size());
    this->modelInputTensor->copyFromHostTensor(this->hostInputTensor);
    net->runSession(session);
    this->modelOutputTensor->copyToHostTensor(this->hostOutputTensor);
    output.resize(this->hostOutputTensor->elementSize());
    memcpy(output.data(), this->hostOutputTensor->host<float>(), this->hostOutputTensor->size());
}
void MNNModel :: forward ( const cv :: Mat & image , vector < float > & output ) { memcpy ( this -> hostInputTensor -> host < float > ( ) , image . data , this -> hostInputTensor -> size ( ) ) ; this -> modelInputTensor -> copyFromHostTensor ( this -> hostInputTensor ) ; net -> runSession ( session ) ; this -> modelOutputTensor -> copyToHostTensor ( this -> hostOutputTensor ) ; output . resize ( this -> hostOutputTensor -> elementSize ( ) ) ; memcpy ( output . data ( ) , this -> hostOutputTensor -> host < float > ( ) , this -> hostOutputTensor -> size ( ) ) ; }
@brief inference on mnn
@brief inference on mnn