DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: teacherlau
今日帖子: 63
在线用户: 21
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 denis (Denis) ★☆☆☆☆ -
盒子活跃会员
2023/5/31 10:46:44
标题:
delphi调用c语言dll问题 浏览:1417
加入我的收藏
楼主: 最近在学机器视觉halcon, 可惜不知从哪个版本开始不再支持delphi了,实际上就是调用c语言的dll,大d应该是能调用的,试着参考c语言的例程改写成pascal, 碰到了几个问题,编译能过,运行时出错,请大D高手看看是哪里转换不对,出错的是下面2个函数:
T_disp_obj(ho_GrayImage, active_win);
Open_Window(0, 0, hv_imageWidth, hv_imageHeight, pnl1.Handle, 'visible', '', @hv_WinHd);
附件是改写的d源码和C程序源码及h头件,C程序运行是正确的
所需的dll因为有点大,附上网盘下载地址,方便测试。
链接:https://pan.baidu.com/s/1U_YGzxPskRhSWZTZYFqXyw?pwd=0531 
提取码:0531
此帖子包含附件:denis_2023531104644.zip 大小:655.9K
----------------------------------------------
-
作者:
男 denis (Denis) ★☆☆☆☆ -
盒子活跃会员
2023/5/31 10:58:32
1楼: 为了方便看贴,贴上关键的代码

delphi

procedure TForm1.action2;
var
  ho_Image_display, ho_GrayImage : HObject;

  hv_imageWidth, hv_imageHeight, hv_WinHd: HLong;
begin
  Gen_Empty_Obj(@ho_Image_display);
  Gen_Empty_Obj(@ho_GrayImage);

  //关闭当前显示窗口,清空屏幕
  if (window_stack_is_open() = 1) then
  begin
    hv_WinHd := window_stack_pop();
    close_window(hv_WinHd);
  end;
  //读取测试图像
  Read_Image(@ho_Image_display, 'shapes.jpg');
  //将图像转化为灰度图像
  Rgb1_To_Gray(ho_Image_display, @ho_GrayImage);
  //获取图像的尺寸
  hv_imageWidth := 0; hv_imageHeight := 0;
  Get_Image_Size(ho_Image_display, @hv_imageWidth, @hv_imageHeight);
  //新建显示窗口,适应图像尺寸
  Set_Window_Attr('background_color', 'black');  // "black");
  hv_WinHd := 0;
  Open_Window(0, 0, hv_imageWidth, hv_imageHeight, pnl1.Handle, 'visible', '', @hv_WinHd);
  Window_Stack_Push(hv_WinHd);
  if (window_stack_is_open() = 1) then
  begin
    hv_WinHd := Window_Stack_Get_Active();
    Disp_Obj(ho_GrayImage, hv_WinHd);
  end;

  clear_obj(ho_Image_display);
  clear_obj(ho_GrayImage);
end;

Open_Window(0, 0, hv_imageWidth, hv_imageHeight, pnl1.Handle, 'visible', '', @hv_WinHd);
这一行出错: 
HALCON error #7002: Wrong type: output control parameter(see:HPut*Par) in operator open_window
----------------------------------------------
-
作者:
男 denis (Denis) ★☆☆☆☆ -
盒子活跃会员
2023/5/31 11:00:03
2楼: C语言H头文件转换成delphi文件:

unit HalconCLib;

{$MINENUMSIZE 4}

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes;

const
  HalconDll = 'halconc.dll';

