資源簡介
FitLine.cs
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?HalconDotNet;
namespace?checktest
{
????class?FitLine
????{
????????///?
????????///?找線?(多段取點擬合)
????????///?
????????///?輸入圖像
????????///?窗口句柄
????????///?中心行坐標
????????///?中心列坐標
????????///?角度
????????///?半長
????????///?半寬
????????///?取點數
????????///?對比度
????????///?平滑系數
????????///?極性
????????///?選擇邊緣點
????????///?返回直線起點行坐標
????????///?返回直線起點列坐標
????????///?返回直線終點行坐標
????????///?返回直線終點列坐標
????????///?是否顯示
????????///?
????????public?bool?Find_Line(Hobject?Image?HTuple?Window?HTuple?RoiRow?HTuple?RoiCol?HTuple?RoiPhi?HTuple?RoiLength1?HTuple?RoiLength2?HTuple?NumPoint
?????????????HTuple?AmpThreshold?HTuple?Smooth?HTuple?Transition?HTuple?Select?ref?HTuple?RowBegion?ref?HTuple?ColBegion?ref?HTuple?RowEnd?ref?HTuple?ColEnd
?????????????bool?ShowRoiFlag)
????????{
????????????try
????????????{
????????????????Hobject?Contour;
????????????????HTuple?ImageWidth?ImageHeight;
????????????????HTuple?Row_Rect?Col_Rect?DRow?DCol?MeasureLength1?MeasureLength2?HomMat2DIdentity;
????????????????HTuple?HomMat2DRotate?Index?MsrHandle?Row_Measure?Col_Measure;
????????????????HTuple?Amplitude_Measure?Distance_Measure?num;
????????????????HTuple?Nr?Nc?Dist;
????????????????HTuple?RowOut?=?new?HTuple()?ColOut?=?new?HTuple();
????????????????Listject>?RectList?=?new?Listject>();
????????????????Row_Rect?=?RoiRow?+?RoiLength2?*?RoiPhi.TupleCos();
????????????????Col_Rect?=?RoiCol?+?RoiLength2?*?RoiPhi.TupleSin();
????????????????MeasureLength1?=?RoiLength1;
????????????????MeasureLength2?=?RoiLength2?/?NumPoint?/?2;
????????????????DRow?=?-2?*?RoiLength2?*?RoiPhi.TupleCos()?/?NumPoint;
????????????????DCol?=?-2?*?RoiLength2?*?RoiPhi.TupleSin()?/?NumPoint;
????????????????HOperatorSet.HomMat2dIdentity(out?HomMat2DIdentity);
????????????????HOperatorSet.HomMat2dTranslate(HomMat2DIdentity?DRow?DCol?out?HomMat2DRotate);
????????????????HOperatorSet.GetImageSize(Image?out?ImageWidth?out?ImageHeight);
????????????????if?(ShowRoiFlag)//是否顯示
????????????????{
????????????????????Hobject?rect2;
???????????????
評論
共有 條評論