#pragma once #include #include #include #ifdef _WIN32 #include // Windows: _access #else #include // Linux/macOS: access #endif #define ORT_OLD_VISON 13 //ort1.12.0 之前的版本为旧版本API struct PoseKeyPoint { float x = 0; float y = 0; float confidence = 0; }; struct OutputParams { int id; //结果类别id float confidence; //结果置信度 cv::Rect box; //矩形框 cv::RotatedRect rotatedBox; //obb结果矩形框 cv::Mat boxMask; //矩形框内mask,节省内存空间和加快速度 std::vector keyPoints; //pose key points }; struct MaskParams { //int segChannels = 32; //int segWidth = 160; //int segHeight = 160; int netWidth = 640; int netHeight = 640; float maskThreshold = 0.5; cv::Size srcImgShape; cv::Vec4d params; }; struct PoseParams { float kptThreshold = 0.5; int kptRadius = 5; bool isDrawKptLine = false; //If True, the function will draw lines connecting keypoint for human pose.Default is True. cv::Scalar objColor = cv::Scalar(0, 0, 255); std::vector>skeleton = { {16, 14} ,{14, 12},{17, 15},{15, 13}, {12, 13},{6, 12},{7, 13},{6, 7},{6, 8},{7, 9}, {8, 10},{9, 11},{2, 3},{1, 2},{1, 3},{2, 4}, {3, 5},{4, 6},{5, 7} }; std::vector posePalette = { cv::Scalar(255, 128, 0) }; std::vector limbColor = {0}; std::vector kptColor = {0}; std::map kptBodyNames{ {0,"A"} }; }; bool CheckModelPath(std::string modelPath); bool CheckParams(int netHeight, int netWidth, const int* netStride, int strideSize); void DrawPred(cv::Mat& img, std::vector result, std::vector classNames, std::vector color ); void DrawPredPose(cv::Mat& img, std::vector result, PoseParams& poseParams); void DrawRotatedBox(cv::Mat& srcImg, cv::RotatedRect box, cv::Scalar color, int thinkness); void LetterBox(const cv::Mat& image, cv::Mat& outImage, cv::Vec4d& params, //[ratio_x,ratio_y,dw,dh] const cv::Size& newShape = cv::Size(640, 640), bool autoShape = false, bool scaleFill = false, bool scaleUp = true, int stride = 32, const cv::Scalar& color = cv::Scalar(114, 114, 114)); void GetMask(const cv::Mat& maskProposals, const cv::Mat& maskProtos, std::vector& output, const MaskParams& maskParams); void GetMask2(const cv::Mat& maskProposals, const cv::Mat& maskProtos, OutputParams& output, const MaskParams& maskParams); int BBox2Obb(float centerX, float centerY, float boxW, float boxH, float angle, cv::RotatedRect& rotatedRect);