type
  PPUTF8Char = ^PUTF8Char;
  {$IF Defined(WIN64)}
  INT4_8 = Int64;
  {$ELSE}
  INT4_8 = Long;
  {$ENDIF}
  PINT4_8 = ^INT4_8;
  Hlong = Int64;
  PHlong = ^Hlong;
  Hkey = PInt64;  //PInteger;
  Hobject = Hkey;
  Herror = UInt32;
  PHobject = ^Hobject;
  Hphandle = UInt64;  //Pointer;
  PHphandle = ^Hphandle;
  Hvector = Hlong;
  PHvector = ^Hvector;

  Hpar = record
    case i: Integer of
      0: (l: INT4_8);
      1: (d: Double);
      2: (s: PUTF8Char);
      3: (f: Double);
      4: (h: Hphandle);
  end;
  Hcpar = record
    par: Hpar;
    _type: Integer;
  end;
  PHcpar = ^Hcpar;
  Hcelem = record
    case i: Integer of
      0: (l: PINT4_8);
      1: (d: PDouble);
      2: (s: PPUTF8Char);
      3: (cpar: PHcpar);
      4: (h: PHphandle);
  end;
  Htuple = record
    val: Hpar;
    _type: Integer;
    pad: array [0..3] of UTF8Char;
    num: INT4_8;
    capacity: INT4_8;
    free: Integer;
    elem: Hcelem;
  end;
  PHtuple = ^Htuple;
  PHCTUPLE = ^Htuple;

  Hvectype = (
    eVector = 99352576,
    eTupleVector = 99352577,
    eTupleLeaf = 99352578,
    eObjectVector = 99352579,
    eObjectLeaf = 99352580);
  PHvectype = ^Hvectype;

  Hproc_handle = Pointer;
  PHproc_handle = ^Hproc_handle;

procedure SetHcInterfaceStringEncodingIsUtf8(is_utf8: Integer); cdecl;
  external HalconDll name 'SetHcInterfaceStringEncodingIsUtf8';

function hdev_window_stack_is_open(): Integer; cdecl;
  external HalconDll name 'hdev_window_stack_is_open';

procedure hdev_window_stack_pop(win_handle: PHtuple); cdecl;
  external HalconDll name 'hdev_window_stack_pop';

procedure hdev_window_stack_push(const win_handle: Htuple); cdecl;
  external HalconDll name 'hdev_window_stack_push';

procedure hdev_window_stack_get_active(win_handle: PHtuple); cdecl;
  external HalconDll name 'hdev_window_stack_get_active';

function gen_empty_obj(EmptyObject: PHobject): Herror; cdecl;
  external HalconDll name 'gen_empty_obj';

function clear_obj(const Objects: Hobject): Herror; cdecl;
  external HalconDll name 'clear_obj';

function read_image(Image: PHobject; const FileName: PUTF8Char): Herror; cdecl;
  external HalconDll name 'read_image';

function rgb1_to_gray(const RGBImage: Hobject; GrayImage: PHobject): Herror; cdecl;
  external HalconDll name 'rgb1_to_gray';

function T_get_image_size(const Image: Hobject; Width: PHtuple; Height: PHtuple): Herror; cdecl;
  external HalconDll name 'T_get_image_size';

function get_image_size(const Image: Hobject; Width: PHlong; Height: PHlong): Herror; cdecl;
  external HalconDll name 'get_image_size';

function T_close_window(const WindowHandle: Htuple): Herror; cdecl;
  external HalconDll name 'T_close_window';

function close_window(WindowHandle: Hlong): Herror; cdecl;
  external HalconDll name 'close_window';

function T_set_window_attr(const AttributeName: Htuple; const AttributeValue: Htuple): Herror; cdecl;
  external HalconDll name 'T_set_window_attr';

function T_set_system(const SystemParameter: Htuple; const Value: Htuple): Herror; cdecl;
  external HalconDll name 'T_set_system';

function set_system(const SystemParameter: PUTF8Char; const Value: PUTF8Char): Herror; cdecl;
  external HalconDll name 'set_system';

function T_open_window(const Row: Htuple; const Column: Htuple; const Width: Htuple; const Height: Htuple; const FatherWindow: Htuple; const Mode: Htuple; const Machine: Htuple; WindowHandle: PHtuple): Herror; cdecl;
  external HalconDll name 'T_open_window';

function open_window(Row: Hlong; Column: Hlong; Width: Hlong; Height: Hlong; FatherWindow: Hlong; const Mode: PUTF8Char; const Machine: PUTF8Char; WindowHandle: PHlong): Herror; cdecl;
  external HalconDll name 'open_window';

function T_disp_obj(const HObject: Hobject; const WindowHandle: Htuple): Herror; cdecl;
  external HalconDll name 'T_disp_obj';

function disp_obj(const HObject: Hobject; WindowHandle: Hlong): Herror; cdecl;
  external HalconDll name 'disp_obj';

