#if defined(__CHAR_UNSIGNED__) || defined(__sgi)
#define INT1 signed char /* integer, signed 1 Byte */
#define INT1_MIN SCHAR_MIN
#define INT1_MAX SCHAR_MAX
#else
#define INT1 char /* integer, signed 1 Byte */
#define INT1_MIN CHAR_MIN
#define INT1_MAX CHAR_MAX
#endif
#define UINT1 unsigned char /* integer, unsigned 1 Byte */
#define UINT1_MIN 0
#define UINT1_MAX UCHAR_MAX #define LONG_FORMAT _INT64_FORMAT
typedef INT4_8 Hlong;
typedef UINT4_8 Hulong;

  看粗体部分,可以看到 Hlong型在32位的机器上其实就是long型 代表4个字节 32位,在64位机器上有另一种定义

  再来看看halcon中最重要的数据类型HTuple,在C++里面,halcon将HTuple类型封装了类,其始祖类HRootObject,这个类相当于MFC里面的CObject,halcon从HRootObject派生了HBaseArray,当然这两个类是虚基类,有一些方法需要我HTuple自己实现,当然也有一些方法可以直接用的。这两个类在HCPPUtil里,可以看看。

  HTuple类就是从HBaseArray派生,元组基类,相当于数组,具有如下的构造函数:

  

  HTuple(int l);
HTuple(float f);
HTuple(double d);
HTuple(const char *s);
HTuple(const HCtrlVal &c);
HTuple(const HTuple &in):HBaseArray() {CopyTuple(in);}
HTuple(Hlong length, const HTuple &value);
HTuple(const HTuple &length, const HTuple &value);
HTuple(SpecialTuple d);

  

  HTuple对各种操作符进行了重载:

  operator     HCtrlVal(void) const;
HTuple operator () (Hlong min, Hlong max) const;
HTuple operator () (const HTuple &min, const HTuple &max) const;
HCtrlVal &operator [] (Hlong index);
HCtrlVal operator [] (Hlong index) const;
HCtrlVal &operator [] (const HTuple &index);
HCtrlVal operator [] (const HTuple &index) const;
HTuple &operator ++ (void); // nur fuer double und Hlong
HBool operator ! (void) const;
HTuple operator ~ (void) const;
HTuple operator << (const HTuple &val) const;
HTuple operator << (Hlong val) const;
HTuple operator >> (const HTuple &val) const;
HTuple operator >> (Hlong val) const;
HTuple operator + (const HTuple &val) const;
HTuple operator + (double val) const;
HTuple operator + (int val) const;

  在讲解halcon是如何维护这样一个HTuple中各种数据之前 ,先来看看这样一个类:

  

class LIntExport HCtrlVal  {
friend class HTuple;
public:
HCtrlVal(void) {val.type = UndefVal; val.par.l = ;}
#if !defined(_TMS320C6X)
HCtrlVal(Hlong l) {val.type = LongVal; val.par.l = l;}
#endif
HCtrlVal(int l) {val.type = LongVal; val.par.l = l;}
HCtrlVal(double d) {val.type = DoubleVal; val.par.f = d;}
HCtrlVal(const char *s);
HCtrlVal(const HCtrlVal &v) {CopyCtrlVal(v);}
~HCtrlVal(void) {ClearCtrlVal();}
HCtrlVal& operator = (const HCtrlVal &v); // Type conversion
int ValType() const {return val.type;}
operator int(void) const {return I();}
#if !defined(_TMS320C6X)
operator Hlong(void) const {return L();}
#endif
operator double(void) const {return D();}
operator const char*(void) const {return S();}
operator const Hcpar&(void)const {return HCPAR();}
// Access contents
double D() const;
Hlong L() const;
int I() const;
const char * S() const;
const Hcpar& HCPAR()const;
// Arithmetics
HCtrlVal operator + (const HCtrlVal &val) const;
HTuple operator + (const HTuple &val) const;
HCtrlVal operator - (const HCtrlVal &val) const;
HTuple operator - (const HTuple &val) const;
HCtrlVal operator * (const HCtrlVal &val) const;
HTuple operator * (const HTuple &val) const;
HCtrlVal operator / (const HCtrlVal &val) const;
HTuple operator / (const HTuple &val) const;
HCtrlVal operator % (const HCtrlVal &val) const;
HTuple operator % (const HTuple &val) const;
HBool operator != (const HCtrlVal &val) const;
HBool operator != (const HTuple &val) const;
HBool operator == (const HCtrlVal &val) const;
HBool operator == (const HTuple &val) const;
HBool operator >= (const HCtrlVal &val) const;
HBool operator >= (const HTuple &val) const;
HBool operator <= (const HCtrlVal &val) const;
HBool operator <= (const HTuple &val) const;
HBool operator > (const HCtrlVal &val) const;
HBool operator > (const HTuple &val) const;
HBool operator < (const HCtrlVal &val) const;
HBool operator < (const HTuple &val) const; const char *ClassName(void) const { return "HCtrlVal"; }
int Version(void) const;
int Revision(void) const;
const char *Creation(void) const; private:
// Data
Hcpar val; // Value: one of the three types and type specifyer
// Support operationen
void ClearCtrlVal();
void CopyCtrlVal(const HCtrlVal& source);
};
typedef struct
{
Hpar par; /* values */
INT1 type; /* type flag */
} Hcpar; /* parameter passing for the C interface */
typedef union
{
INT4_8 l; /* 4/8 byte integer (input) */
double f; /* 8 byte real (input) */
char *s; /* pointer to strings (input) */
} Hpar; /* parameter passing for the C interface */
typedef union
{
INT4_8 *l; /* 4/8 byte integer (output) */
double *f; /* 8 byte real (output) */
char *s; /* pointer to strings (output) */
VOIDP p; /* pointer to var. of any type (e.g. tuple)(output)*/
} Hvar; /* parameter passing for the C interface */

  仔细看我用红色粗体并加大的部分,这四段代码可以说是halcon维护HTuple这种数据类型的精髓了。下面我们来讲解一下:

  首先HTuple类中有私有成员变量:

