#include "stdafx.h" #include "SigmaView.h" #include "ItemCalibrate.h" #pragma pack(1) struct FourPoint { //输入的四个点的坐标 double cx1; double cy1; double cx2; double cy2; double cx3; double cy3; double cx4; double cy4; //四个点的世界坐标 double wx1; double wy1; double wx2; double wy2; double wx3; double wy3; double wx4; double wy4; }; #pragma pack() #pragma pack(1) struct TwoPoint { //输入的四个点的坐标 double cx1; double cy1; double cx2; double cy2; //四个点的世界坐标 double wx1; double wy1; double wx2; double wy2; }; #pragma pack() extern "C" __declspec(dllexport) int CalibrateForFourPoint(CSigmaView* pView, FourPoint * fourPts, int coordinateMode) { if (!pView || !pView->m_pDoc || fourPts == 0) { return -1; } if (coordinateMode < 0 || coordinateMode >2) { return -1; } CItemCalibrate item(pView->m_pDoc); std::vector pts; CPoint2D pt1(fourPts->cx1, fourPts->cy1); pts.push_back(pt1); CPoint2D pt2(fourPts->cx2, fourPts->cy2); pts.push_back(pt2); CPoint2D pt3(fourPts->cx3, fourPts->cy3); pts.push_back(pt3); CPoint2D pt4(fourPts->cx4, fourPts->cy4); pts.push_back(pt4); CPoint2D pt5(fourPts->wx1, fourPts->wy1); pts.push_back(pt5); CPoint2D pt6(fourPts->wx2, fourPts->wy2); pts.push_back(pt6); CPoint2D pt7(fourPts->wx3, fourPts->wy3); pts.push_back(pt7); CPoint2D pt8(fourPts->wx4, fourPts->wy4); pts.push_back(pt8); if (item.CalibrateForFourPoint(pts, (COORDINATE_MODE)coordinateMode)) { return 1; } return -1; } extern "C" __declspec(dllexport) int CalibrateForTwoPoint(CSigmaView* pView, TwoPoint * twoPts, int coordinateMode) { if (!pView || !pView->m_pDoc || twoPts == 0) { return -1; } if (coordinateMode < 0 || coordinateMode >2) { return -1; } CItemCalibrate item(pView->m_pDoc); std::vector pts; CPoint2D pt1(twoPts->cx1, twoPts->cy1); pts.push_back(pt1); CPoint2D pt2(twoPts->cx2, twoPts->cy2); pts.push_back(pt2); CPoint2D pt5(twoPts->wx1, twoPts->wy1); pts.push_back(pt5); CPoint2D pt6(twoPts->wx2, twoPts->wy2); pts.push_back(pt6); if (item.CalibrateForTwoPoint(pts, (COORDINATE_MODE)coordinateMode)) { return 1; } return -1; }