暂存 测试
This commit is contained in:
@@ -159,8 +159,7 @@ void pinHandleAiEvaluate(std::shared_ptr <detData> data,
|
||||
|
||||
}
|
||||
|
||||
bool pinHalconEvaluate(std::vector<cv::Rect>& Result, cv::Mat& src, cv::Mat& out
|
||||
, int productType, int pinRow, int pinCol)
|
||||
bool pinHalconEvaluate(std::vector<cv::Rect>& Result, cv::Mat& src, cv::Mat& out,int productType)
|
||||
{
|
||||
|
||||
#pragma region halcon变量定义
|
||||
@@ -221,11 +220,14 @@ bool pinHalconEvaluate(std::vector<cv::Rect>& Result, cv::Mat& src, cv::Mat& out
|
||||
//}
|
||||
}
|
||||
|
||||
cv::Mat pinDetEvaluate(cv::Mat& src, handleAiModelManager* _handleAiModelManager)
|
||||
std::vector<handdleAI::Bbox> pinDetEvaluate(cv::Mat& src, handleAiModelManager* _handleAiModelManager)
|
||||
{
|
||||
cv::Mat resultImg;
|
||||
std::vector<handdleAI::Bbox> result;
|
||||
_handleAiModelManager->smalDet->Evaluate(src, result);
|
||||
}
|
||||
cv::Mat getpinHandleAiEvaluateImg(cv::Mat& src, std::vector<handdleAI::Bbox>& result)
|
||||
{
|
||||
cv::Point centerPos(src.rows / 2, src.cols / 2);
|
||||
std::vector<handdleAI::Bbox> 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 <detData> data, handleAiModelManager* _handleAiModelManager)
|
||||
{
|
||||
if (data->oriImgs.size() < 1)
|
||||
@@ -264,26 +265,18 @@ void ALGO_Inspection(std::shared_ptr <detData> data, handleAiModelManager* _hand
|
||||
return;
|
||||
}
|
||||
cv::Mat src = data->oriImgs[0];
|
||||
//DET
|
||||
cv::Mat detResult = pinDetEvaluate(src, _handleAiModelManager);
|
||||
//使用det获取每个公头的位置
|
||||
std::vector<handdleAI::Bbox> pinPos= pinDetEvaluate(src, _handleAiModelManager);
|
||||
//获取用于handleAi检测的图片
|
||||
cv::Mat detResult = getpinHandleAiEvaluateImg(src,pinPos);
|
||||
|
||||
cv::Mat Paint;
|
||||
cvtColor(detResult, Paint, cv::COLOR_GRAY2BGR);
|
||||
std::vector<cv::Rect>halconResult;
|
||||
//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 <detData> data, handleAiModelManager* _hand
|
||||
data->resultImgs.push_back(Paint);//AI检测结果
|
||||
if(halconBoolResult==true)
|
||||
data->resultImgs.push_back(halconMatResult);//AI检测结果
|
||||
_sleep(100);
|
||||
//_sleep(100);
|
||||
}
|
||||
|
||||
|
||||
@@ -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])<HTuple(hv_Value[1]))))
|
||||
{
|
||||
hv_Value1[2] = HTuple(hv_Value1[2])-(HTuple(90).TupleRad());
|
||||
hv_Rect2Len1 = ((const HTuple&)hv_Value1)[3];
|
||||
hv_Rect2Len2 = ((const HTuple&)hv_Value1)[4];
|
||||
hv_Value1[3] = hv_Rect2Len2;
|
||||
hv_Value1[4] = hv_Rect2Len1;
|
||||
}
|
||||
CropRectangle2(ho_in_Image, &ho_ImagePart, HTuple(hv_Value1[0]), HTuple(hv_Value1[1]),
|
||||
HTuple(hv_Value1[2]), HTuple(hv_Value1[3]), HTuple(hv_Value1[4]), "true",
|
||||
"constant");
|
||||
//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])<HTuple(hv_Value[1]))))
|
||||
{
|
||||
// hv_Value1[2] = HTuple(hv_Value1[2])-(HTuple(90).TupleRad());
|
||||
// hv_Rect2Len1 = ((const HTuple&)hv_Value1)[3];
|
||||
// hv_Rect2Len2 = ((const HTuple&)hv_Value1)[4];
|
||||
// hv_Value1[3] = hv_Rect2Len2;
|
||||
// hv_Value1[4] = hv_Rect2Len1;
|
||||
// }
|
||||
// CropRectangle2(ho_in_Image, &ho_ImagePart, HTuple(hv_Value1[0]), HTuple(hv_Value1[1]),
|
||||
// HTuple(hv_Value1[2]), HTuple(hv_Value1[3]), HTuple(hv_Value1[4]), "true",
|
||||
// "constant");
|
||||
ho_ImagePart = ho_in_Image;
|
||||
GetImageSize(ho_ImagePart, &hv_ImgaeWidth, &hv_ImgaeHeight);
|
||||
|
||||
GenGridRegion(&ho_RegionGrid, hv_ImgaeHeight.TupleReal(), (hv_ImgaeWidth.TupleReal())/8,
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user