ContourModifyExport.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #include <opencv2/opencv.hpp>
  3. #ifdef _WIN32
  4. #define EXPORT_API __declspec(dllexport)
  5. #else
  6. #define EXPORT_API
  7. #endif
  8. using namespace cv;
  9. #define PI (3.14159265358979323846)
  10. #define PI_DIV_180 (0.017453292519943296)//¦Ð/180
  11. #define DegToRad(x) ((x)*PI_DIV_180)//½Ç¶Èת»»Îª»¡¶È
  12. typedef struct MyPoint
  13. {
  14. int x;
  15. int y;
  16. }MyPoint;
  17. typedef struct LesionSize
  18. {
  19. MyPoint hl;
  20. MyPoint hr;
  21. MyPoint vu;
  22. MyPoint vd;
  23. }LesionSize;
  24. typedef struct MyRect
  25. {
  26. int left;
  27. int right;
  28. int top;
  29. int bottom;
  30. }MyRect;
  31. typedef struct SelfCrossRegionDetails
  32. {
  33. std::pair<int, int> eliminateStartIndexPair;
  34. std::pair<int, int> eliminateEndIndexPair;
  35. }SelfCrossRegionDetails;
  36. typedef struct InterecttionsDetails
  37. {
  38. int indexInContour;
  39. double distanceToLineStart;
  40. double distanceToLineEnd;
  41. }InterecttionsDetails;
  42. typedef struct InterecttionsResults
  43. {
  44. bool intersectWithLineStart;
  45. bool intersectWithLineEnd;
  46. int indexInContourIntersectionStart;
  47. int indexInContourIntersectionEnd;
  48. }InterecttionsResults;
  49. extern "C" EXPORT_API bool GetRotationTransMat(const MyPoint pointFix, const MyPoint pointMoveBef, const MyPoint pointMoveAft,double * rotMatDatas);
  50. extern "C" EXPORT_API bool RotateAndScalePoints(double* rotMatDatas, const int pointNum, MyPoint * pointsBef, MyPoint * pointsAft);
  51. extern "C" EXPORT_API bool RotatePoints(const MyPoint pointCenter, double angle, const int pointNum, MyPoint * pointsBef, MyPoint * pointsAft);
  52. extern "C" EXPORT_API bool AngleBetweenTwoLine(const MyPoint pointOrigin, const MyPoint pointAnyDir,const MyPoint pointXDir,double& angle);
  53. extern "C" EXPORT_API bool ContourArea(const MyPoint * points,const int pointNum, int& area);
  54. extern "C" EXPORT_API bool GetContourPointByPoint(const MyPoint * pointsBef, const int pointNum, MyPoint * pointsAft, int& pointNumAft);
  55. extern "C" EXPORT_API bool GetContourWithLineAA(const MyPoint * pointsBef, const int pointNum, MyPoint * pointsAft, int& pointNumAft);
  56. extern "C" EXPORT_API bool GetContourPointByPointEliminateSelfCross(const MyPoint * pointsBef, const int pointNumBef, MyPoint * pointsAft, int& pointNumAft);
  57. extern "C" EXPORT_API bool LineContourIntersection(const MyPoint * points, const int pointNum, const MyPoint lineStart, const MyPoint lineEnd,
  58. const int touchDistance, bool extended, InterecttionsResults& results);
  59. MyRect ContourBoundBox(const MyPoint* points, const int pointNum);
  60. double DistanceBetweenTwoPoints(const MyPoint pointOne, const MyPoint pointOther);
  61. double DistanceBetweenTwoRect(const MyRect rectOne, const MyRect rectOther);
  62. bool SortPointByDistanceIncrease(std::pair<double, MyPoint>a, std::pair<double, MyPoint>b);
  63. bool SortIntersectionByDistanceToStartIncrease(InterecttionsDetails a, InterecttionsDetails b);
  64. bool SortIntersectionByDistanceToEndIncrease(InterecttionsDetails a, InterecttionsDetails b);
  65. bool AddPointsPixelByPixel(std::vector<MyPoint>& contours, MyPoint pointToAdd, MyPoint pointPre);
  66. bool CheckIfContourSelfCrossed(std::vector<MyPoint> contours, int curIndex, int preStartCount,int& indexOfClosePoint);