|
|
|
@ -87,7 +87,7 @@ int Down_Detect::CheckRun()
|
|
|
|
t1 = CheckUtil::getcurTime();
|
|
|
|
t1 = CheckUtil::getcurTime();
|
|
|
|
CheckImgInit();
|
|
|
|
CheckImgInit();
|
|
|
|
cv::Mat detimg = DetImgInfo_shareP->img;
|
|
|
|
cv::Mat detimg = DetImgInfo_shareP->img;
|
|
|
|
//准备结果图
|
|
|
|
// 准备结果图
|
|
|
|
cv::resize(detimg.clone(), m_CheckResult_shareP->resultImg, cv::Size(800, 600));
|
|
|
|
cv::resize(detimg.clone(), m_CheckResult_shareP->resultImg, cv::Size(800, 600));
|
|
|
|
if (detimg.empty())
|
|
|
|
if (detimg.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -115,12 +115,16 @@ int Down_Detect::CheckRun()
|
|
|
|
re = ImgAlinRotate(detimg, AlignImg);
|
|
|
|
re = ImgAlinRotate(detimg, AlignImg);
|
|
|
|
if (0 != re)
|
|
|
|
if (0 != re)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// 失败NG
|
|
|
|
|
|
|
|
m_CheckResult_shareP->nresult = 1;
|
|
|
|
return re;
|
|
|
|
return re;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 缺陷检测
|
|
|
|
// 缺陷检测
|
|
|
|
re = DetectImg(AlignImg);
|
|
|
|
re = DetectImg(AlignImg);
|
|
|
|
if (0 != re)
|
|
|
|
if (0 != re)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// 失败NG
|
|
|
|
|
|
|
|
m_CheckResult_shareP->nresult = 1;
|
|
|
|
return re;
|
|
|
|
return re;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
t2 = CheckUtil::getcurTime();
|
|
|
|
t2 = CheckUtil::getcurTime();
|
|
|
|
@ -309,15 +313,15 @@ int Down_Detect::Draw(const cv::Mat &img, cv::Mat &resultimg)
|
|
|
|
|
|
|
|
|
|
|
|
// int x = center.x - w / 2;
|
|
|
|
// int x = center.x - w / 2;
|
|
|
|
// int y = center.y - h / 2;
|
|
|
|
// int y = center.y - h / 2;
|
|
|
|
|
|
|
|
|
|
|
|
// // 确保裁剪区域不超出图像边界
|
|
|
|
// // 确保裁剪区域不超出图像边界
|
|
|
|
// x = std::max(0, x);
|
|
|
|
// x = std::max(0, x);
|
|
|
|
// y = std::max(0, y);
|
|
|
|
// y = std::max(0, y);
|
|
|
|
// x = std::min(x, img.cols - w);
|
|
|
|
// x = std::min(x, img.cols - w);
|
|
|
|
// y = std::min(y, img.rows - h);
|
|
|
|
// y = std::min(y, img.rows - h);
|
|
|
|
|
|
|
|
|
|
|
|
// // 创建裁剪区域
|
|
|
|
// // 创建裁剪区域
|
|
|
|
// cv::Rect cropRoi(x, y, w, h);
|
|
|
|
// cv::Rect cropRoi(x, y, w, h);
|
|
|
|
// resultimg = resultimg(cropRoi).clone();
|
|
|
|
// resultimg = resultimg(cropRoi).clone();
|
|
|
|
|
|
|
|
|
|
|
|
// cv::polylines(resultimg, m_CheckBaseConfig->pointArry, true, cv::Scalar(0, 255, 0), 2);
|
|
|
|
// cv::polylines(resultimg, m_CheckBaseConfig->pointArry, true, cv::Scalar(0, 255, 0), 2);
|
|
|
|
@ -488,7 +492,7 @@ int Down_Detect::ImgAlinRotate(const cv::Mat &img, cv::Mat &alignImg)
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//判断尺寸
|
|
|
|
// 判断尺寸
|
|
|
|
int w = m_CheckBaseConfig->baseCheckFunction.detconfig.chip_width_mm / m_CheckBaseConfig->imageScaleParam.fScale_X;
|
|
|
|
int w = m_CheckBaseConfig->baseCheckFunction.detconfig.chip_width_mm / m_CheckBaseConfig->imageScaleParam.fScale_X;
|
|
|
|
int h = m_CheckBaseConfig->baseCheckFunction.detconfig.chip_height_mm / m_CheckBaseConfig->imageScaleParam.fScale_Y;
|
|
|
|
int h = m_CheckBaseConfig->baseCheckFunction.detconfig.chip_height_mm / m_CheckBaseConfig->imageScaleParam.fScale_Y;
|
|
|
|
auto w_offset = std::abs(w - m_AlignMaxRoi.width);
|
|
|
|
auto w_offset = std::abs(w - m_AlignMaxRoi.width);
|
|
|
|
@ -497,7 +501,7 @@ int Down_Detect::ImgAlinRotate(const cv::Mat &img, cv::Mat &alignImg)
|
|
|
|
int param_h_offset = m_CheckBaseConfig->baseCheckFunction.detconfig.chip_height_offset_mm / m_CheckBaseConfig->imageScaleParam.fScale_Y;
|
|
|
|
int param_h_offset = m_CheckBaseConfig->baseCheckFunction.detconfig.chip_height_offset_mm / m_CheckBaseConfig->imageScaleParam.fScale_Y;
|
|
|
|
if (w_offset > param_w_offset || h_offset > param_h_offset)
|
|
|
|
if (w_offset > param_w_offset || h_offset > param_h_offset)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
printf("Align error, no product\n");
|
|
|
|
printf("Align error, no product\n");
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|