function window_stack_is_open(): Integer; cdecl;
  external HalconDll name 'window_stack_is_open';

function window_stack_pop(): Hlong; cdecl;
  external HalconDll name 'window_stack_pop';

function window_stack_get_active(): Hlong; cdecl;
  external HalconDll name 'window_stack_get_active';

procedure window_stack_push(win_handle: Hlong); cdecl;
  external HalconDll name 'window_stack_push';

function set_window_attr(const AttributeName: PUTF8Char; const AttributeValue: PUTF8Char): Herror; cdecl;
  external HalconDll name 'set_window_attr';

procedure Mcreate_tuple(t: PHtuple; l: Hlong; const &file : PUTF8Char; line: Integer); cdecl;
  external HalconDll name 'Mcreate_tuple';

procedure Mdestroy_tuple(t: PHtuple; const &file : PUTF8Char; line: Integer); cdecl;
  external HalconDll name 'Mdestroy_tuple';

procedure Mcreate_tuple_s(t: PHtuple; const value: PUTF8Char; const &file : PUTF8Char; line: Integer); cdecl;
  external HalconDll name 'Mcreate_tuple_s';

procedure Mcreate_tuple_i(t: PHtuple; value: Hlong; const &file : PUTF8Char; line: Integer); cdecl;
  external HalconDll name 'Mcreate_tuple_i';

procedure Mset_i(t: PHtuple; v: Hlong; i: Hlong; const &file : PUTF8Char; line: Integer); cdecl;
  external HalconDll name 'Mset_i';

procedure Mset_s(t: PHtuple; const v: PUTF8Char; i: Hlong; const &file : PUTF8Char; line: Integer); cdecl;
  external HalconDll name 'Mset_s';

procedure create_tuple(htuple: PHtuple; l: Hlong);
procedure destroy_tuple(htuple: Htuple);
procedure create_tuple_s(t: PHtuple; const val: PUTF8Char);
procedure create_tuple_i(t: PHtuple; val: Hlong);
procedure set_i(t: Htuple; value: Hlong; idx: Hlong);
procedure set_s(t: Htuple; const val: PUTF8Char; idx: Hlong);

implementation

procedure create_tuple(htuple: PHtuple; l: Hlong);
begin
  Mcreate_tuple(htuple, l, '', 0);
end;

procedure destroy_tuple(htuple: Htuple);
begin
  Mdestroy_tuple(@htuple, '', 0);
end;

procedure create_tuple_s(t: PHtuple; const val: PUTF8Char);
begin
  Mcreate_tuple_s(t, val, '', 0);
end;

procedure create_tuple_i(t: PHtuple; val: Hlong);
begin
  Mcreate_tuple_i(t, val, '', 0);
end;

procedure set_i(t: Htuple; value: Hlong; idx: Hlong);
begin
  Mset_i(@t, value, idx, '', 0);
end;

procedure set_s(t: Htuple; const val: PUTF8Char; idx: Hlong);
begin
  Mset_s(@t, val, idx, '', 0);
end;

end.
----------------------------------------------
-
作者:
男 denis (Denis) ★☆☆☆☆ -
盒子活跃会员
2023/5/31 11:01:15
3楼: c语言例子:

#  include "HalconC.h"
#  include "halconc/Hdevthread.h"

#include <stdio.h>
#include <stdlib.h>

