private void updatePoiMatrix(Position pcbPoi,Position poi1, Position poi2,Position takePhotoPoi)
{
//更新對應的陣列
imagePoiList.Add(new Position() { X = (poi1.X + poi2.X) / 2, Y = (poi1.Y + poi2.Y) / 2 });
System.Windows.Point p1=new System.Windows.Point();
p1.X = pcbPoi.X - takePhotoPoi.X;
p1.Y = pcbPoi.Y - takePhotoPoi.Y;
Position newDstPoi = new Position();
newDstPoi.X = p1.X;
newDstPoi.Y = p1.Y;
robotPoiList.Add(newDstPoi);
}
private void btnSaveCalibration_Click(object sender, EventArgs e)
{
try
{
NcHelper.GetInstance().SaveMat(imagePoiList, robotPoiList, this.matPath);
}
catch (Exception ex)
{
this.printException(ex);
}
}
public void SaveMat(List<Position> imageList, List<Position> robotPoiList, string path)
{
HTuple imageXList = new HTuple(), imageYList = new HTuple();
HTuple robotXList = new HTuple(), robotYList = new HTuple();
for (int i = 0; i < imageList.Count; i++)
{
imageXList[i] = imageList[i].X;
imageYList[i] = imageList[i].Y;
robotXList[i] = robotPoiList[i].X;
robotYList[i] = robotPoiList[i].Y;
}
HTuple hv_HomMat2D = new HTuple(), hv_SerializedItemHandle = new HTuple();
HTuple hv_FileHandle = new HTuple();
////標定
hv_HomMat2D.Dispose();
HOperatorSet.VectorToHomMat2d(imageXList, imageYList, robotXList, robotYList, out hv_HomMat2D);
//儲存變換矩陣
hv_SerializedItemHandle.Dispose();
HOperatorSet.SerializeHomMat2d(hv_HomMat2D, out hv_SerializedItemHandle);
hv_FileHandle.Dispose();
HOperatorSet.OpenFile(path, "output_binary", out hv_FileHandle);
HOperatorSet.FwriteSerializedItem(hv_FileHandle, hv_SerializedItemHandle);
HOperatorSet.CloseFile(hv_FileHandle);
imageXList.Dispose();
imageYList.Dispose();
robotXList.Dispose();
robotYList.Dispose();
hv_HomMat2D.Dispose();
hv_SerializedItemHandle.Dispose();
hv_FileHandle.Dispose();
}
作者:Bonker 出處:http://www.cnblogs.com/Bonker QQ:519841366 |