|
|
|
@ -501,6 +501,32 @@ int CheckUtil::CreateDir(const std::string &dir)
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int CheckUtil::SaveImgAsync(const std::string &path, const cv::Mat &img)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (path.empty() || img.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 拷贝图像,避免异步线程执行时原图像被释放或修改
|
|
|
|
|
|
|
|
cv::Mat imgCopy = img.clone();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 创建保存路径的父目录
|
|
|
|
|
|
|
|
std::string::size_type pos = path.find_last_of('/');
|
|
|
|
|
|
|
|
if (pos != std::string::npos)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::string parentDir = path.substr(0, pos);
|
|
|
|
|
|
|
|
CheckUtil::CreateDir(parentDir);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 启动后台线程异步存图
|
|
|
|
|
|
|
|
std::thread([path, imgCopy]() {
|
|
|
|
|
|
|
|
cv::imwrite(path, imgCopy);
|
|
|
|
|
|
|
|
}).detach();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CheckUtil::bcalDis(cv::Point p1, cv::Point p2, int disT)
|
|
|
|
bool CheckUtil::bcalDis(cv::Point p1, cv::Point p2, int disT)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
double dis = std::sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
|
|
|
|
double dis = std::sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
|
|
|
|
|