cns_openpose.hpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*************************************************************************
  2. * Copyright (C) [2021] by Cambricon, Inc. All rights reserved
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  15. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. * THE SOFTWARE.
  19. *************************************************************************/
  20. #include <opencv2/opencv.hpp>
  21. #include <array>
  22. #include <map>
  23. #include <string>
  24. #include <utility>
  25. #include <vector>
  26. namespace cns_openpose {
  27. static const std::map<unsigned int, std::string> kBody25PartStrs {
  28. {0, "Nose"},
  29. {1, "Neck"},
  30. {2, "RShoulder"},
  31. {3, "RElbow"},
  32. {4, "RWrist"},
  33. {5, "LShoulder"},
  34. {6, "LElbow"},
  35. {7, "LWrist"},
  36. {8, "MidHip"},
  37. {9, "RHip"},
  38. {10, "RKnee"},
  39. {11, "RAnkle"},
  40. {12, "LHip"},
  41. {13, "LKnee"},
  42. {14, "LAnkle"},
  43. {15, "REye"},
  44. {16, "LEye"},
  45. {17, "REar"},
  46. {18, "LEar"},
  47. {19, "LBigToe"},
  48. {20, "LSmallToe"},
  49. {21, "LHeel"},
  50. {22, "RBigToe"},
  51. {23, "RSmallToe"},
  52. {24, "RHeel"},
  53. {25, "Background"}
  54. };
  55. static const std::map<unsigned int, std::string> kBodyCOCOPartStrs {
  56. {0, "Nose"},
  57. {1, "Neck"},
  58. {2, "RShoulder"},
  59. {3, "RElbow"},
  60. {4, "RWrist"},
  61. {5, "LShoulder"},
  62. {6, "LElbow"},
  63. {7, "LWrist"},
  64. {8, "RHip"},
  65. {9, "RKnee"},
  66. {10, "RAnkle"},
  67. {11, "LHip"},
  68. {12, "LKnee"},
  69. {13, "LAnkle"},
  70. {14, "REye"},
  71. {15, "LEye"},
  72. {16, "REar"},
  73. {17, "LEar"},
  74. {18, "Background"}
  75. };
  76. using Keypoints = std::vector<std::vector<cv::Point>>;
  77. using Limbs = std::vector<std::vector<std::pair<cv::Point, cv::Point>>>;
  78. static constexpr char kPoseKeypointsTag[] = "POSE_KEYPOINTS";
  79. static constexpr char kPoseLimbsTag[] = "POSE_LIMBS";
  80. } // namespace cns_openpose