diff --git a/HanddleAI/HandleAiUi-new/algo/ALGO_Inspection.h b/HanddleAI/HandleAiUi-new/algo/ALGO_Inspection.h index b08ddddb..ed07b86f 100644 --- a/HanddleAI/HandleAiUi-new/algo/ALGO_Inspection.h +++ b/HanddleAI/HandleAiUi-new/algo/ALGO_Inspection.h @@ -159,8 +159,7 @@ void pinHandleAiEvaluate(std::shared_ptr data, } -bool pinHalconEvaluate(std::vector& Result, cv::Mat& src, cv::Mat& out - , int productType, int pinRow, int pinCol) +bool pinHalconEvaluate(std::vector& Result, cv::Mat& src, cv::Mat& out,int productType) { #pragma region halcon变量定义 @@ -221,11 +220,14 @@ bool pinHalconEvaluate(std::vector& Result, cv::Mat& src, cv::Mat& out //} } -cv::Mat pinDetEvaluate(cv::Mat& src, handleAiModelManager* _handleAiModelManager) +std::vector pinDetEvaluate(cv::Mat& src, handleAiModelManager* _handleAiModelManager) { cv::Mat resultImg; std::vector result; _handleAiModelManager->smalDet->Evaluate(src, result); +} +cv::Mat getpinHandleAiEvaluateImg(cv::Mat& src, std::vector& result) +{ cv::Point centerPos(src.rows / 2, src.cols / 2); std::vector targets; cv::Rect targetRect(src.cols / 4, src.rows / 4, src.cols / 2, src.rows / 2); @@ -255,7 +257,6 @@ cv::Mat pinDetEvaluate(cv::Mat& src, handleAiModelManager* _handleAiModelManager return src(resultRect); } - void ALGO_Inspection(std::shared_ptr data, handleAiModelManager* _handleAiModelManager) { if (data->oriImgs.size() < 1) @@ -264,26 +265,18 @@ void ALGO_Inspection(std::shared_ptr data, handleAiModelManager* _hand return; } cv::Mat src = data->oriImgs[0]; - //DET - cv::Mat detResult = pinDetEvaluate(src, _handleAiModelManager); + //使用det获取每个公头的位置 + std::vector pinPos= pinDetEvaluate(src, _handleAiModelManager); + //获取用于handleAi检测的图片 + cv::Mat detResult = getpinHandleAiEvaluateImg(src,pinPos); cv::Mat Paint; cvtColor(detResult, Paint, cv::COLOR_GRAY2BGR); std::vectorhalconResult; - //hv_in_Parameter - //[0]-产品种类; 1A正面 2A反面 3B正面 5C正面 int productType = 3; - //[1]-图像序号第一位; - int pinRow = 1; - //[2]-图像序号第二位; - int pinCol = 0; - //[3]-3d相机精度(mm); - //[4]-ping针偏移判NG阈值(mm); - //[5]-切图存图开关 - //HALCON cv::Mat halconMatResult; - bool halconBoolResult=pinHalconEvaluate(halconResult, detResult, halconMatResult, productType, pinRow, pinCol); + bool halconBoolResult=pinHalconEvaluate(halconResult, detResult, halconMatResult, productType); //HANDLEAI switch (productType) @@ -312,6 +305,6 @@ void ALGO_Inspection(std::shared_ptr data, handleAiModelManager* _hand data->resultImgs.push_back(Paint);//AI检测结果 if(halconBoolResult==true) data->resultImgs.push_back(halconMatResult);//AI检测结果 - _sleep(100); + //_sleep(100); } diff --git a/HanddleAI/HandleAiUi-new/halconAlgo/Inspection.h b/HanddleAI/HandleAiUi-new/halconAlgo/Inspection.h index a051f800..d40ee82a 100644 --- a/HanddleAI/HandleAiUi-new/halconAlgo/Inspection.h +++ b/HanddleAI/HandleAiUi-new/halconAlgo/Inspection.h @@ -1549,34 +1549,35 @@ void Pings_Inspection_2_Front (HObject ho_in_Image, HTuple hv_in_ShapePath, HTup try { - //定位 + ////定位 //Pings_ROI_Rec2(ho_in_Image, hv_in_ShapePath, hv_in_Parameter, &hvec_out_ROI_Row, // &hvec_out_ROI_Col, &(*hv_out_Flag)); - //等分 - hv_Num = (HTuple(hvec_out_ROI_Row.Length()).TupleInt())-1; + ////等分 + //hv_Num = (HTuple(hvec_out_ROI_Row.Length()).TupleInt())-1; { - HTuple end_val14 = hv_Num; - HTuple step_val14 = 1; - for (hv_Index2=0; hv_Index2.Continue(end_val14, step_val14); hv_Index2 += step_val14) - { - //GenRegionPolygon(&ho_ROI, hvec_out_ROI_Row[hv_Index2].T(), hvec_out_ROI_Col[hv_Index2].T()); - //FillUp(ho_ROI, &ho_ROI); - //AreaCenter(ho_ROI, &hv_Area, &hv_Row0, &hv_Column0); - //RegionFeatures(ho_ROI, ((((HTuple("row").Append("column")).Append("rect2_phi")).Append("rect2_len1")).Append("rect2_len2")), - // &hv_Value1); - //RegionFeatures(ho_ROI, (HTuple("width").Append("height")), &hv_Value); - ho_ROI = ho_in_Image; - if (0 != (int(HTuple(hv_Value[0])