Qt与halcon联合开发实现基于形状的模板匹配
程序员文章站
2024-03-25 10:49:46
...
基于形状的模板匹配,也称为基于边缘方向梯度的匹配,是一种最常用也最前沿的模板匹配算法。该算法以物体边缘的梯度相关性作为匹配标准。
if(HDevWindowStack::IsOpen())//调用halcon静态类
{
HDevWindowStack::Pop();
ClearWindow(m_hvWindowHandle);
CloseWindow(m_hvWindowHandle);
}
GetImageSize(pImageVar->m_image.m_himage,&hv_Width,&hv_Height);
OpenWindow(0,0,ui->lb_Show->width(),double(hv_Height)/double(hv_Width)*ui->lb_Show->width(),Hlong(ui->lb_Show->winId()),"","",&m_hvWindowHandle);
SetPart(m_hvWindowHandle,0,0,hv_Height,hv_Width);
HDevWindowStack::Push(m_hvWindowHandle);
if (HDevWindowStack::IsOpen())
DispObj(pImageVar->m_image.m_himage,HDevWindowStack::GetActive());
HTuple RowBegin,ColBegin,RowEnd,ColEnd;
DrawRectangle1(m_hvWindowHandle,&RowBegin,&ColBegin,&RowEnd,&ColEnd);
HImage ho_Rectangle1;
GenRectangle1(&ho_Rectangle1,RowBegin,ColBegin,RowEnd,ColEnd);
HImage ho_ReduceImage;
ReduceDomain(pImageVar->m_image.m_himage,ho_Rectangle1,&ho_ReduceImage);
CreateShapeModel(ho_ReduceImage, 5, HTuple(0).TupleRad(), HTuple(360).TupleRad(),
HTuple(0.4735).TupleRad(), (HTuple("none").Append("no_pregeneration")), "use_polarity",((HTuple(10).Append(11)).Append(9)), 4, &m_hvModelID);
Image ho_ModelContours;
GetShapeModelContours(&ho_ModelContours, m_hvModelID, 1);
HTuple hv_ModelRegionArea,hv_RefRow,hv_RefColumn;
AreaCenter(ho_Rectangle1, &hv_ModelRegionArea, &hv_RefRow, &hv_RefColumn);
HTuple hv_HomMat2D;
VectorAngleToRigid(0, 0, 0, hv_RefRow, hv_RefColumn, 0, &hv_HomMat2D);
HImage ho_TransContours;
AffineTransContourXld(ho_ModelContours, &ho_TransContours, hv_HomMat2D);
if (HDevWindowStack::IsOpen())
DispObj(ho_TransContours,HDevWindowStack::GetActive());
上一篇: OpenCV计算机视觉入门案例
下一篇: 计算机视觉-opencv绘图