/* Main procedure */
void action()
{
  /* Stack for temporary tuples */
  Htuple   TTemp0, TTemp1, TTemp2, TTemp3, TTemp4;

  /* Local iconic variables */
  Hobject  ho_Image_display, ho_GrayImage;

  /* Local control variables */
  Htuple  hv_imageWidth, hv_imageHeight, hv_WindowHandle1;  

  /* Initialize iconic variables */
  gen_empty_obj(&ho_Image_display);
  gen_empty_obj(&ho_GrayImage);
  
  /* Initialize control variables */
  create_tuple(&hv_imageWidth,0);
  create_tuple(&hv_imageHeight,0);
  create_tuple(&hv_WindowHandle1,0);
  
  /**********/
  /**********   Begin procedure   **********/
  /**********/

  /*关闭当前显示窗口,清空屏幕*/
  if (hdev_window_stack_is_open())
  {
    Htuple active_win;
    create_tuple(&active_win,0);
    hdev_window_stack_pop(&active_win);
    T_close_window(active_win);
    destroy_tuple(active_win);
  }
  /*读取测试图像*/
  /*read_image (Image_display, 'd:/display.jpg')*/
  clear_obj(ho_Image_display);
  /***/read_image(&ho_Image_display, "E:/shapes.jpg");

  /*将图像转化为灰度图像*/
  /*rgb1_to_gray (Image_display, GrayImage)*/
  clear_obj(ho_GrayImage);
  /***/rgb1_to_gray(ho_Image_display, &ho_GrayImage);

  /*获取图像的尺寸*/
  /*get_image_size (Image_display, imageWidth, imageHeight)*/
  destroy_tuple(hv_imageWidth);
  destroy_tuple(hv_imageHeight);
  /***/T_get_image_size(ho_Image_display, &hv_imageWidth, &hv_imageHeight);

  /*新建显示窗口,适应图像尺寸*/
  /*dev_open_window (0, 0, imageWidth, imageHeight, 'black', WindowHandle1)*/
  create_tuple_s(&TTemp0,"black");
  create_tuple_s(&TTemp1,"background_color");
  T_set_window_attr(TTemp1,TTemp0);
  destroy_tuple(TTemp1);
  destroy_tuple(TTemp0);
  create_tuple_i(&TTemp0,0);
  create_tuple_i(&TTemp1,0);
  create_tuple_i(&TTemp2,0);
  create_tuple_s(&TTemp3,"visible");
  create_tuple_s(&TTemp4,"");
  destroy_tuple(hv_WindowHandle1);
  /***/T_open_window(TTemp0,TTemp1,hv_imageWidth,hv_imageHeight,TTemp2,TTemp3,TTemp4,&hv_WindowHandle1);
  destroy_tuple(TTemp4);
  destroy_tuple(TTemp3);
  destroy_tuple(TTemp2);
  destroy_tuple(TTemp1);
  destroy_tuple(TTemp0);
  hdev_window_stack_push(hv_WindowHandle1);

  if (hdev_window_stack_is_open())
  {
    Htuple active_win;
    create_tuple(&active_win,0);
    hdev_window_stack_get_active(&active_win);
    /*dev_display (GrayImage)*/
    /***/T_disp_obj(ho_GrayImage, active_win);
    destroy_tuple(active_win);
  }  


  /**********/
  /**********     End procedure   **********/
  /**********/

  system("pause");

  /* Clear temporary tuple stack */

  /* Clear local iconic variables */
  clear_obj(ho_Image_display);
  clear_obj(ho_GrayImage);
  

  /* Clear local control variables */
  destroy_tuple(hv_imageWidth);
  destroy_tuple(hv_imageHeight);
  destroy_tuple(hv_WindowHandle1); 

}


int main(int argc, char *argv[])
{
  /* Default settings used in HDevelop */
  int ret=0;
  Htuple Parameter, Value;

#if defined(_WIN32)
  set_system("use_window_thread", "true");
#endif

  /* file was stored with local-8-bit encoding
   *   -> set the interface encoding accordingly */
  SetHcInterfaceStringEncodingIsUtf8(FALSE);

  create_tuple(&Parameter,2);
  create_tuple(&Value,2);
  set_s(Parameter,"width",0);
  set_i(Value,512,0);
  set_s(Parameter,"height",1);
  set_i(Value,512,1);
  T_set_system(Parameter,Value);
  destroy_tuple(Value);
  destroy_tuple(Parameter);

  action();

  return ret;
}
----------------------------------------------
-
作者:
男 denis (Denis) ★☆☆☆☆ -
盒子活跃会员
2023/5/31 11:03:18
4楼: HBase.h

/**********
 * HBase.h
 **********
 *
 * Project:     HALCON/libhalcon
 * Description: Basic definitions for HALCON, HALCON/C, HALCON/C++
 *          and other language interfaces
 *
 * (c) 1996-2021 by MVTec Software GmbH
 *          www.mvtec.com
 *
 **********/

