halcon 区域Region(HObject)的传输

GetRegionRuns


获取:游程编码,行号、起始列、行列。
private void butTemp_Click(object sender, EventArgs e)
        {
            HObject region;
            HOperatorSet.GenRectangle1(out region, 1, 1, 2, 2);
            HTuple tRows, tCols;
            HOperatorSet.GetRegionPoints(region, out tRows, out tCols);
            //region有4个点(1,1),(1,2),(2,1),(2,2)
            HTuple row, col1, col2;
            HOperatorSet.GetRegionRuns(region, out row, out col1, out col2);
            //region有4个点的行长码: 1行1列到2列 2行1列到2列

            //修改行长码
            row = new int[] { 5, 6 };
            HObject region1;
            HOperatorSet.GenRegionRuns(out region1, row, col1, col2);                
            HOperatorSet.GetRegionPoints(region1, out tRows, out tCols);
            //region有4个点(5,1),(5,2),(6,1),(6,2)
        }


扩展

也可使用GenRegionPoints

WriteRegion


 HOperatorSet.WriteRegion(region1, "c:\\1.reg");
            byte[] bys = System.IO.File.ReadAllBytes("c:\\1.reg");
存储文件,以二进制的方式读取,存储格式就是游程编码。末尾是行号 起始列号 结束列号。

测试环境

Win7 VS2022 halcon12

你可能感兴趣的:(#,OpenCV,halcon12,传输,区域,Region,机器视觉,HObject,游程编码)