Skip to content

File model_result.h

File List > model_result.h

Go to the documentation of this file

#pragma once

#ifdef DLL_EXPORT
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif

#include "config.h"
#include "utils.h"

#include <Windows.h>
#include <opencv2/opencv.hpp>
#include <vector>

using namespace cv;
using namespace std;


namespace inspection
{

    class ModelResult
    {
    private:
        DomainConfig _domainConfig;

        void RefineSkeleton(vector<Point> contour, vector<Point>& keypoints, int& bottomX);
        void GetKeyPoints(vector<Point> contour, vector<Point>& keypoints);
        void RefineLinearKeypoint(vector<Point>& keypoints, int a1, int a2, int a3);
        void SelectDirection(vector<Point> keypoints, vector<Point>& res, int& bias, int& bottomIdx);
        void CheckSkeletonTopPoint(vector<Point>& res, int angle, bool& flag);
        float GetAngleThreePoints(Point p1, Point p2, Point p3);
        float GetAngleFourPoints(Point p1, Point p2, Point p3, Point p4);
        int GetBottomX(vector<Point> contour);
        void MergeNeighbours(vector<Point>& keypoints, int mergeDistThres);
        void RefineCircularKeypoint(vector<Point>& keypoints, float mergeDistanceThreshold);
        void SortByX(vector<vector<Point>>& skeletons, vector<int> bottomXs);
        vector<size_t> Argsort(const std::vector<float>& array);
        vector<size_t> Argsort(const std::vector<int>& array);
        void GetCenterPoints(vector<Point>& keypoints, Point& center);
        void FindEndPointByMaximumAngle(vector<Point> keypoints, int& idx1, int& idx2);
        Mat SplitMask(Mat mask, int classID);

    public:
        map<int, Mat> masks;
        map<int, vector<vector<Point>>> skeletons;
        Mat originImage;

        ModelResult(DomainConfig dc, Mat mask, Mat originImage);
        void GetSkeleton(vector<vector<Point>> contours, vector<vector<Point>>& skeleton);
        void GetMask(vector<vector<Point>> contours, Mat& mask, Size size);
        int GetNumOfClass();
    };
}