#ifndef HBASE_H
#define HBASE_H

#include <stdlib.h> /* NULL */
#include "HIntDef.h"

typedef void* VOIDP;

/**********/
/* Parameter passing (Control parameters)          */
/**********/
#define UNDEF_PAR 0          /* Parameter type: no defined type          */
#define LONG_PAR 1          /* Parameter type: long          */
#define FLOAT_PAR 2          /* Parameter type: float          */
#define STRING_PAR 4         /* Parameter type: string          */
#define HANDLE_PAR 16        /* Parameter type: handle (arbitrary data)  */
#define INT_PAR LONG_PAR     /* Parameter type: int          */
#define DOUBLE_PAR FLOAT_PAR /* Parameter type: double          */
#define MIXED_PAR 8          /* Parameter type: Hcpar          */
#define MAX_TUPLE_TYPE HANDLE_PAR /* maximum type number          */
/* Possible parameter types for a single element: */
#define ANY_ELEM (LONG_PAR | FLOAT_PAR | STRING_PAR | HANDLE_PAR)
/* Possible parameter types for a tuple: */
#define ANY_TUPLE (ANY_ELEM | MIXED_PAR)
/*          32          reserved */
#define POINTER_PAR 64 /* Parameter type: pointer to any type    */
#define TUPLE_PAR 128  /* Parameter type: pointer to tuple       */
#define MAX_PAR HANDLE_PAR


/**********/
/* Constants and basic types          */
/**********/
#define MAX_TUPLE_LENGTH 1000000 /* max. length of a tuple          */
#define MAX_STRING 1024          /* max. length of a string          */

typedef uint32_t Herror; /* Type function values (error messages)  */

typedef long* Hkey;         /* primary key in DB (for iconic objects) */
#define UNDEF_KEY (Hkey)(0) /* Undefined iconic object          */


/**********/
/* Structures for passing parameters between language interface and core     */
/**********/
#ifndef HC_NO_STRUCT_MEMBER_ALIGNMENT
/* sets the struct member alignment to avoid problems if
 * the settings of the user differ to those of the HALCON
 * version. (8 is the default alignment, generally) */
#  pragma pack(push, 8)
#endif


/**********/
/* HALCON procedure (operator) handle          */
/**********/
/* This data structure contains all informations about an instance of an     */
/* HALCON operator or an HALCON thread derived from an HALCON operator       */
/* instance. The contained information describes the processing context of   */
/* HALCON operators (e.g. parameter values, debugging information, etc.).    */
/**********/
typedef void* Hproc_handle;


/**********/
/* Structures, Functions and Defines for Handles          */
/**********/

struct HStreamBufferT;
struct HhandleListT;

/**********/
/** HSignalTypeEnum: List of signals that can be sent to handles
 **********
 * This enum defines a set of signals that can be sent to the
 * signalling callback of handles.  Note that the callback functions must
 * ignore any signal that they do not understand.
 **********/
typedef enum
{
  eSignalNone = 0,   /**< No signal */
  eSignalStartAbort, /**< Initiate abort: stop running, abort mutexes etc. */
  eSignalAbort,      /**< Finalize abort, wait for resources to finish */
  eSignalRestore,    /**< After abortion is complete, restore mutexes etc. */
} HSignalTypeEnum;

typedef Herror (*HHandleSerializeFunc)(Hproc_handle, struct HStreamBufferT*,
          void*);
typedef Herror (*HHandleDeserializeFunc)(Hproc_handle, struct HStreamBufferT*,
          void**);
typedef Herror (*HHandleDestructorFunc)(Hproc_handle, void*);
typedef Herror (*HHandleSignalFunc)(HSignalTypeEnum signal, void*);

/**********/
/** HHandleInfo holds handle type information.
 **********
 * This structure exists once per handle type (usually per sem_type).
 * It contains basic, static, constant information about that type.
 * Most notably, it contains pointers to the functions that operate on the
 * handles (clear, serialize, deserialize and signal).
 *
 * Handles (instances) of types where the cb_signal callback is not NULL are
 * stored in a list that allows calling the signal callback for each of them.
 *
 * All serialized items must have a unique header, usually a string, that
 * identifies them. 'header' contains a pointer to that header, allowing
 * other functions to identify a serialized item based on its header.
 * If no (de)serialization function is set, header must be NULL.
 *
 * \ingroup data_structures_handles
 **********/
