以下是Halcon基本用法,
不過 HTuple *ROWW;
HTuple A[2];
A[0]=3;
A[1]=4;
因為//gen_contour_polygon_xld(Halcon::Hobject *Contour, const Halcon::HTuple &Row, const Halcon::HTuple &Col);
要寫成: gen_contour_polygon_xld (EdgeFirst, [-sin(Angle+rad(90))*Length2+RowEdgeFirst[i], -sin(Angle-rad(90))*Length2+RowEdgeFirst[i]], [cos(Angle+rad(90))*Length2+ColumnEdgeFirst[i], cos(Angle-rad(90))*Length2+ColumnEdgeFirst[i]])
走到此很容易發現HTuple=[HTuple,HTuple]這種類似Matlab的幼兒園寫法在c++上是行不通滴,因此我還需要
把HTuple 轉成double,再與double運算完後丟回 HTuple,並且用指標方式的寫,
這段我還沒寫好,基本上就是看著Halcon spec搭配Halcon hdev並且觀看Halcon在vc的lib編寫出來的,
Hobject image,ImageMean,DarkPixel,ConnecttionRegions,SelectionRegions,EdgeFirst,ROI;
read_image(&image,"fuse.png");
double Row=350;
double Column=580;
double Angle=0.5*PI;
double Length1=120;
double Length2=20;
HTuple RowEdgeFirst,ColumnEdgeFirst,Amp,ROW_edge,ColunEdge,AMP_SECOND,IntraDIS,INETR_DIS;
int Row_edge_int;
Hlong width,height,MeasureHandle;
get_image_size(image, &width, &height);//获取图像宽、高
gen_rectangle2(&ROI,Row,Column,Angle,Length1,Length2);
//(double Row, double Column, double Phi, double Length1, double Length2, Hlong Width, Hlong Height, const char *Interpolation, Hlong *MeasureHandle);
gen_measure_rectangle2(Row,Column,Angle,Length1,Length2,width,height,"bilinear",&MeasureHandle);
measure_pairs(image,MeasureHandle,1,1,"negative","all",&RowEdgeFirst,&ColumnEdgeFirst,&Amp,&ROW_edge,&ColunEdge,&_SECOND,&IntraDIS,&INETR_DIS);
Row_edge_int=ROW_edge[0].I();
Row_edge_int=abs(Row_edge_int);
//
int w = width[0].I();//HTuple类型
//
CRect rtWindow1;
HTuple Window_HANDLE;
GetDlgItem(IDC_DISPIMAGE)->GetClientRect(&rtWindow1);
HWND hlmgWnd=GetDlgItem(IDC_DISPIMAGE)->m_hWnd;
open_window(rtWindow1.left,rtWindow1.top,rtWindow1.Width(),rtWindow1.Height(),(Hlong)hlmgWnd,"visible","",&Window_HANDLE);
set_color(Window_HANDLE,"blue");
disp_obj(image,Window_HANDLE);
disp_obj(ROI,Window_HANDLE);
for(int i=0;i
{
HTuple *ROWW;
HTuple A[2];
A[0]=3;
A[1]=4;
ROWW=&A[0];
//
ROWW[0]=RowEdgeFirst[i];
//
ROWW[1]=RowEdgeFirst[i];
HTuple COLL=ColumnEdgeFirst[i];
//gen_contour_polygon_xld(Halcon::Hobject *Contour, const Halcon::HTuple &Row, const Halcon::HTuple &Col);
gen_contour_polygon_xld (&EdgeFirst,*ROWW,*ROWW);
//cos(Angle+(90))*Length2+COLL, cos(Angle-(90))*Length2+COLL);
//gen_contour_polygon_xld(&EdgeFirst,0,0,0,0);
disp_obj(EdgeFirst,Window_HANDLE);
}