Compare commits

...

3 Commits

@ -40,17 +40,6 @@
using namespace std;
using namespace cv;
// ============================ Pin 检测方案开关 ============================
// 1 = 新方案(Pin 直接分析, 不做模板对比): 不做仿射变换, 检测图直接按当前外定位结果裁剪;
// 只分析检测Pin: 自动区分两排Pin(考虑图像旋转)并逐排拟合直线,
// 到直线(法线方向)距离超过 pin_y_offset 的判 偏移;
// 相邻两Pin中心连线距离超过 pin_x_offset 的判 两Pin中间缺失一个Pin。
// 0 = 旧方案(模板对比/内定位仿射): 以内定位(无效时回退外定位)仿射变换到模板坐标系后与模板Pin对比。
// 说明: 可通过编译参数 -DPIN_USE_DIRECT_MATCH=0/1 覆盖此处默认值。
#ifndef PIN_USE_DIRECT_MATCH
#define PIN_USE_DIRECT_MATCH 0
#endif
enum AT_THRESHOLD_TYPE_
{
AT_THRESHOLD_TYPE_NULL,
@ -207,10 +196,20 @@ private:
// 边缘缺陷检测
int Pin_Qx_Det(const cv::Mat &img);
#if PIN_USE_DIRECT_MATCH
// 当前 Pin 检测方案是否为"直接分析"(参数 pinDet.Det_Method == "line_fitting")
bool IsDirectPinMethod() const;
// 当前 Pin 检测方案是否为"Pin 投影矩阵"(参数 pinDet.Det_Method == "Pin_Matrix")
bool IsPinMatrixMethod() const;
// 新方案: 不做模板对比, 只分析检测Pin: 自动分两排(考虑旋转) -> 拟合直线判偏移 + 相邻间距判缺失
int Pin_Direct_Check();
#endif
// Pin_Matrix 方案: 用当前帧 Pin 拟合投影矩阵(上下两排分别计算相似变换), 把模板 Pin 投影到当前检测图坐标系
int ComputePinProjectionMats();
// Pin_Matrix 方案: 过滤当前帧上明显的误检 pin blob(按模板 pin 的包围盒尺寸)
int FilterCurPinBlobsByTplSize();
// 把blob 汇总成 检测结果。
int BLobToDetResult();

File diff suppressed because it is too large Load Diff

@ -1247,6 +1247,10 @@ struct Base_Function_Pin_Det
bool bOpen; // 是否开启
float pin_x_offset; // pin x 偏移
float pin_y_offset; // pin y 偏移
// "line_fitting" = 新方案(直接分析检测Pin: 分两排拟合直线判偏移 + 相邻间距判缺失, 不做模板对比)
// "BTB_Marix" = 旧方案(内定位仿射 + 模板Pin对比)
// "Pin_Matrix" = 模板Pin对比方案, 投影矩阵由 Pin 自身拟合(上下两排分别计算, 不做二次偏移矫正)
std::string Det_Method; // pin 检测方案
bool bDrawResult; // 是否绘制结果
Base_Function_Pin_Det()
@ -1258,6 +1262,7 @@ struct Base_Function_Pin_Det
bOpen = false;
pin_x_offset = 0;
pin_y_offset = 0;
Det_Method = "BTB_Marix";
bDrawResult = false;
}
@ -1266,18 +1271,19 @@ struct Base_Function_Pin_Det
this->bOpen = tem.bOpen;
this->pin_x_offset = tem.pin_x_offset;
this->pin_y_offset = tem.pin_y_offset;
this->Det_Method = tem.Det_Method;
this->bDrawResult = tem.bDrawResult;
}
void print(std::string str)
{
printf("%s>>bOpen %d pin_x_offset %f pin_y_offset %f bDrawResult %d\n", str.c_str(),
bOpen, pin_x_offset, pin_y_offset, bDrawResult);
printf("%s>>bOpen %d pin_x_offset %f pin_y_offset %f Det_Method %s bDrawResult %d\n", str.c_str(),
bOpen, pin_x_offset, pin_y_offset, Det_Method.c_str(), bDrawResult);
}
std::string GetInfo(std::string str)
{
char buffer[256];
sprintf(buffer, "%s>>bOpen %d pin_x_offset %f pin_y_offset %f bDrawResult %d\n", str.c_str(),
bOpen, pin_x_offset, pin_y_offset, bDrawResult);
sprintf(buffer, "%s>>bOpen %d pin_x_offset %f pin_y_offset %f Det_Method %s bDrawResult %d\n", str.c_str(),
bOpen, pin_x_offset, pin_y_offset, Det_Method.c_str(), bDrawResult);
std::string str123 = buffer;
return str123;
}

@ -822,6 +822,10 @@ int BaseFuntonConfigJson::GetFunction(Json::Value value)
if (_config.pinDet.bOpen)
{
if (value_f["form"]["Det_Config"]["Det_Method"])
{
_config.pinDet.Det_Method = value_f["form"]["Det_Config"]["Det_Method"].asString();
}
if (value_f["form"]["Det_Config"]["pin_x_offset"])
{
_config.pinDet.pin_x_offset = value_f["form"]["Det_Config"]["pin_x_offset"].asFloat();

Loading…
Cancel
Save