| 335 | } |
| 336 | |
| 337 | void Segmentation::runERF(cv::Mat& rImg, cv::Mat& maskImg){ |
| 338 | cv::Mat pImg(rImg.rows, rImg.cols, CV_32FC2, cv::Scalar(0)); |
| 339 | _preProcessRange(rImg, pImg, 30); |
| 340 | |
| 341 | std::vector<float> outputTensorValues(_outputTensorSize); |
| 342 | std::vector<float> inputTensorValues(_inputTensorSize); |
| 343 | |
| 344 | auto imgSize = pImg.rows * pImg.cols * pImg.channels(); |
| 345 | memcpy(inputTensorValues.data(), pImg.data, imgSize * sizeof(float)); |
| 346 | std::cout << "Tensor size: " << _inputTensorSize << std::endl; |
| 347 | std::cout << "Tensor size: " << _outputTensorSize << std::endl; |
| 348 | std::cout << "DAta size: " << imgSize << std::endl; |
| 349 | |
| 350 | std::vector<Ort::Value> inputTensors; |
| 351 | std::vector<Ort::Value> outputTensors; |
| 352 | inputTensors.push_back(Ort::Value::CreateTensor<float>( |
| 353 | *_memoryInfo, inputTensorValues.data(), _inputTensorSize, _inputDims.data(), |
| 354 | _inputDims.size())); |
| 355 | |
| 356 | outputTensors.push_back(Ort::Value::CreateTensor<float>( |
| 357 | *_memoryInfo, outputTensorValues.data(), _outputTensorSize, |
| 358 | _outputDims.data(), _outputDims.size())); |
| 359 | |
| 360 | _session->Run(Ort::RunOptions{nullptr}, _inputNames.data(), |
| 361 | inputTensors.data(), 1, _outputNames.data(), |
| 362 | outputTensors.data(), 1); |
| 363 | |
| 364 | float* outData = outputTensors.front().GetTensorMutableData<float>(); |
| 365 | // int dims[] = {3,64,2048}; |
| 366 | // cv::Mat result = cv::Mat(3, dims, CV_32F, outData); |
| 367 | // cv::FileStorage file("/opt/bags/inf/res.ext", cv::FileStorage::WRITE); |
| 368 | // Write to file! |
| 369 | // file << "matName" << result; |
| 370 | // std::cout << sizeof(outData) << std::endl; |
| 371 | _argmax(outData, maskImg); |
| 372 | } |
| 373 | |
| 374 | void Segmentation::run(const Cloud::Ptr cloud, cv::Mat& maskImg){ |
| 375 | std::vector<float> cloudVector; |