visualize.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright (c) 2020 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. #pragma once
  15. #include <iostream>
  16. #include <map>
  17. #include <vector>
  18. #ifdef _WIN32
  19. #include <direct.h>
  20. #include <io.h>
  21. #else // Linux/Unix
  22. #include <dirent.h>
  23. #include <sys/io.h>
  24. #include <sys/stat.h>
  25. #include <sys/types.h>
  26. #include <unistd.h>
  27. #endif
  28. #include <string>
  29. #include <opencv2/core/core.hpp>
  30. #include <opencv2/highgui/highgui.hpp>
  31. #include <opencv2/imgproc/imgproc.hpp>
  32. #include "include/paddlex/results.h"
  33. #ifdef _WIN32
  34. #define OS_PATH_SEP "\\"
  35. #else
  36. #define OS_PATH_SEP "/"
  37. #endif
  38. namespace PaddleX {
  39. // Generate visualization colormap for each class
  40. std::vector<int> GenerateColorMap(int num_class);
  41. cv::Mat Visualize(const cv::Mat& img,
  42. const DetResult& results,
  43. const std::map<int, std::string>& labels,
  44. const std::vector<int>& colormap,
  45. float threshold = 0.5);
  46. cv::Mat Visualize(const cv::Mat& img,
  47. const SegResult& result,
  48. const std::map<int, std::string>& labels,
  49. const std::vector<int>& colormap);
  50. std::string generate_save_path(const std::string& save_dir,
  51. const std::string& file_path);
  52. } // namespce of PaddleX