|
|
|
|
@ -528,6 +528,7 @@ int ImgCheckAnalysisy::Adapt_Config(Mat img, Rect cur_roi, bool b_update){
|
|
|
|
|
m_old_cur_markLine_mark1 = m_AnalysisyConfig.baseFunction.markLine.mark_local_1;
|
|
|
|
|
m_old_cur_markLine_mark2 = m_AnalysisyConfig.baseFunction.markLine.mark_local_2;
|
|
|
|
|
m_old_cur_regionConfigArr = m_AnalysisyConfig.commonCheckConfig.nodeConfigArr[0].regionConfigArr;
|
|
|
|
|
m_old_cur_traditional_region = m_pbaseCheckFunction->traditionDet.detArea;
|
|
|
|
|
}
|
|
|
|
|
Rect old_roi = m_old_productROI;
|
|
|
|
|
Point old_center(old_roi.x + old_roi.width / 2, old_roi.y + old_roi.height / 2);
|
|
|
|
|
@ -553,6 +554,8 @@ int ImgCheckAnalysisy::Adapt_Config(Mat img, Rect cur_roi, bool b_update){
|
|
|
|
|
cv::Point& cur_markLine_mark1 = m_AnalysisyConfig.baseFunction.markLine.mark_local_1;
|
|
|
|
|
cv::Point& cur_markLine_mark2 = m_AnalysisyConfig.baseFunction.markLine.mark_local_2;
|
|
|
|
|
std::vector<RegionConfigST>& cur_regionConfigArr = m_AnalysisyConfig.commonCheckConfig.nodeConfigArr[0].regionConfigArr;
|
|
|
|
|
cv::Rect& cur_traditional_rect = m_pbaseCheckFunction->traditionDet.detArea_ROI;
|
|
|
|
|
std::vector<cv::Point>& cur_traditional_region = m_pbaseCheckFunction->traditionDet.detArea;
|
|
|
|
|
|
|
|
|
|
/*进行修改*/
|
|
|
|
|
// rect
|
|
|
|
|
@ -582,7 +585,11 @@ int ImgCheckAnalysisy::Adapt_Config(Mat img, Rect cur_roi, bool b_update){
|
|
|
|
|
cur_regionConfigArr[i].basicInfo.pointArry[j] = Point((cur_regionConfigArr[i].basicInfo.pointArry[j].x - new_center.x) * scale_x + new_center.x, (cur_regionConfigArr[i].basicInfo.pointArry[j].y - new_center.y) * scale_y + new_center.y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < cur_traditional_region.size(); i++){
|
|
|
|
|
cur_traditional_region[i].x = m_old_cur_traditional_region[i].x + x_offset;
|
|
|
|
|
cur_traditional_region[i].y = m_old_cur_traditional_region[i].y + y_offset;
|
|
|
|
|
cur_traditional_region[i] = Point((cur_traditional_region[i].x - new_center.x) * scale_x + new_center.x, (cur_traditional_region[i].y - new_center.y) * scale_y + new_center.y);
|
|
|
|
|
}
|
|
|
|
|
/*show*/
|
|
|
|
|
// Mat show_img = img.clone();
|
|
|
|
|
// cv::rectangle(show_img, m_AnalysisyConfig.baseFunction.markLine.productROI, Scalar(255), 5);
|
|
|
|
|
@ -1631,6 +1638,14 @@ int ImgCheckAnalysisy::Traditional_Detect_Thread(const cv::Mat &img, cv::Mat &Re
|
|
|
|
|
std::string strBaseLog = "Traditional_Detect";
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_0, DET_LOG_LEVEL_3, strBaseLog, "Traditional_Detect Start");
|
|
|
|
|
|
|
|
|
|
// 输入校验
|
|
|
|
|
if (img.empty())
|
|
|
|
|
{
|
|
|
|
|
m_pdetlog->AddCheckstr(PrintLevel_0, DET_LOG_LEVEL_3, strBaseLog, "Traditional_Detect FAILED (empty image)");
|
|
|
|
|
ResultImg = cv::Mat();
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Base_Function_TraditionDet traditionParam = m_pbaseCheckFunction->traditionDet;
|
|
|
|
|
// 首次调用时初始化传统检测参数(从 m_AnalysisyConfig 映射)
|
|
|
|
|
static bool bTcsInited = false;
|
|
|
|
|
@ -1652,7 +1667,10 @@ int ImgCheckAnalysisy::Traditional_Detect_Thread(const cv::Mat &img, cv::Mat &Re
|
|
|
|
|
bTcsInited = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cv::Rect detroi = traditionParam.detArea_ROI;
|
|
|
|
|
cv::Rect detroi = cv::boundingRect(traditionParam.detArea);
|
|
|
|
|
detroi.x -= m_Crop_Roi_paramImg.x;
|
|
|
|
|
detroi.y -= m_Crop_Roi_paramImg.y;
|
|
|
|
|
detroi = detroi & cv::Rect(0, 0, img.cols, img.rows);
|
|
|
|
|
if(!traditionParam.bdetArea)
|
|
|
|
|
{
|
|
|
|
|
detroi = cv::Rect(0, 0, img.cols, img.rows);
|
|
|
|
|
@ -2254,7 +2272,7 @@ int ImgCheckAnalysisy::Edge_Qx_Det(const cv::Mat &img)
|
|
|
|
|
cv::Point pCenter;
|
|
|
|
|
pCenter.x = temerror.roi.x + temerror.roi.width * 0.5;
|
|
|
|
|
pCenter.y = temerror.roi.y + temerror.roi.height * 0.5;
|
|
|
|
|
int nmaxregionIdx = 0;
|
|
|
|
|
int nmaxregionIdx = -1;
|
|
|
|
|
for (int iregion = 0; iregion < m_DetRoiList.roiList_Src.size(); iregion++)
|
|
|
|
|
{
|
|
|
|
|
const std::vector<cv::Point> &polygon = m_DetRoiList.roiList_Src[iregion];
|
|
|
|
|
@ -2266,7 +2284,10 @@ int ImgCheckAnalysisy::Edge_Qx_Det(const cv::Mat &img)
|
|
|
|
|
nmaxregionIdx = iregion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
temerror.detRegionidxList.push_back(nmaxregionIdx);
|
|
|
|
|
if (nmaxregionIdx >= 0)
|
|
|
|
|
{
|
|
|
|
|
temerror.detRegionidxList.push_back(nmaxregionIdx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
@ -2347,7 +2368,7 @@ int ImgCheckAnalysisy::BLobToDetResult()
|
|
|
|
|
cv::Point pCenter;
|
|
|
|
|
pCenter.x = roi.x + roi.width * 0.5;
|
|
|
|
|
pCenter.y = roi.y + roi.height * 0.5;
|
|
|
|
|
int nmaxregionIdx = 0;
|
|
|
|
|
int nmaxregionIdx = -1;
|
|
|
|
|
for (int iregion = 0; iregion < m_DetRoiList.roiList_Src.size(); iregion++)
|
|
|
|
|
{
|
|
|
|
|
const std::vector<cv::Point> &polygon = m_DetRoiList.roiList_Src[iregion];
|
|
|
|
|
@ -2359,7 +2380,10 @@ int ImgCheckAnalysisy::BLobToDetResult()
|
|
|
|
|
nmaxregionIdx = iregion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
temerror.detRegionidxList.push_back(nmaxregionIdx);
|
|
|
|
|
if (nmaxregionIdx >= 0)
|
|
|
|
|
{
|
|
|
|
|
temerror.detRegionidxList.push_back(nmaxregionIdx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|