typedef struct H_HANDLE_TYPE
{
  INT4_8          type_id;        /**< Type ID */
  const char*          sem_type;       /**< sem_type of the handle */
  HHandleSerializeFunc   cb_serialize;   /**< Serialize this handle type */
  HHandleDeserializeFunc cb_deserialize; /**< Deserialize this handle type */
  const char*          header;         /**< Serialization header */
  HHandleDestructorFunc  cb_clear;       /**< Clear this handle type */
  HHandleSignalFunc      cb_signal;      /**< Signal (for semaphores etc.) */
  struct HhandleListT*   list;          /**< List of handles, or NULL */
} HHandleInfo;


/**********/
/** HANDLE_INFO_INITIALIZER: Convenience macro for initializing HHandleInfo
 **********/
#define HANDLE_INFO_INITIALIZER(TYPE_ID, SEM_TYPE, FUN_SERIALIZE,          \
          FUN_DESERIALIZE, HEADER_STRING, FUN_CLEAR,    \
          FUN_SIGNAL, LIST)          \
  {          \
    (INT4_8)(TYPE_ID), (SEM_TYPE), (HHandleSerializeFunc)(FUN_SERIALIZE),     \
        (HHandleDeserializeFunc)(FUN_DESERIALIZE), HEADER_STRING,          \
        (HHandleDestructorFunc)(FUN_CLEAR), (HHandleSignalFunc)(FUN_SIGNAL),  \
        (LIST)          \
  }

/**********/
/** HANDLE_INFO_INITIALIZER_NOSER: Convenience macro for init. HHandleInfo
 **********
 * Use this macro for handles that cannot be (de)serialized.
 **********/
#define HANDLE_INFO_INITIALIZER_NOSER(TYPE_ID, SEM_TYPE, FUN_CLEAR,          \
          FUN_SIGNAL, LIST)          \
  {          \
    (INT4_8)(TYPE_ID), (SEM_TYPE), (HHandleSerializeFunc)NULL,          \
        (HHandleDeserializeFunc)NULL, (const char*)NULL,          \
        (HHandleDestructorFunc)(FUN_CLEAR), (HHandleSignalFunc)(FUN_SIGNAL),  \
        (LIST)          \
  }

typedef struct HhandleT* Hphandle;

typedef union
{
  INT4_8   l; /* 4/8 byte integer          (input)  */
  double   d; /* 8 byte real          (input)  */
  char*    s; /* pointer to strings          (input)  */
  double   f; /* 8 byte real (legacy 11.0)          (input)  */
  Hphandle h; /* Pointer to handle          (input)  */
} Hpar;       /* parameter passing for the C interface          */

typedef union
{
  INT4_8* l; /* 4/8 byte integer          (output) */
  double* d; /* 8 byte real,          (output) */
  char*   s; /* pointer to strings          (output) */
  void*   p; /* pointer to var. of any type (e.g. tuple)(output)*/
  double* f; /* 8 byte real, (legacy 11.0)          (output) */
} Hvar;      /* parameter passing for the C interface          */

typedef struct
{
  Hpar par;  /* values          */
  int  type; /* type flag          */
} Hcpar;     /* parameter passing for the C interface          */

typedef struct
{
  Hvar var;  /* values          */
  int  type; /* type flag          */
} Hcvar;     /* parameter passing for the C interface          */

typedef union
{
  INT4_8*   l;
  double*   d;
  char**    s;
  Hcpar*    cpar;
  Hphandle* h;
} Hcelem; /* pure type array */