private:
HCtrlVal *tuple; // values (array of Hlong/float/string)

  halcon给的注释写的很清楚,tuple是一群值,指向一个数组,数组里面有long型,浮点型及字符串型数据。这是一个指针,这个类就是维护这样一个指针,具体此指针的内容,我们往下看HCtrlVal: (这里说一下这几个单词的意义吧:H->Halcon   Ctrl->Control   Val->Values  表示Halcon的控制变量,当然还有图形变量,以后再讲吧。)

private:
// Data
Hcpar val; // Value: one of the three types and type specifyer

  HCtrlVal类就维护了这样一个成员变量,halcon给的注释是说 val 代表数据的三种类型中的一个,并指向一个值。那么HTuple中的tuple指针就是维护了val组成的链表,这样HTuple就可以维护多种不同类型的数据。

  HTuple用起来的确很方便,halcon对其进行了大量的运算符重载包括像强制类型转换,都不需要我们手动去做,只需要在前面加个数据类型就行了。

  好了,由于本人水平有限,文中可能会有纰漏,敬请指出!

  added by xiejl

halcon基础数据类型详解的更多相关文章

  1. Java基础数据类型详解

    在Java中的数据类型一共有8种,大致分为整型(4个)浮点型(2个)布尔(1)字符(1个) 分类 类型 默认值 占用字节 范围 整型 byte 0 1 = 8 bit -2^7 - 2^7 short ...

  2. Python基础之数据类型详解(2)

    今天继续昨天的python基本数据类型详解,按照上一篇博文的格式,接下来讲解列表.元组.字典以及集合. 列表 1.用途按位置存放多个值2.定义在[]内用逗号分割开多个任意类型的元素 # 定义列表 # ...

  3. ClickHouse(05)ClickHouse数据类型详解

    ClickHouse属于分析型数据库,ClickHouse提供了许多数据类型,它们可以划分为基础类型.复合类型和特殊类型.其中基础类型使ClickHouse具备了描述数据的基本能力,而另外两种类型则使 ...

  4. MySQL 数据类型 详解

    MySQL 数据类型 详解 MySQL 的数值数据类型可以大致划分为两个类别,一个是整数,另一个是浮点数或小数.许多不同的子类型对这些类别中的每一个都是可用的,每个子类型支持不同大小的数据,并且 My ...

  5. I2C 基础原理详解

    今天来学习下I2C通信~ I2C(Inter-Intergrated Circuit)指的是 IC(Intergrated Circuit)之间的(Inter) 通信方式.如上图所以有很多的周边设备都 ...

  6. oracle 数据类型详解---日期型(转载)

    oracle 数据类型详解---日期型 oracle数据类型看起来非常简单,但用起来会发现有许多知识点,本文是我对ORACLE日期数据类型的一些整理,都是开发入门资料,与大家分享: 注:由于INTER ...

  7. python 3.x 爬虫基础---Urllib详解

    python 3.x 爬虫基础 python 3.x 爬虫基础---http headers详解 python 3.x 爬虫基础---Urllib详解 前言 爬虫也了解了一段时间了希望在半个月的时间内 ...

  8. python之数据类型详解

    python之数据类型详解 二.列表list  (可以存储多个值)(列表内数字不需要加引号) sort s1=[','!'] # s1.sort() # print(s1) -->['!', ' ...

  9. RabbitMQ基础知识详解

    什么是MQ? MQ全称为Message Queue, 消息队列(MQ)是一种应用程序对应用程序的通信方法.MQ是消费-生产者模型的一个典型的代表,一端往消息队列中不断写入消息,而另一端则可以读取队列中 ...

随机推荐

  1. JavaScript form提交汉字乱码

    <script type="text/javascript"> var test1="http://www.w3school.com.cn/My first/ ...

  2. 会话技术——Cookies和Session详解

    会话技术 (一) 概述.用途以及分类 (1) 基本概述 概述:会话是浏览器和服务器之间的多次请求和响应 也就是说,从浏览器访问服务器开始,到访问服务器结束,浏览器关闭为止的这段时间内容产生的多次请求和 ...

  3. JAVA支持字符编码读取文件

    文件操作,在java中很常用,对于存在特定编码的文件,则需要根据字符编码进行读取,要不容易出现乱码 /** * 读取文件 * @param filePath 文件路径 */ public static ...

  4. C 统计用户输入的总行数和字符长度

    C 统计用户输入的总行数和字符长度 #include <stdio.h> #include <Windows.h> int main(void) { ]; ; ; printf ...

  5. WUSTOJ 1889: 编辑距离(Java)

    转自:

  6. 时间格式_java

    @Test public void testDate(){ Date date=new Date(); System.out.println(date); /*日期格式*/ DateFormat df ...

  7. linux重启php服务

  8. Django rest-framework框架-组件之路由

    路由: a. url(r'^(?P<version>[v1|v2]+)/v1/$',views.ViewView.as_view()) url(r'^(?P<version>[ ...

  9. VBA教程(一)

    VBA代表Visual Basic for Applications,它是一个来自Microsoft的事件驱动的编程语言. 现在它主要用于Microsoft Office应用程序,如MSExcel,M ...

  10. es6中Array.from()

    Array.from()方法就是将一个类数组对象或者可遍历对象转换成一个真正的数组. 那么什么是类数组对象呢?所谓类数组对象,最基本的要求就是具有length属性的对象. 1.将类数组对象转换为真正数 ...