uvdoc_postprocessor.cc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include "ultra_infer/vision/ocr/ppocr/uvdoc_postprocessor.h"
  15. #include "ultra_infer/utils/perf.h"
  16. #include "ultra_infer/vision/ocr/ppocr/utils/ocr_utils.h"
  17. namespace ultra_infer {
  18. namespace vision {
  19. namespace ocr {
  20. // bool UVDocPostprocessor::SingleBatchPostprocessor(const float* out_data,
  21. // cv::Mat* result) {
  22. // // Reverse normalization
  23. // std::vector<float> mean{127.5f, 127.5f, 127.5f};
  24. // std::vector<float> std{127.5f, 127.5f, 127.5f};
  25. // Mat result_mat = Mat::Create(result->rows, result->cols, 3,
  26. // FDDataType::FP32, const_cast<float*>(out_data));
  27. // Convert::Run(&result_mat, mean, std);
  28. // // Convert result_mat to OpenCV Mat object
  29. // auto temp = result_mat.GetOpenCVMat();
  30. // cv::Mat res = cv::Mat::zeros(temp->size(), CV_8UC3);
  31. // temp->convertTo(res, CV_8UC3, 1);
  32. // // Execute BGR2RGB conversion
  33. // Mat fd_image = WrapMat(res);
  34. // BGR2RGB::Run(&fd_image);
  35. // res = *(fd_image.GetOpenCVMat());
  36. // // Copy result to output
  37. // res.copyTo(*result);
  38. // return true;
  39. // }
  40. bool UVDocPostprocessor::Run(const std::vector<FDTensor> &infer_results,
  41. std::vector<FDTensor> *results) {
  42. *results = infer_results;
  43. return true;
  44. }
  45. } // namespace ocr
  46. } // namespace vision
  47. } // namespace ultra_infer