typedef struct HCTUPLE
{
  Hpar val;
  int  type;
  /*
   * Add manual padding here so that a Hcpar can be mapped to a Hctuple
   * exactly, including the padding compilers insert at the end of data
   * structures to align the entire structure to the largest alignment of any
   * structure member. Note that on 32 bit Linux for Intel, Hcpar is aligned to
   * 4 bytes, so no manual padding is necessary on that architecture (only).
   */
#if !(defined(__linux__) && defined(__i386__))
  char pad[sizeof(Hcpar) - sizeof(Hpar) - sizeof(int)];
#endif
  INT4_8 num;      /* number of set array elements */
  INT4_8 capacity; /* allocated array length */
  int    free;     /* free array elem when destroying tuple? */
  Hcelem elem;     /* the actual array */
} Hctuple;
#define HCTUPLE_INITIALIZER          \
  {          \
    {0}, UNDEF_PAR, {0}, 0, 0, 0,          \
    {          \
      NULL          \
    }          \
  }

typedef struct
{
  Hcvar* variables; /* variables (of application) to write back values */
  Hcpar* element;   /* tuple element(s)          */
  INT4_8 num_el;    /* number of used elements          */
  INT4_8 length;    /* total length of array (incl. unused elements)   */
} Hcvtuple;         /* for passing control parameter variables from    */
          /* the language to the core interface          */
#ifndef HC_NO_STRUCT_MEMBER_ALIGNMENT
#  pragma pack(pop)
#endif

/**********/
/* Bool constants (legacy)          */
/**********/
#ifdef TRUE
#  undef TRUE
#endif
#define TRUE true

#ifdef FALSE
#  undef FALSE
#endif
#define FALSE false


/**********/
/* Pixel types of HALCON images          */
/**********/
#define UNDEF_IMAGE 0
#define BYTE_IMAGE (1 << 0)
#define INT4_IMAGE (1 << 1)
#define LONG_IMAGE INT4_IMAGE
#define FLOAT_IMAGE (1 << 2)
#define DIR_IMAGE (1 << 3)
#define CYCLIC_IMAGE (1 << 4)
#define INT1_IMAGE (1 << 5)
/* (1<<6) omitted so far -> use it for next new image type */
#define COMPLEX_IMAGE (1 << 7)
/* (1<<8) omitted so far -> use it for next new image type */
#define INT2_IMAGE (1 << 9)
#define UINT2_IMAGE (1 << 10)
#define VF_IMAGE (1 << 11)
#define INT8_IMAGE (1 << 12)

/**********/
/* Type of HALCON vector field images          */
/**********/
#define VF_ABSOLUTE 0
#define VF_RELATIVE (1 << 0)


/**********/
/* data types for handling pthreads (POSIX threads) and mutex variables      */
/**********/
typedef void* H_pthread_t;         /* pthread handle          */
typedef void* H_pthread_mutex_t;   /* pthread mutex data type    */
typedef void* H_pthread_cond_t;    /* pthread condition variable */
typedef void* H_pthread_barrier_t; /* pthread barrier variable */


/**********/
/* signature of the callback functions for drawing objects          */
/**********/

#ifndef _WIN32
#  define __stdcall
#endif
typedef Herror(__stdcall* HDrawObjectCallback)(Hphandle DrawHandle,
          Hphandle WindowHandle,
          char*    type);

/**********/
/* signature of the callback functions for buffer window content updates     */
/**********/
typedef Herror(__stdcall* HUpdateContentCallback)(void* context);

/**********/
/* signature of the callback function for license recheck failure callbacks  */
/**********/
typedef void(__stdcall* HLicenseRecheckFailedCallback)(void*  context,
          Herror error);

/* A define for the restrict qualifier */
#if !defined(H_RESTRICT)
#  if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* Compiler is in C99 mode and should know about the restrict qualifier */
#    define H_RESTRICT restrict
#  else
#    if (defined(_WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) ||         \
        defined(__INTEL_COMPILER)
/* Intel Compilers and grown-up Microsoft Compilers always know a __restrict */
#      define H_RESTRICT __restrict
#    elif (defined(__linux) || defined(__APPLE__)) && defined(__GNUC__)
/* Gcc knows about __restrict__ since at least gcc 3.0 */
#      define H_RESTRICT __restrict__
#    elif defined(__TI_COMPILER_VERSION__)
/* TI's cgtools know about restrict. */
#      define H_RESTRICT restrict
#    else
#      define H_RESTRICT
#    endif
#  endif /* __STDC_VERSION__ */
#endif   /* H_RESTRICT */


