143 lines
2.8 KiB
C++
143 lines
2.8 KiB
C++
![]() |
#include "Libapi2D3D.h"
|
||
|
|
||
|
|
||
|
CMeasureInfo* CMeasureInfo::m_instance;
|
||
|
|
||
|
CMeasureInfo* CMeasureInfo::Get()
|
||
|
{
|
||
|
if (CMeasureInfo::m_instance == nullptr)
|
||
|
{
|
||
|
assert(0);
|
||
|
}
|
||
|
return CMeasureInfo::m_instance;
|
||
|
}
|
||
|
|
||
|
CMeasureInfo* CMeasureInfo::Clear()
|
||
|
{
|
||
|
if (CMeasureInfo::m_instance == nullptr)
|
||
|
{
|
||
|
assert(0);
|
||
|
}
|
||
|
CMeasureInfo* measureInfo = CMeasureInfo::m_instance;
|
||
|
measureInfo->mId = -1;
|
||
|
measureInfo->mInfo = "";
|
||
|
measureInfo->mImPtr = nullptr;
|
||
|
measureInfo->mIm2D3DPtr = nullptr;
|
||
|
for (int i = 0; i < measureInfo->subRois.size(); ++i)
|
||
|
{
|
||
|
std::shared_ptr<CSubRoi> roi = measureInfo->subRois[i];
|
||
|
roi->mId = -1;
|
||
|
roi->mInfo = "";
|
||
|
roi->mInnerConners.clear();
|
||
|
roi->mInnerConners3D.clear();
|
||
|
roi->mPparentId = -1;
|
||
|
roi->mRoiPoints.clear();
|
||
|
roi->mVc2D.clear();
|
||
|
roi->mVc3D.clear();
|
||
|
roi->vpOffset = { 0.0, 0.0 };
|
||
|
}
|
||
|
measureInfo->subRois.clear();
|
||
|
return CMeasureInfo::m_instance;
|
||
|
}
|
||
|
|
||
|
CMeasureInfo* CMeasureInfo::Init(long id, std::string info)
|
||
|
{
|
||
|
if (CMeasureInfo::m_instance == nullptr)
|
||
|
{
|
||
|
CMeasureInfo::m_instance = new CMeasureInfo(id, info);
|
||
|
}
|
||
|
CMeasureInfo::Clear();
|
||
|
CMeasureInfo* measureInfo = CMeasureInfo::m_instance;
|
||
|
measureInfo->mId = id;
|
||
|
measureInfo->mInfo = info;
|
||
|
|
||
|
return CMeasureInfo::m_instance;
|
||
|
}
|
||
|
|
||
|
CMeasureInfo::CMeasureInfo()
|
||
|
{
|
||
|
};
|
||
|
|
||
|
CMeasureInfo::CMeasureInfo(long id, std::string info)
|
||
|
{
|
||
|
this->mId = id;
|
||
|
this->mInfo = info;
|
||
|
}
|
||
|
|
||
|
CMeasureInfo::~CMeasureInfo()
|
||
|
{
|
||
|
// 统一在这里删除
|
||
|
this->mImPtr = nullptr;
|
||
|
};
|
||
|
|
||
|
long CMeasureInfo::GetID()
|
||
|
{
|
||
|
return this->mId;
|
||
|
}
|
||
|
|
||
|
std::string CMeasureInfo::GetInfo()
|
||
|
{
|
||
|
return this->mInfo;
|
||
|
}
|
||
|
|
||
|
std::shared_ptr<cv::Mat> CMeasureInfo::GetIm()
|
||
|
{
|
||
|
return this->mImPtr;
|
||
|
};
|
||
|
|
||
|
void CMeasureInfo::SetIm(std::shared_ptr<cv::Mat>& imptr)
|
||
|
{
|
||
|
this->mImPtr = imptr;
|
||
|
};
|
||
|
|
||
|
std::shared_ptr<cv::Mat>& CMeasureInfo::GetIm2D3D()
|
||
|
{
|
||
|
return this->mIm2D3DPtr;
|
||
|
};
|
||
|
|
||
|
void CMeasureInfo::SetIm2D3D(std::shared_ptr<cv::Mat>& imim2D3Dptr)
|
||
|
{
|
||
|
this->mIm2D3DPtr = imim2D3Dptr;
|
||
|
};
|
||
|
|
||
|
std::vector<std::shared_ptr<CSubRoi>>& CMeasureInfo::GetSubRois()
|
||
|
{
|
||
|
return this->subRois;
|
||
|
};
|
||
|
|
||
|
std::vector<std::vector<cv::Point2f>> CMeasureInfo::GetAllRoiConners()
|
||
|
{
|
||
|
std::vector<std::vector<cv::Point2f>> allConners;
|
||
|
std::vector<cv::Point2f> vp2f;
|
||
|
for (int i = 0; i < this->subRois.size(); ++i)
|
||
|
{
|
||
|
CSubRoi* subRoi = this->subRois[i].get();
|
||
|
vp2f.clear();
|
||
|
for (int j = 0; j < subRoi->mInnerConners.size(); ++j)
|
||
|
{
|
||
|
vp2f.push_back(subRoi->mInnerConners[j]);
|
||
|
|
||
|
}
|
||
|
allConners.push_back(vp2f);
|
||
|
}
|
||
|
return allConners;
|
||
|
}
|
||
|
|
||
|
CSubRoi::CSubRoi()
|
||
|
{
|
||
|
this->mInfo = "";
|
||
|
//this->isGood = true;
|
||
|
};
|
||
|
|
||
|
CSubRoi::CSubRoi(long parentId, long id, std::string info)
|
||
|
{
|
||
|
this->mPparentId = parentId;
|
||
|
this->mId = id;
|
||
|
this->mInfo = info;
|
||
|
this->isGood = true;
|
||
|
}
|
||
|
|
||
|
CSubRoi::~CSubRoi()
|
||
|
{
|
||
|
|
||
|
};
|