Halcon C# 数据类型转换

63 篇文章 6 订阅

HObject ==> HImage

  // 灰度图片
  public static void HObjectToHImage(HObject hObject, ref HImage image)
  {
      HTuple pointer, type, width, height;
      HOperatorSet.GetImagePointer1(hObject, out pointer, out type, out width, out height);
      image.GenImage1(type, width, height, pointer);
  }


  // 彩色图片
  public static void HObjectToRGBHImage(HObject hobject, ref HImage image)
  {
      HTuple pointerRed, pointerGreen, pointerBlue, type, width, height;
      HOperatorSet.GetImagePointer3(hobject, out pointerRed, out pointerGreen, out pointerBlue, out type, out width, out height);
      image.GenImage3(type, width, height, pointerRed, pointerGreen, pointerBlue);
  }

HObject ==> HRegion

HRegion hRegion = new HRegion(ho_ResultAllRegion);

HImage/ HRegion ==> HObject

因为HObject是父类,所以一般不需要类型转换,可以直接替换

HTuple ==> int、double 等

int ErrorCode = hv_ErroCode.I;   // HTuple ==> int
string message = hv_Message.S; // HTuple ==> string
        //
        // 摘要:
        //     Convenience accessor for tuple[0].S
        public string S { get; set; }
        //
        // 摘要:
        //     Convenience accessor for tuple[0].D
        public double D { get; set; }
        //
        // 摘要:
        //     Convenience accessor for tuple[0].L
        public long L { get; set; }
        //
        // 摘要:
        //     Convenience accessor for tuple[0].I
        public int I { get; set; }
        //
        // 摘要:
        //     Exposes the internal array representation to allow most efficient (but not safest)
        //     access. Tuple type must be HTupleType.MIXED. It is not recommended to modify
        //     the array. If you do make sure to only store supported element types int, long,
        //     double, string and HHandle. The array length may be greater than the used tuple
        //     length.
        [EditorBrowsable(EditorBrowsableState.Never)]
        public object[] OArr { get; }
        //
        // 摘要:
        //     Exposes the internal array representation to allow most efficient (but not safest)
        //     access. Tuple type must be HTupleType.STRING. The array length may be greater
        //     than the used tuple length.
        public string[] SArr { get; set; }
        //
        // 摘要:
        //     Convenience accessor for tuple[0].H
        public object O { get; set; }
        //
        // 摘要:
        //     Exposes the internal array representation to allow most efficient (but not safest)
        //     access. Tuple type must be HTupleType.DOUBLE. The array length may be greater
        //     than the used tuple length.
        public double[] DArr { get; set; }
        //
        // 摘要:
        //     Exposes the internal array representation to allow most efficient (but not safest)
        //     access. Tuple type must be HTupleType.LONG. The array length may be greater than
        //     the used tuple length.
        public long[] LArr { get; set; }
        //
        // 摘要:
        //     Exposes the internal array representation to allow most efficient (but not safest)
        //     access. Tuple type must be HTupleType.INTEGER. The array length may be greater
        //     than the used tuple length.
        public int[] IArr { get; set; }
  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

廷益--飞鸟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值