/* A define for the inline qualifier */
#if !defined(H_INLINE)
#  ifdef __cplusplus
#    define H_INLINE inline
#  else
#    if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* compiler is in C99 mode and should know about the inline qualifier */
#      define H_INLINE inline
#    else
#      if defined(_WIN32) || defined(__alpha) || defined(__sgi)
#        define H_INLINE __inline
#      else
#        if defined(__linux) || defined(__APPLE__)
#          define H_INLINE __inline__
#        else
#          if defined(__sun)
#          define H_INLINE inline
#          else
#          define H_INLINE
#          endif
#        endif
#      endif
#    endif /* __STDC_VERSION__ */
#  endif   /* #ifdef __cplusplus .. else */
#endif     /* H_INLINE */

/* A define to force functions to be inlined */
#if defined(_WIN32)
#  define H_FORCEINLINE __forceinline
#elif (defined(__linux) || defined(__APPLE__)) && defined(__GNUC__)
#  define H_FORCEINLINE H_INLINE __attribute__((always_inline))
#else
#  define H_FORCEINLINE H_INLINE
#endif

#endif /* ifndef HBASE_H */
----------------------------------------------
-
作者:
男 denis (Denis) ★☆☆☆☆ -
盒子活跃会员
2023/5/31 11:12:19
5楼: 求高人指教
----------------------------------------------
-
作者:
男 myy (myy) ★☆☆☆☆ -
盒子活跃会员
2023/5/31 11:30:20
6楼: 可能是类型没对应的原因,这就是看你对c和pascal是不是都很熟悉。。

没什么好指教的,就是个体力活。自己在仔细查查吧。
----------------------------------------------
-
作者:
男 wk_knife (wk_knife) ★☆☆☆☆ -
盒子活跃会员
2023/5/31 12:16:33
7楼: 可以找chatgpt帮你转转或找找问题
----------------------------------------------
-
作者:
男 denis (Denis) ★☆☆☆☆ -
盒子活跃会员
2023/5/31 16:43:57
8楼: HalconCLib.pas 修改了2个地方,但错误还是一样。
此帖子包含附件:denis_2023531164357.zip 大小:1,538B
----------------------------------------------
-
作者:
男 hardnut (麦轲数据管家) ★☆☆☆☆ -
普通会员
2023/6/1 7:58:41
9楼: 你有没有考虑C的结构体与pascal的record的对齐方式是否一致,这是个易错点.
----------------------------------------------
UniKeeper V10.40 -- 您最贴心的个人数据管理助手
作者:
男 kwer (★★★★★) ★☆☆☆☆ -
普通会员
2023/6/1 8:17:13
10楼: Windows7根本就跑不起来,好像Win8以上才可以。。。建议试一下Lazarus,至少编译是可以通过
----------------------------------------------
==========-==========-==========-==========-==========
     多隆, 给我备一匹最快的马, 我有事要走先~~~
==========-==========-==========-==========-==========
作者:
男 denis (Denis) ★☆☆☆☆ -
盒子活跃会员
2023/6/1 11:03:55
11楼: 要win10才能跑,Halcon高版本不支持win7
----------------------------------------------
-
作者:
男 denis (Denis) ★☆☆☆☆ -
盒子活跃会员
2023/6/3 18:48:04
12楼: 好像是找到问题点了
相同C语言代码,编译成exe运行,没问题
如果编译成dll 用delphi调用,就会出错

出错的地方还是T_disp_obj  Open_Window 功能是跳出一个显示图片的窗体或把窗体嵌入主程序中

为什么相同的代码,编译成dll就会出错,是不是有什么没有初始化
----------------------------------------------
-
作者:
男 denis (Denis) ★☆☆☆☆ -
盒子活跃会员
2023/6/9 8:20:44
13楼: 问题已解决
参考 https://bbs.2ccc.com/topic.asp?topicid=678227 8楼方法
----------------------------------------------
-
作者:
男 dreamseek (dreamseek) ★☆☆☆☆ -
普通会员
2023/9/25 10:31:12
14楼: 能分享一份吗?最近学halcon,可不会C!
----------------------------------------------
-
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行156.25毫秒 RSS