Machine Vision
Machine Vision
DE CARTAGENA
Escuela Técnica Superior de Ingeniería
Industrial
APPENDIX
Appendix
Index
1
Appendix
2
Appendix
X4 DeviceNet/ CAN
3
Appendix
4
Appendix
5
Appendix
6
Appendix
7
Appendix
8
Appendix
9
Appendix
10
Appendix
A1.2. IOSYS.ini
;==========================================================
;==========================================================
;----------------------------------------------------------
[CONFIG]
VERSION=2.00
[DRIVERS]
RSI=50,rsiLibInit,rsiLib.o
;CNKE2=21,cnke2CPInit,cnke2drv.o
;DNSC6=20,dnsc6Init,dnsc6drv.o
;DNSC5=19,dnsc5Init,dnsc5drv.o
;DNSC4=18,dnsc4Init,dnsc4drv.o
;DNSC3=17,dnsc3Init,dnsc3drv.o
;CNKE1=16,cnke1CPInit,cnke1drv.o
;INTERBUSPCI=15,ibsCPPciInit,ibpcidrv.o
;DSEIO=14,dseIoInit,dseiodrv.o
;DNSC2=13,dnsc2Init,dnsc2drv.o
;DNSC1=12,dnsc1Init,dnsc1drv.o
;PBMASL=11,pbmsInit,pfbmsdrv.o
DEVNET=2,dnInit,dn2drv.o
;INTERBUS=1,ibusInit,ibusdrv.o
;MFC=0,mfcEntry,mfcdrv.o
[RSI]
[MFC]
INW0=0 ;$IN[1-16]
OUTW0=0 ;$OUT[1-16]
OUTW2=2 ;$OUT[17-32]
11
Appendix
[INTERBUS]
;Slave Inputs
INW50=896 ;$IN[401-416]
INW52=898 ;$IN[417-432]
INW54=900 ;$IN[433-448]
INW56=902 ;$IN[449-464]
;Slave Outputs
OUTW50=896 ;$OUT[401-416]
OUTW52=898 ;$OUT[417-432]
OUTW54=900 ;$OUT[433-448]
OUTW56=902 ;$OUT[449-464]
[DEVNET]
INB0=1,0,x1 ;$in[1-8]
OUTB0=1,0,x1 ;$out[1-8]
INB2=21,0,x1 ;$in[17-24]
INB3=21,1,x1 ;$in[25-32]
INB4=21,2,x1 ;$in[33-40]
INB5=21,3,x1 ;$in[41-48]
INB6=21,4,x1 ;$in[49-56]
INB7=21,5,x1 ;$in[57-64]
INB8=21,6,x1 ;$in[65-72]
INB9=21,7,x1 ;$in[73-80]
INB10=21,8,x1 ;$in[81-88]
INB11=21,9,x1 ;$in[89-96]
INB12=21,10,x1 ;$in[97-104]
INB13=21,11,x1 ;$in[105-112]
OUTB2=21,0,x1;$out[17-24]
OUTB3=21,1,x1;$out[25-32]
12
Appendix
OUTB4=21,2,x1;$out[33-40]
OUTB5=21,3,x1;$out[41-48]
OUTB6=21,4,x1 ;$OUT[49-56]
OUTB7=21,5,x1 ;$OUT[57-64]
OUTB8=21,6,x1 ;$OUT[65-72]
OUTB9=21,7,x1 ;$OUT[73-80]
OUTB10=21,8,x1 ;$OUT[81-88]
OUTB11=21,9,x1 ;$OUT[89-96]
OUTB12=21,10,x1 ;$OUT[97-104]
OUTB13=21,11,x1 ;$OUT[105-112]
[PBMASL]
[DNSC1]
[DNSC2]
[DNSC3]
[DNSC4]
[DNSC5]
[DNSC6]
[DSEIO]
INDW0=0 ;$IN[1-32]
OUTDW0=0 ;$OUT[1-32]
[INTERBUSPCI]
;Slave Inputs
INW50=896 ;$IN[401-416]
INW52=898 ;$IN[417-432]
INW54=900 ;$IN[433-448]
INW56=902 ;$IN[449-464]
;Slave Outputs
OUTW50=896 ;$OUT[401-416]
OUTW52=898 ;$OUT[417-432]
OUTW54=900 ;$OUT[433-448]
OUTW56=902 ;$OUT[449-464]
13
Appendix
[CNKE1]
[CNKE2]
[VIO]
;INW0=0 ;$IN[1-16]
;INW8=2 ;$IN[65-80]
;OUTW0=0 ;$OUT[1-16]
;OUTW2=2 ;$OUT[17-32]
[O2I]
;INW4=0 ;$IN[33-48]
;INW6=2 ;$IN[49-64]
;OUTW4=0 ;$OUT[33-48]
;OUTW6=2 ;$OUT[49-64]
[IOLINKING]
[END SECTION]
;==========================================================
; Form 1:
; {token}{offset}={byte}[,{multip}]
14
Appendix
; Example:
; OUTW4=2,x3
; Form 2:
; {token}{offset}={address},{byte}[,{multip}]
; Example:
; INW4=10,0,x2
; Form 1:
; {token}{num}={byte},{res},{type}[,CAL{factor}]
15
Appendix
; Example:
; ANIN1=10,12,3
; Form 2:
; {token}{num}={address},{byte},{res},{type}[,CAL{factor}]
; Example:
; ANIN3=30,0,16,2,CAL 0x6C00
16
Appendix
;particularities:
; Entries in form 1
; Entries in form 1
; $IN/OUT[n_1]=(n+1)*8-7
; $IN/OUT[n_8]=(n+1)*8
; {address}=DeviceNet MACID
; Entries in form 2
; Entries in form 2
; Entries in form 2
; Entries in form 2
17
Appendix
; Entries in form 2
; Entries in form 2
; Entries in form 2
; Entries in form 1
; Entries in form 2
; {address} = ConNo
; Entries in form 2
; {address} = ConNo
; Entries in form 1
;VIO=30,vioInit,vio_drv.o
18
Appendix
; Entries in form 1
;O2I=31,o2iInit,o2i_drv.o
; Special form:
; $OUT[{bitoffset}]=$IN[{bitoffset}]
; Example: $OUT[512]=$IN[401]
; Notes:
; linked by itself.
;----------------------------------------------------------
A1.3. CONFIG.dat
&REL 49
DEFDAT $CONFIG
;==================================
19
Appendix
;==================================
;----------------------------------
;----------------------------------
INT DEF_OV_PRO=100
INT DEF_ADVANCE=3
; PTP - MOVEMENTS
;----------------------------------
INT DEF_VEL_PTP=100
INT DEF_ACC_PTP=50
; CP - MOVEMENTS
;----------------------------------
REAL DEF_VEL_CP=2.0
REAL DEF_VEL_ORI1=200.0
REAL DEF_VEL_ORI2=200.0
REAL DEF_VEL_ORIS=200.0
REAL DEF_ACC_CP=2.29999995
REAL DEF_ACC_ORI1=100.0
REAL DEF_ACC_ORI2=100.0
REAL DEF_ACC_ORIS=200.0
REAL DEF_VEL_FACT=1.0
; APO - parameters
;--------------------------------
INT DEF_APO_CPTP=50
INT DEF_APO_CVEL=100
REAL DEF_APO_CDIS=3.0
REAL DEF_APO_CORI=5.0
REAL DEF_APO_CORIS=80.0
20
Appendix
;==================================
; Structures:
;==================================
ENUM BAS_COMMAND
INITMOV,ACC_CP,ACC_PTP,VEL_CP,VEL_PTP,ACC_GLUE,TOOL,BASE,EX_BASE,PTP_DAT,CP_DAT,OUT_S
YNC,OUT_ASYNC,GROUP,FRAMES,PTP_PARAMS,CP_PARAMS
;==================================
; TORQUE MONITORING
;==================================
BOOL bTQM_ACTIVE=FALSE
BOOL bTQM_CYC=FALSE
BOOL bTQM_KCPSTATUS=FALSE
21
Appendix
DECL TQM_TQDAT_T TMDEFAULT={T11 200,T12 200,T13 200,T14 200,T15 200,T16 200,T21 1000,T22
1000,T23 1000,T24 1000,T25 1000,T26 1000,K1 280,K2 280,K3 280,K4 280,K5 280,K6 280,O1
20,O2 30,ID 0,OVM 0,TMF 1.0}
DECL TQM_TQDAT_T TM0={T11 200,T12 200,T13 200,T14 200,T15 200,T16 200,T21 1000,T22
1000,T23 1000,T24 1000,T25 1000,T26 1000,K1 280,K2 280,K3 280,K4 280,K5 280,K6 280,O1
20,O2 30,ID 0,OVM 0,TMF 1.0}
;==================================
; External declarations:
;==================================
EXT IR_STOPM ( )
;====================
; Signal declarations
;====================
22
Appendix
;==================================
;==================================
;==================================
; Variables:
;==================================
23
Appendix
;GROUP-Definitions
;----------------------------------
INT COMPL_GROUP='B0001'
INT DEF_GROUP[10]
DEF_GROUP[1]='B1111' ; complete
DEF_GROUP[7]='B1111' ; complete
DEF_GROUP[8]='B1111' ; complete
DEF_GROUP[9]='B1111' ; complete
DEF_GROUP[10]='B1111' ; complete
INT $ACT_GROUP='B0001'
; HOME POSITION
;----------------------------------
24
Appendix
E6AXIS XHOME2={A1 0.0,A2 -90.0,A3 90.0,A4 0.0,A5 0.0,A6 0.0,E1 0.0,E2 0.0,E3 0.0,E4
0.0,E5 0.0,E6 0.0}
E6AXIS XHOME3={A1 0.0,A2 -90.0,A3 90.0,A4 0.0,A5 0.0,A6 0.0,E1 0.0,E2 0.0,E3 0.0,E4
0.0,E5 0.0,E6 0.0}
E6AXIS XHOME4={A1 0.0,A2 -90.0,A3 90.0,A4 0.0,A5 0.0,A6 0.0,E1 0.0,E2 0.0,E3 0.0,E4
0.0,E5 0.0,E6 0.0}
E6AXIS XHOME5={A1 0.0,A2 -90.0,A3 90.0,A4 0.0,A5 0.0,A6 0.0,E1 0.0,E2 0.0,E3 0.0,E4
0.0,E5 0.0,E6 0.0}
; REFERENCE POINTS
;----------------------------------
;----------------------------------
BOOL AUTO_IPO_M=FALSE
25
Appendix
BOOL STOPM_FLAG=FALSE
BOOL TOOL_CORR_ON=FALSE
BOOL TOOL_CORR_W_ON=FALSE
BOOL BASE_CORR_ON=FALSE
BOOL M_BAS_COR_ON=FALSE
INT COR_TOOL_NO=0
INT MAX_TOOL=16
TOOL_NAME[1,]="Flens A6"
TOOL_NAME[2,]="welding_torch"
TOOL_NAME[3,]=" "
TOOL_NAME[4,]=" "
26
Appendix
TOOL_NAME[5,]=" "
TOOL_NAME[6,]=" "
TOOL_NAME[7,]=" "
TOOL_NAME[8,]=" "
TOOL_NAME[9,]=" "
TOOL_NAME[10,]=" "
TOOL_NAME[11,]=" "
TOOL_NAME[12,]=" "
TOOL_NAME[13,]=" "
TOOL_NAME[14,]=" "
TOOL_NAME[15,]=" "
TOOL_NAME[16,]=" "
LOAD_DATA[1]={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z 0.0}}
LOAD_DATA[2]={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z 0.0}}
LOAD_DATA[3]={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z 0.0}}
LOAD_DATA[4]={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z 0.0}}
LOAD_DATA[5]={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z 0.0}}
LOAD_DATA[6]={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z 0.0}}
LOAD_DATA[7]={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z 0.0}}
LOAD_DATA[8]={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z 0.0}}
LOAD_DATA[9]={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z 0.0}}
LOAD_DATA[10]={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z 0.0}}
LOAD_DATA[11]={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z 0.0}}
LOAD_DATA[12]={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z 0.0}}
LOAD_DATA[13]={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z 0.0}}
LOAD_DATA[14]={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z 0.0}}
LOAD_DATA[15]={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z 0.0}}
LOAD_DATA[16]={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z 0.0}}
TOOL_TYPE[1]=#BASE
TOOL_TYPE[2]=#BASE
TOOL_TYPE[3]=#BASE
TOOL_TYPE[4]=#BASE
27
Appendix
TOOL_TYPE[5]=#NONE
TOOL_TYPE[6]=#NONE
TOOL_TYPE[7]=#NONE
TOOL_TYPE[8]=#NONE
TOOL_TYPE[9]=#NONE
TOOL_TYPE[10]=#NONE
TOOL_TYPE[11]=#NONE
TOOL_TYPE[12]=#NONE
TOOL_TYPE[13]=#NONE
TOOL_TYPE[14]=#NONE
TOOL_TYPE[15]=#NONE
TOOL_TYPE[16]=#NONE
DECL LOAD LOAD_A1_DATA={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z
0.0}}
DECL LOAD LOAD_A2_DATA={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z
0.0}}
DECL LOAD LOAD_A3_DATA={M -1.0,CM {X 0.0,Y 0.0,Z 0.0,A 0.0,B 0.0,C 0.0},J {X 0.0,Y 0.0,Z
0.0}}
INT MAX_BASE=32
28
Appendix
BASE_NAME[1,]="pallet "
BASE_NAME[2,]="bakjeGereedschappen"
BASE_NAME[3,]="bakjeGereedschappen2"
BASE_NAME[4,]=" "
BASE_NAME[5,]=" "
BASE_NAME[6,]=" "
BASE_NAME[7,]=" "
BASE_NAME[8,]=" "
BASE_NAME[9,]=" "
BASE_NAME[10,]=" "
BASE_NAME[11,]=" "
BASE_NAME[12,]=" "
BASE_NAME[13,]=" "
BASE_NAME[14,]=" "
BASE_NAME[15,]=" "
29
Appendix
BASE_NAME[16,]=" "
BASE_NAME[17,]=" "
BASE_NAME[18,]=" "
BASE_NAME[19,]=" "
BASE_NAME[20,]=" "
BASE_NAME[21,]=" "
BASE_NAME[22,]=" "
BASE_NAME[23,]=" "
BASE_NAME[24,]=" "
BASE_NAME[25,]=" "
BASE_NAME[26,]=" "
BASE_NAME[27,]=" "
BASE_NAME[28,]=" "
BASE_NAME[29,]=" "
BASE_NAME[30,]=" "
BASE_NAME[31,]=" "
BASE_NAME[32,]=" "
BASE_TYPE[1]=#BASE
BASE_TYPE[2]=#BASE
BASE_TYPE[3]=#BASE
BASE_TYPE[4]=#NONE
BASE_TYPE[5]=#NONE
BASE_TYPE[6]=#NONE
BASE_TYPE[7]=#NONE
BASE_TYPE[8]=#NONE
BASE_TYPE[9]=#NONE
BASE_TYPE[10]=#NONE
BASE_TYPE[11]=#NONE
BASE_TYPE[12]=#NONE
BASE_TYPE[13]=#NONE
BASE_TYPE[14]=#NONE
BASE_TYPE[15]=#NONE
BASE_TYPE[16]=#NONE
BASE_TYPE[17]=#NONE
30
Appendix
BASE_TYPE[18]=#NONE
BASE_TYPE[19]=#NONE
BASE_TYPE[20]=#NONE
BASE_TYPE[21]=#NONE
BASE_TYPE[22]=#NONE
BASE_TYPE[23]=#NONE
BASE_TYPE[24]=#NONE
BASE_TYPE[25]=#NONE
BASE_TYPE[26]=#NONE
BASE_TYPE[27]=#NONE
BASE_TYPE[28]=#NONE
BASE_TYPE[29]=#NONE
BASE_TYPE[30]=#NONE
BASE_TYPE[31]=#NONE
BASE_TYPE[32]=#NONE
;******************************************
;******************************************
INT MAX_MACHINES=16
MACHINE_DEF[2]={NAME[] " ",COOP_KRC_INDEX 0,PARENT[] " ",ROOT {X 0.0,Y 0.0,Z 0.0,A 0.0,B
0.0,C 0.0},MECH_TYPE #NONE,GEOMETRY[] " "}
MACHINE_DEF[3]={NAME[] " ",COOP_KRC_INDEX 0,PARENT[] " ",ROOT {X 0.0,Y 0.0,Z 0.0,A 0.0,B
0.0,C 0.0},MECH_TYPE #NONE,GEOMETRY[] " "}
MACHINE_DEF[4]={NAME[] " ",COOP_KRC_INDEX 0,PARENT[] " ",ROOT {X 0.0,Y 0.0,Z 0.0,A 0.0,B
0.0,C 0.0},MECH_TYPE #NONE,GEOMETRY[] " "}
MACHINE_DEF[5]={NAME[] " ",COOP_KRC_INDEX 0,PARENT[] " ",ROOT {X 0.0,Y 0.0,Z 0.0,A 0.0,B
0.0,C 0.0},MECH_TYPE #NONE,GEOMETRY[] " "}
MACHINE_DEF[6]={NAME[] " ",COOP_KRC_INDEX 0,PARENT[] " ",ROOT {X 0.0,Y 0.0,Z 0.0,A 0.0,B
0.0,C 0.0},MECH_TYPE #NONE,GEOMETRY[] " "}
MACHINE_DEF[7]={NAME[] " ",COOP_KRC_INDEX 0,PARENT[] " ",ROOT {X 0.0,Y 0.0,Z 0.0,A 0.0,B
0.0,C 0.0},MECH_TYPE #NONE,GEOMETRY[] " "}
MACHINE_DEF[8]={NAME[] " ",COOP_KRC_INDEX 0,PARENT[] " ",ROOT {X 0.0,Y 0.0,Z 0.0,A 0.0,B
0.0,C 0.0},MECH_TYPE #NONE,GEOMETRY[] " "}
MACHINE_DEF[9]={NAME[] " ",COOP_KRC_INDEX 0,PARENT[] " ",ROOT {X 0.0,Y 0.0,Z 0.0,A 0.0,B
0.0,C 0.0},MECH_TYPE #NONE,GEOMETRY[] " "}
31
Appendix
32
Appendix
;******************************************
;******************************************
BOOL CONST_SPEED
;******************************************
33
Appendix
;******************************************
INT POWER
;******************************************
;******************************************
BOOL UM_TOUCHUP=FALSE
REAL CARTESIAN_TOL=5.0
REAL ROTATION_ANGLE=10.0
REAL EXTAX_TOL[6]
EXTAX_TOL[1]=10.0
EXTAX_TOL[2]=10.0
EXTAX_TOL[3]=10.0
EXTAX_TOL[4]=10.0
EXTAX_TOL[5]=10.0
EXTAX_TOL[6]=10.0
;******************************************
;******************************************
I[1]=0
I[2]=0
I[3]=0
I[4]=0
I[5]=0
I[6]=0
I[7]=0
I[8]=0
I[9]=0
I[10]=0
I[11]=0
I[12]=0
I[13]=0
34
Appendix
I[14]=0
I[15]=0
I[16]=0
I[17]=0
I[18]=0
I[19]=0
I[20]=0
;******************************************
;******************************************
IBUS_SEGMENT[1]=0
IBUS_SEGMENT[2]=0
IBUS_SEGMENT[3]=0
IBUS_SEGMENT[4]=0
IBUS_SEGMENT[5]=0
IBUS_SEGMENT[6]=0
IBUS_SEGMENT[7]=0
IBUS_SEGMENT[8]=0
IBUS_SEGMENT[9]=0
IBUS_SEGMENT[10]=0
IBUS_SEGMENT[11]=0
IBUS_SEGMENT[12]=0
IBUS_SEGMENT[13]=0
IBUS_SEGMENT[14]=0
IBUS_SEGMENT[15]=0
IBUS_SEGMENT[16]=0
;==================================
; Structures:
;==================================
35
Appendix
;==================================
; External declarations:
;==================================
;==================================
; Variables:
;==================================
; Communication:
;----------------------------------
BOOL ERROR_FLAG
BOOL CHECK_HOME=TRUE
BOOL PROG_CONTROL=FALSE
PRO_NAME1_L[]=" "
PRO_NAME1_A[]=" "
; Communication: I/O-Interface
;----------------------------------
36
Appendix
INT P01_STEP
INT CHK_STEP
INT PGNO_FLAG
INT MAX_SPS_PROG=12
TMPNAME[]=" "
;******************************************************
; Date: : 26/06/2008
;******************************************************
; Variable nomenclatur:
37
Appendix
; XX_b = bool
; XX_i = integer
; XX_e = enumeration
; XX_r = real
; XX_s = string
; XX_f = frame
; I_ = input
; O_ = output
;=====================================
; STRINGS
;=====================================
APP_sDATA_PATH[]="D:\ApplicationsData\"
APP_sROB_PROG_PATH[]="C:\KRC\Roboter\KRC\R1\Program\"
APP_sHTML_JOBINFO[]=" "
APP_TM_sPROJECTNAME[]=" "
APP_JLM_sLASTJOBLIST[]="My_Joblist.jls "
APP_JLM_sTEMPLATE_PATH[]="C:\KRC\TP\Applications\LIB\Templates\sw5_2\"
;=====================================
;=====================================
; INTEGERS
38
Appendix
;=====================================
INT APP_iLAST_PSTATE1=1
;=====================================
;=====================================
; BOOLS
;=====================================
;=====================================
;=====================================
; Network socket
;=====================================
BOOL APP_bTCP_ENABLED=FALSE
BOOL APP_bTCP_LOG_ON=FALSE
BOOL APP_bUDP_ENABLED=TRUE
BOOL APP_bUDP_LOG_ON=FALSE
INT APP_iSOCKET_NIC_INDEX=1
INT APP_iTCP_PORT=9901
INT APP_iUDP_PORT=9902
APP_sSOCKET_JOBLISTNAME[]="SocketJobList"
;=====================================
39
Appendix
40
Appendix
41
Appendix
42
Appendix
;Wirefeed control
43
Appendix
BOOL B_RESTART=FALSE
BOOL FLY_WELD=FALSE
BOOL WELD_ACTIVE=FALSE
BOOL T1_L
;current instruction
INT ARC_INSTR_D=0
44
Appendix
; instruction code
INT ARC_INI=1
INT ARC_ON=2
INT ARC_OFF=3
INT ARC_SWI_F=4
INT ARC_SWIP=5
INT TECH_STOP1=6
INT TECH_STOP2=7
INT TECH_STOP=9
INT ARC_OFF_P=10
INT ARC_OFF_V=12
INT ARC_START=13
INT ARC_SWI_T=14
INT ARC_OFF_T=15
INT PRGNO=1
INT TMP_PRG=0
INT A_WEAV_GEN_D[6]
A_WEAV_GEN_D[1]=1 ; A_FG_MECH1
A_WEAV_GEN_D[2]=2 ; A_FG_MECH2
A_WEAV_GEN_D[3]=3 ; A_FG_THERM
A_WEAV_GEN_D[4]=4 ; A_FG_SENSOR
INT A_LST_M1_FIG_D=0
INT A_LST_M2_FIG_D=0
;*******************************************
45
Appendix
;*******************************************
;==================================
; Userdefined Types
;==================================
;==================================
; Userdefined Externals
;==================================
;==================================
; Userdefined Variables
;==================================
INT HANDLE,OFFSET
REAL TIMEOUT
REAL R_VALUE
BOOL B_VALUE
ENDDAT
46
Appendix
A2. KUKA.ArcTech
47
Appendix
48
Appendix
&ACCESS RVP
&REL 267
&PARAM EDITMASK = *
49
Appendix
DEF Jose( )
;FOLD INI
;MOTION COMMANDS
;INITIAL POSITION
;WELDING ACTION
;END POSITION
END
DEF Cylinder( )
FOLD INI
;Initial Position
50
Appendix
;Motion Commands
;First Sector
;Arc ignition
;Second Sector
;Arc Ignition
FOLD LIN P11 Vel= 2 m/s CPDAT17 ARC_ON Pgno= 7 S3 Seam3 Tool[3]:Welding_torch2
Base[3]:Cylinder;%{PE}%R 5.5.0,%MKUKATPA20,%CARC_ON,%VLIN,%P 1:LIN, 2:P11, 3:, 5:2,
7:CPDAT17, 10:1, 11:S3, 12:Seam3
;Welding performance
51
Appendix
;Third Sector
;Arc ignition
;Welding performance
;Fourth Sector
;Arc Ignition
;FOLD LIN P13 Vel= 2 m/s CPDAT23 ARC_ON Pgno= 7 S5 Seam5 Tool[2]:welding_torch
Base[3]:Cylinder;%{PE}%R 5.5.0,%MKUKATPA20,%CARC_ON,%VLIN,%P 1:LIN, 2:P13, 3:, 5:2,
7:CPDAT23, 10:1, 11:S5, 12:Seam5
;Welding Performance
;Final Position
52
Appendix
END
DEF workpiece( )
FOLD INI
;Initial position
;Arc Ignition
;Welding performance
;Circular beam
;First Sector
;Arc Ignition
53
Appendix
FOLD LIN P10 Vel= 2 m/s CPDAT40 ARC_ON Pgno= 7 S13 Seam6 Tool[2]:welding_torch
Base[2]:Base1;%{PE}%R 5.5.0,%MKUKATPA20,%CARC_ON,%VLIN,%P 1:LIN, 2:P10, 3:, 5:2,
7:CPDAT40, 10:4, 11:S13, 12:Seam6
;Welding performance
FOLD CIRC P15 P16 CPDAT41 ARC_OFF Pgno= 7 E12 Seam12 Tool[2]:welding_torch
Base[2]:Base1;%{PE}%R 5.5.0,%MKUKATPA20,%CARC_OFF,%VCIRC,%P 1:CIRC, 2:P15, 3:P16, 4:,
6:2, 8:CPDAT41, 11:4, 12:E12, 13:Seam12
;Second Sector
;Arc Ignition
FOLD LIN P18 Vel= 2 m/s CPDAT42 ARC_ON Pgno= 7 S14 Seam13 Tool[2]:welding_torch
Base[2]:Base1;%{PE}%R 5.5.0,%MKUKATPA20,%CARC_ON,%VLIN,%P 1:LIN, 2:P18, 3:, 5:2,
7:CPDAT42, 10:4, 11:S14, 12:Seam13
;Welding performance
FOLD CIRC P19 P20 CPDAT43 ARC_OFF Pgno= 7 E13 Seam13 Tool[2]:welding_torch
Base[2]:Base1;%{PE}%R 5.5.0,%MKUKATPA20,%CARC_OFF,%VCIRC,%P 1:CIRC, 2:P19, 3:P20, 4:,
6:2, 8:CPDAT43, 11:4, 12:E13, 13:Seam13
;Third Sector
;Arc Ignition
FOLD LIN P16 Vel= 2 m/s CPDAT45 ARC_ON Pgno= 7 S15 Seam14 Tool[2]:welding_torch
Base[2]:Base1;%{PE}%R 5.5.0,%MKUKATPA20,%CARC_ON,%VLIN,%P 1:LIN, 2:P16, 3:, 5:2,
7:CPDAT45, 10:4, 11:S15, 12:Seam14
;Welding performance
FOLD CIRC P17 P18 CPDAT46 ARC_OFF Pgno= 7 E14 Seam14 Tool[2]:welding_torch
Base[2]:Base1;%{PE}%R 5.5.0,%MKUKATPA20,%CARC_OFF,%VCIRC,%P 1:CIRC, 2:P17, 3:P18, 4:,
6:2, 8:CPDAT46, 11:4, 12:E14, 13:Seam14
;Fourth Sector
;Arc Ignition
54
Appendix
FOLD LIN P20 Vel= 2 m/s CPDAT48 ARC_ON Pgno= 7 S16 Seam15 Tool[2]:welding_torch
Base[2]:Base1;%{PE}%R 5.5.0,%MKUKATPA20,%CARC_ON,%VLIN,%P 1:LIN, 2:P20, 3:, 5:2,
7:CPDAT48, 10:4, 11:S16, 12:Seam15
;Welding performance
FOLD CIRC P11 P12 CPDAT49 ARC_OFF Pgno= 7 E15 Seam15 Tool[2]:welding_torch
Base[2]:Base1;%{PE}%R 5.5.0,%MKUKATPA20,%CARC_OFF,%VCIRC,%P 1:CIRC, 2:P11, 3:P12, 4:,
6:2, 8:CPDAT49, 11:4, 12:E15, 13:Seam15
;First Sector
;Arc Ignition
FOLD LIN P23 Vel= 2 m/s CPDAT16 ARC_ON Pgno= 8 S7 Seam7 Tool[2]:welding_torch
Base[2]:Base1;%{PE}%R 5.5.0,%MKUKATPA20,%CARC_ON,%VLIN,%P 1:LIN, 2:P23, 3:, 5:2,
7:CPDAT16, 10:11, 11:S7, 12:Seam7
;Welding performance
;Second Sector
;Arc Ignition
FOLD LIN P30 Vel= 2 m/s CPDAT19 ARC_ON Pgno= 8 S8 Seam8 Tool[2]:welding_torch
Base[2]:Base1;%{PE}%R 5.5.0,%MKUKATPA20,%CARC_ON,%VLIN,%P 1:LIN, 2:P30, 3:, 5:2,
7:CPDAT19, 10:11, 11:S8, 12:Seam8
;Welding performance
55
Appendix
;Third Sector
;Arc Ignition
FOLD LIN P36 Vel= 2 m/s CPDAT23 ARC_ON Pgno= 8 S9 Seam9 Tool[2]:welding_torch
Base[2]:Base1;%{PE}%R 5.5.0,%MKUKATPA20,%CARC_ON,%VLIN,%P 1:LIN, 2:P36, 3:, 5:2,
7:CPDAT23, 10:11, 11:S9, 12:Seam9
;Welding Performance
;Fourth Sector
;Arc Ignition
FOLD LIN P42 Vel= 2 m/s CPDAT26 ARC_ON Pgno= 8 S10 Seam10 Tool[2]:welding_torch
Base[2]:Base1;%{PE}%R 5.5.0,%MKUKATPA20,%CARC_ON,%VLIN,%P 1:LIN, 2:P42, 3:, 5:2,
7:CPDAT26, 10:11, 11:S10, 12:Seam10
;Weldign performance
;Vertical beam
56
Appendix
;First weld
;Arc Ignition
FOLD LIN P49 Vel= 2 m/s CPDAT29 ARC_ON Pgno= 6 S11 Seam11 Tool[2]:welding_torch
Base[2]:Base1;%{PE}%R 5.5.0,%MKUKATPA20,%CARC_ON,%VLIN,%P 1:LIN, 2:P49, 3:, 5:2,
7:CPDAT29, 10:4, 11:S11, 12:Seam11
;Welding performance
;Second weld
;Arc Ignition
FOLD LIN P55 Vel= 2 m/s CPDAT32 ARC_ON Pgno= 6 S12 Seam12 Tool[2]:welding_torch
Base[2]:Base1;%{PE}%R 5.5.0,%MKUKATPA20,%CARC_ON,%VLIN,%P 1:LIN, 2:P55, 3:, 5:2,
7:CPDAT32, 10:4, 11:S12, 12:Seam12;
Welding performance
;Final Position
END
57
Appendix
DEF Cleaner( )
;FOLD INI
;WIRECUTTING
58
Appendix
;LUBRICATION
END
59
Appendix
*****************************
*****************************
*** Close any possible acquirement device that could remain open***
close_all_framegrabbers()
CalTabDescrFile := 'caltab_70mm.descr'
StartCamPar := [0.0416569701915549,0,1.09711074971488e-005,1.1e-
005,1155.47676730987,782.699003739001,2048,1536]
***Acquirement Initialization***
dev_close_window ()
dev_update_off ()
dev_set_draw ('margin')
dev_set_line_width (3)
NumImages := 10
60
Appendix
for I := 1 to NumImages by 1
grab_image(Image,AcqHandle)
dev_display (Image)
dev_set_color ('green')
dev_display (Contours)
dev_set_color ('red')
dev_display (Cross)
stop ()
endfor
***CAMERA CALIBRATION***
write_cam_par(CamParam,'UeyeParam.dat')
close_framegrabber(AcqHandle)
******************************************
******************************************
61
Appendix
dev_update_off ()
close_all_framegrabbers()
read_cam_par('UeyeParam.dat', CamParam)
Width := CamParam[6]/4
Height := CamParam[7]/4
dev_close_window ()
dev_update_off ()
***Acquirement Initialization***
*** Prepare the object model for the use within the 3d shape-based matching***
disp_message (WindowHandle,'Reading the 3D shape model file from disk ...' , 'window',
12, 12, 'black', 'true')
try
read_shape_model_3d('Test1_Shape_Model.sm3',ShapeModel3DID)
catch(Exception)
62
Appendix
disp_message (WindowHandle, 'Reading the 3D shape model file from disk ...File
not found', 'window', 12, 12, 'black', 'true')
Message := 'Creating the 3D shape model (may take several minutes) ...'
count_seconds (S1)
write_shape_model_3d(ShapeModel3DID, 'Test1_Shape_Model.sm3')
count_seconds (S2)
T := S2 - S1
disp_message (WindowHandle, 'Creation time: ' + T$'.3' + ' s', 'window', 92, 12,
'black', 'false')
endtry
disp_continue_message(WindowHandle, 'black','true')
stop()
clear_object_model_3d (ObjectModel3DID)
Times := []
for ImageNo := 1 to 4 by 1
grab_image(Image, AcqHandle)
dev_display (Image)
count_seconds (Seconds1)
count_seconds (Seconds2)
Times := [Times,Time]
for I := 0 to |Score| - 1 by 1
write_pose(PoseTmp,'Test1_Pose.dat')
63
Appendix
dev_set_color ('green')
dev_display (ModelContours)
dev_set_color ('red')
endfor
if (ImageNo<4)
stop ()
dev_clear_window()
endif
endfor
close_all_framegrabbers()
stop ()
clear_shape_model_3d (ShapeModel3DID)
******************************************
******************************************
dev_update_off ()
64
Appendix
close_all_framegrabbers()
Width := CamParam[6]/4
Height := CamParam[7]/4
dev_close_window ()
dev_update_off ()
disp_object_model_3d(WindowHandle, ObjectModel3DID,CamParam,[],[],[])
stop()
*** Prepare the object model for the use within the 3d shape-based matching***
dev_clear_window ()
try
65
Appendix
read_shape_model_3d('C:/Documents and
Settings/acro/Desktop/SmartFactory/matching/Cylinder/Piece1_Shape_Model_new_ca
libration.sm3',ShapeModel3DID)
catch(Exception)
disp_continue_message(WindowHandle, 'black','true')
stop()
grab_image(Image, AcqHandle)
dev_display(Image)
stop()
*** Inspect the 3D object model and specify the desired pose range
dev_clear_window ()
Message := 'Creating the 3D shape model (may take several minutes) ...'
count_seconds (S1)
count_seconds (S2)
write_shape_model_3d(ShapeModel3DID, 'Piece1_Shape_Model_new_calibration.sm3')
T := S2 - S1
disp_message (WindowHandle, 'Creation time: ' + T$'.3' + ' s', 'window', 102,
12, 'black', 'false')
endtry
disp_continue_message(WindowHandle, 'black','true')
stop()
66
Appendix
clear_object_model_3d (ObjectModel3DID)
Times := []
for ImageNo := 1 to 50 by 1
grab_image(Image, AcqHandle)
dev_display(Image)
count_seconds (Seconds1)
count_seconds (Seconds2)
Time:=Seconds2-Seconds1
Times := [Times,Time]
*** the 3D shape model into it using the pose of the match***
for I := 0 to |Score| - 1 by 1
***Display Contours***
pose_to_hom_mat3d(PoseTmp,obj_H_cam)
hom_mat3d_identity(HomMat3DIdentity)
hom_mat3d_translate_local(HomMat3DIdentity,0.024,0.048,0.024,HomMat3D_R
)
hom_mat3d_rotate_local(HomMat3D_T,1.570796327,'x',HomMat3D_T_R)
hom_mat3d_to_pose(obj_H_cam,PoseTmp1)
write_pose(PoseTmp1,'CylinderinCam_Pose.dat')
dev_set_color ('green')
dev_display (ModelContours)
67
Appendix
dev_set_color ('red')
endfor
if (ImageNo<50)
stop ()
dev_clear_window()
endif
endfor
stop ()
clear_shape_model_3d (ShapeModel3DID)
local_IP_adres:='10.10.107.20'
remote_IP_adres:='10.10.107.25'
Local_port_number:=9901
Remote_port_number:=9901
TCP_or_UDP:='TCP'
Timeout=200
close_all_framegrabbers()
68
Appendix
dev_close_window ()
for i := 1 to 100 by 1
grab_image(Image,AcqHandle)
*Recieve data
tuple_number(Rob_X,Rob_X)
tuple_number(Rob_Y,Rob_Y)
tuple_number(Rob_Z,Rob_Z)
tuple_number(Rob_A,Rob_A)
69
Appendix
tuple_number(Rob_B,Rob_B)
tuple_number(Rob_C,Rob_C)
write_pose(Robot_Pose,'Robot_Pose' + i$'002'+'.dat')
disp_continue_message(WindowHandle,'black','true')
dev_display(Image)
stop()
dev_clear_window()
endfor
*Close framegrabber
close_framegrabber (AcqHandle)
*Close Socket
close_socket(Socket)
***********************************************************
***********************************************************
dev_update_off ()
NumImages :=12
* Read image
70
Appendix
dev_close_window ()
dev_set_line_width (2)
dev_set_draw ('margin')
CalTabFile := 'caltab_70mm.descr'
stop ()
for I := 0 to NumImages-1 by 1
dev_display (Image)
* Search for the calibration plate, extract the marks and the
* pose of it, and store the results in the calibration data model of the
* hand-eye calibration
* Visualize the extracted calibration marks and the estimated pose (coordinate
system)
dev_set_color ('green')
dev_display (Image)
71
Appendix
dev_display (Caltab)
dev_set_color ('yellow')
dev_set_colored (3)
Rob_X:=ToolInBasePose[0]/1000
Rob_Y:=ToolInBasePose[1]/1000
Rob_Z:=ToolInBasePose[2]/1000
* Set the pose tool in robot base coordinates in the calibration data model
stop ()
endfor
disp_message (WindowHandle, 'All relevant data has been set in the calibration data
model', 'window', 12, 12, 'black', 'true')
stop ()
dev_display (Image)
72
Appendix
stop ()
clear_calib_data (CalibDataID)
remote_IP_address:='10.10.107.25'
port:=9901
timeout:=200
pose_to_hom_mat3d(PoseBaseinCam,Cam_H_RobBase)
read_pose('C:/Documents and
Settings/acro/Desktop/SmartFactory/matching/Cylinder/Cylinder47mminCam_Pose.dat',
PoseCylinderinCam)
pose_to_hom_mat3d(PoseCylinderinCam,Cam_H_Cylinder)
*Do transformation to obtain coordinate of the cylinder in robot base coordinate system
hom_mat3d_invert(Cam_H_RobBase,RobBase_H_Cam)
hom_mat3d_compose(RobBase_H_Cam,Cam_H_Cylinder,RobBase_H_Cylinder)
hom_mat3d_to_pose(RobBase_H_Cylinder,Pose_Cylinder_in_RobBase)
* Set Offsets
Pose_Cylinder_in_RobBase[0]:=(Pose_Cylinder_in_RobBase[0]-0.0045)*1000
Pose_Cylinder_in_RobBase[1]:=(Pose_Cylinder_in_RobBase[1]-0.0025)*1000
Pose_Cylinder_in_RobBase[2]:=(Pose_Cylinder_in_RobBase[2]+0.0041)*1000
Change:=Pose_Cylinder_in_RobBase[5]
Pose_Cylinder_in_RobBase[5]:=Pose_Cylinder_in_RobBase[3]
73
Appendix
Pose_Cylinder_in_RobBase[3]:= Change
convert_pose_type(Pose_Cylinder_in_RobBase,'Rp+T','abg','point',Pose_Cylinder_in_RobB
ase)
write_pose(Pose_Cylinder_in_RobBase,'CylinderinrobBase_Pose.dat')
tuple_string(Pose_Cylinder_in_RobBase,'-',Cylinder_RobBase_String)
*sending data
*closing socket
close_socket(Socket)
A5.1. CamParam.calc
# <pargroup_description>;
74
Appendix
# <description>;
# =========================================================================
##############################################################################
# Camera : Parameter
# > Focus
# > Kappa
# > Sx
# > Sy
# > Cx
# > Cy
# > ImageWidth
# > ImageHeight
##############################################################################
Focus:foc: 0.0267014393180477;
DOUBLE:0.0:;
Kappa:kappa: -273.173782923715;
DOUBLE::;
Sx:sx: 3.19209913486419e-006;
DOUBLE:0.0:;
Sy:sy: 3.2e-006;
DOUBLE:0.0:;
Cx:cx: 1174.32362533896;
DOUBLE::;
75
Appendix
Cy:cy: 595.948638426092;
DOUBLE::;
ImageWidth:imgw: 2048;
INT:1:32768;
ImageHeight:imgh: 1536;
INT:1:32768;
A5.2. Cam_Pose.dat
f 0
A6.1. Acquirement.vb
Option Strict Off
Option Explicit
Imports HalconDotNet
Module HDevelopExportAcquirement
76
Appendix
End Sub
ho_Image.Dispose()
HOperatorSet.GrabImage(ho_Image, hv_AcqHandle)
HOperatorSet.DispObj(ho_Image, hv_ExpDefaultWinHandle)
HDevelopStopAcq()
HOperatorSet.CloseFramegrabber(hv_AcqHandle)
ho_Image.Dispose()
End Sub
Sub InitHalcon()
' Default settings used in HDevelop
Call HOperatorSet.SetSystem(New HTuple("width"), New HTuple(512))
End Sub
End Module
A6.2. ShapeModelCreation.vb
77
Appendix
Option Explicit On
Imports HalconDotNet
Module HDevelopExportShapeModelCreation
' Procedures
' External procedures
' Chapter: Develop
' Short Description: Switch dev_update_pc, dev_update_var and dev_update_window
to 'off'.
Public Sub dev_update_off()
' Initialize local and output iconic variables
Exit Sub
End Sub
78
Appendix
hv_Column_COPY_INP_TMP = hv_Column.Clone()
Dim hv_Row_COPY_INP_TMP As HTuple
hv_Row_COPY_INP_TMP = hv_Row.Clone()
Dim hv_String_COPY_INP_TMP As HTuple
hv_String_COPY_INP_TMP = hv_String.Clone()
79
Appendix
hv_FactorColumn = (((New
HTuple(1.0)).TupleMult(hv_WidthWin))).TupleDiv(((hv_Column2Part.TupleSub( _
hv_Column1Part))).TupleAdd(New HTuple(1)))
hv_R1 = ((((hv_Row_COPY_INP_TMP.TupleSub(hv_Row1Part))).TupleAdd(New
HTuple(0.5)))).TupleMult( _
hv_FactorRow)
hv_C1 =
((((hv_Column_COPY_INP_TMP.TupleSub(hv_Column1Part))).TupleAdd(New
HTuple(0.5)))).TupleMult( _
hv_FactorColumn)
End If
'
'display text box depending on text size
If New HTuple(hv_Box.TupleEqual(New HTuple("true"))).I() Then
'calculate box extents
hv_String_COPY_INP_TMP = (((New HTuple("
")).TupleAdd(hv_String_COPY_INP_TMP))).TupleAdd( _
New HTuple(" "))
hv_Width = New HTuple()
For hv_Index = (New HTuple(0)) To ((New
HTuple(hv_String_COPY_INP_TMP.TupleLength( _
)))).TupleSub(New HTuple(1)) Step (New HTuple(1))
HOperatorSet.GetStringExtents(hv_WindowHandle,
hv_String_COPY_INP_TMP.TupleSelect( _
hv_Index), hv_Ascent, hv_Descent, hv_W, hv_H)
hv_Width = hv_Width.TupleConcat(hv_W)
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
' so that it can handle events in a standard way.
System.Windows.Forms.Application.DoEvents()
#End If
Next
hv_FrameHeight = hv_MaxHeight.TupleMult(New
HTuple(hv_String_COPY_INP_TMP.TupleLength( _
)))
hv_FrameWidth = (((New HTuple(0)).TupleConcat(hv_Width))).TupleMax()
hv_R2 = hv_R1.TupleAdd(hv_FrameHeight)
hv_C2 = hv_C1.TupleAdd(hv_FrameWidth)
'display rectangles
HOperatorSet.GetDraw(hv_ExpDefaultWinHandle, hv_DrawMode)
HOperatorSet.SetDraw(hv_ExpDefaultWinHandle, New HTuple("fill"))
HOperatorSet.SetColor(hv_ExpDefaultWinHandle, New HTuple("light gray"))
HOperatorSet.DispRectangle1(hv_ExpDefaultWinHandle, hv_R1.TupleAdd(New
HTuple(3)), _
hv_C1.TupleAdd(New HTuple(3)), hv_R2.TupleAdd(New HTuple(3)),
hv_C2.TupleAdd( _
New HTuple(3)))
HOperatorSet.SetColor(hv_ExpDefaultWinHandle, New HTuple("white"))
HOperatorSet.DispRectangle1(hv_ExpDefaultWinHandle, hv_R1, hv_C1, hv_R2,
hv_C2)
HOperatorSet.SetDraw(hv_ExpDefaultWinHandle, hv_DrawMode)
ElseIf New HTuple(hv_Box.TupleNotEqual(New HTuple("false"))).I() Then
hv_Exception = New HTuple("Wrong value of control parameter Box")
Throw New HalconException(hv_Exception)
End If
'Write text.
For hv_Index = (New HTuple(0)) To ( _
(New HTuple(hv_String_COPY_INP_TMP.TupleLength()))).TupleSub(New
HTuple(1)) Step (New HTuple(1))
hv_CurrentColor = hv_Color_COPY_INP_TMP.TupleSelect(hv_Index.TupleMod(New
HTuple( _
hv_Color_COPY_INP_TMP.TupleLength())))
If ((New HTuple(hv_CurrentColor.TupleNotEqual(New
HTuple(""))))).TupleAnd(New HTuple( _
80
Appendix
Exit Sub
End Sub
'This procedure sets the text font of the current window with
'the specified attributes.
'It is assumed that following fonts are installed on the system:
'Windows: Courier New, Arial Times New Roman
'Mac OS X: CourierNewPS, Arial, TimesNewRomanPS
'Linux: courier, helvetica, times
'Because fonts are displayed smaller on Linux than on Windows,
'a scaling factor of 1.25 is used the get comparable results.
'For Linux, only a limited number of font sizes is supported,
81
Appendix
82
Appendix
HDevExpDefaultException1.ToHTuple(hv_Exception)
'throw (Exception)
End Try
ElseIf New HTuple(((hv_OS.TupleSubstr(New HTuple(0), New
HTuple(2)))).TupleEqual( _
New HTuple("Dar"))).I() Then
'Set font on Mac OS X systems
If New HTuple(hv_Bold_COPY_INP_TMP.TupleEqual(New HTuple("true"))).I()
Then
hv_BoldString = New HTuple("Bold")
ElseIf New HTuple(hv_Bold_COPY_INP_TMP.TupleEqual(New
HTuple("false"))).I() Then
hv_BoldString = New HTuple("")
Else
hv_Exception = New HTuple("Wrong value of control parameter Bold")
Throw New HalconException(hv_Exception)
End If
If New HTuple(hv_Slant_COPY_INP_TMP.TupleEqual(New HTuple("true"))).I()
Then
hv_SlantString = New HTuple("Italic")
ElseIf New HTuple(hv_Slant_COPY_INP_TMP.TupleEqual(New
HTuple("false"))).I() Then
hv_SlantString = New HTuple("")
Else
hv_Exception = New HTuple("Wrong value of control parameter Slant")
Throw New HalconException(hv_Exception)
End If
If ((((New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("mono"))))).TupleOr( _
New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("Courier")))))).TupleOr( _
New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("courier")))).I() Then
hv_Font_COPY_INP_TMP = New HTuple("CourierNewPS")
ElseIf New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("sans"))).I() Then
hv_Font_COPY_INP_TMP = New HTuple("Arial")
ElseIf New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("serif"))).I() Then
hv_Font_COPY_INP_TMP = New HTuple("TimesNewRomanPS")
End If
If ((New HTuple(hv_Bold_COPY_INP_TMP.TupleEqual(New
HTuple("true"))))).TupleOr( _
New HTuple(hv_Slant_COPY_INP_TMP.TupleEqual(New HTuple("true")))).I()
Then
hv_Font_COPY_INP_TMP = ((((hv_Font_COPY_INP_TMP.TupleAdd(New
HTuple("-")))).TupleAdd( _
hv_BoldString))).TupleAdd(hv_SlantString)
End If
hv_Font_COPY_INP_TMP = hv_Font_COPY_INP_TMP.TupleAdd(New HTuple("MT"))
Try
HOperatorSet.SetFont(hv_WindowHandle,
((hv_Font_COPY_INP_TMP.TupleAdd( _
New HTuple("-")))).TupleAdd(hv_Size_COPY_INP_TMP))
' catch (Exception)
Catch HDevExpDefaultException1 As HalconException
HDevExpDefaultException1.ToHTuple(hv_Exception)
'throw (Exception)
End Try
Else
'Set font for UNIX systems
hv_Size_COPY_INP_TMP = hv_Size_COPY_INP_TMP.TupleMult(New HTuple(1.25))
hv_AllowedFontSizes = (((((New
HTuple(11)).TupleConcat(14)).TupleConcat(17)).TupleConcat( _
20)).TupleConcat(25)).TupleConcat(34)
83
Appendix
If New
HTuple(((hv_AllowedFontSizes.TupleFind(hv_Size_COPY_INP_TMP))).TupleEqual( _
New HTuple(-1))).I() Then
hv_Distances =
((hv_AllowedFontSizes.TupleSub(hv_Size_COPY_INP_TMP))).TupleAbs( _
)
HOperatorSet.TupleSortIndex(hv_Distances, hv_Indices)
hv_Size_COPY_INP_TMP =
hv_AllowedFontSizes.TupleSelect(hv_Indices.TupleSelect( _
New HTuple(0)))
End If
If ((New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("mono"))))).TupleOr( _
New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("Courier")))).I() Then
hv_Font_COPY_INP_TMP = New HTuple("courier")
ElseIf New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("sans"))).I() Then
hv_Font_COPY_INP_TMP = New HTuple("helvetica")
ElseIf New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("serif"))).I() Then
hv_Font_COPY_INP_TMP = New HTuple("times")
End If
If New HTuple(hv_Bold_COPY_INP_TMP.TupleEqual(New HTuple("true"))).I()
Then
hv_Bold_COPY_INP_TMP = New HTuple("bold")
ElseIf New HTuple(hv_Bold_COPY_INP_TMP.TupleEqual(New
HTuple("false"))).I() Then
hv_Bold_COPY_INP_TMP = New HTuple("medium")
Else
hv_Exception = New HTuple("Wrong value of control parameter Bold")
Throw New HalconException(hv_Exception)
End If
If New HTuple(hv_Slant_COPY_INP_TMP.TupleEqual(New HTuple("true"))).I()
Then
If New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("times"))).I() Then
hv_Slant_COPY_INP_TMP = New HTuple("i")
Else
hv_Slant_COPY_INP_TMP = New HTuple("o")
End If
ElseIf New HTuple(hv_Slant_COPY_INP_TMP.TupleEqual(New
HTuple("false"))).I() Then
hv_Slant_COPY_INP_TMP = New HTuple("r")
Else
hv_Exception = New HTuple("Wrong value of control parameter Slant")
Throw New HalconException(hv_Exception)
End If
Try
HOperatorSet.SetFont(hv_WindowHandle, (((((((((((((((New HTuple("-
adobe-")).TupleAdd( _
hv_Font_COPY_INP_TMP))).TupleAdd(New HTuple("-
")))).TupleAdd(hv_Bold_COPY_INP_TMP))).TupleAdd( _
New HTuple("-")))).TupleAdd(hv_Slant_COPY_INP_TMP))).TupleAdd(New
HTuple("-normal-*-")))).TupleAdd( _
hv_Size_COPY_INP_TMP))).TupleAdd(New HTuple("-*-*-*-*-*-*-*")))
' catch (Exception)
Catch HDevExpDefaultException1 As HalconException
HDevExpDefaultException1.ToHTuple(hv_Exception)
If ((New HTuple(((hv_OS.TupleSubstr(New HTuple(0), New
HTuple(4)))).TupleEqual( _
New HTuple("Linux"))))).TupleAnd(New
HTuple(hv_Font_COPY_INP_TMP.TupleEqual( _
New HTuple("courier")))).I() Then
HOperatorSet.QueryFont(hv_ExpDefaultWinHandle, hv_Fonts)
84
Appendix
Exit Sub
End Sub
85
Appendix
Try
'Generate the menu buttons
If ((New HTuple(hv_TopBottom.TupleNotEqual(New
HTuple("top"))))).TupleAnd(New HTuple( _
hv_TopBottom.TupleNotEqual(New HTuple("bottom")))).I() Then
HDevelopStop()
'Wrong parameter: TopBottom must be 'top' or 'bottom'
End If
HOperatorSet.GetPart(hv_WindowHandle, hv_PartRow1, hv_PartCol1,
hv_PartRow2, _
hv_PartCol2)
hv_Height = ((hv_PartRow2.TupleSub(hv_PartRow1))).TupleAdd(New HTuple(1))
hv_Width = ((hv_PartCol2.TupleSub(hv_PartCol1))).TupleAdd(New HTuple(1))
hv_MenuHeight = ((hv_Height.TupleMult(hv_PercentageHeight))).TupleDiv(New
HTuple(100.0))
hv_MenuWidth = hv_Width.Clone()
hv_ButtonHeight = hv_MenuHeight.TupleDiv(hv_NumRows)
hv_ButtonWidth = hv_MenuWidth.TupleDiv(hv_NumCols)
If New HTuple(hv_TopBottom.TupleEqual(New HTuple("top"))).I() Then
hv_Row0 = hv_PartRow1.Clone()
End If
If New HTuple(hv_TopBottom.TupleEqual(New HTuple("bottom"))).I() Then
hv_Row0 = hv_PartRow2.TupleSub(hv_MenuHeight)
End If
hv_Col0 = hv_PartCol1.Clone()
ho_MenuRegions.Dispose()
HOperatorSet.GenEmptyObj(ho_MenuRegions)
For hv_c = (New HTuple(0)) To hv_NumCols.TupleSub( _
New HTuple(1)) Step (New HTuple(1))
For hv_r = (New HTuple(0)) To hv_NumRows.TupleSub( _
New HTuple(1)) Step (New HTuple(1))
ho_Rectangle.Dispose()
HOperatorSet.GenRectangle1(ho_Rectangle,
hv_Row0.TupleAdd(hv_r.TupleMult( _
hv_ButtonHeight)),
hv_Col0.TupleAdd(hv_c.TupleMult(hv_ButtonWidth)), _
((((hv_Row0.TupleAdd(hv_r.TupleMult(hv_ButtonHeight)))).TupleAdd(hv_ButtonHeight))).T
upleSub( _
New HTuple(1)),
((((hv_Col0.TupleAdd(hv_c.TupleMult(hv_ButtonWidth)))).TupleAdd( _
hv_ButtonWidth))).TupleSub(New HTuple(1)))
HOperatorSet.ConcatObj(ho_MenuRegions, ho_Rectangle, OTemp(0))
ho_MenuRegions.Dispose()
ho_MenuRegions = OTemp(0)
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
' so that it can handle events in a standard way.
System.Windows.Forms.Application.DoEvents()
#End If
Next
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
' so that it can handle events in a standard way.
System.Windows.Forms.Application.DoEvents()
#End If
Next
ho_Rectangle.Dispose()
Exit Sub
Catch HDevExpDefaultException As HalconException
ho_Rectangle.Dispose()
86
Appendix
Throw HDevExpDefaultException
End Try
End Sub
Try
HOperatorSet.CountObj(ho_MenuRegions, hv_NumberRegions)
hv_NumberTexts = New HTuple(hv_Texts.TupleLength())
If New HTuple(hv_NumberRegions.TupleNotEqual(hv_NumberTexts)).I() Then
HDevelopStop()
'Wrong number of regions or texts
End If
hv_SelectedButton = New HTuple("")
' (dev_)set_check ("~give_error")
For hv_i = (New HTuple(1)) To hv_NumberRegions Step (New HTuple(1))
Try
ho_MenuRegion.Dispose()
HOperatorSet.SelectObj(ho_MenuRegions, ho_MenuRegion, hv_i)
Catch e As HalconException
Dim err As Integer
err = e.GetErrorNumber()
If err < 0 Then
Throw e
End If
End Try
Try
HOperatorSet.TestRegionPoint(ho_MenuRegion, hv_Row, hv_Col,
hv_IsInside)
Catch e As HalconException
Dim err As Integer
err = e.GetErrorNumber()
If err < 0 Then
Throw e
End If
End Try
If hv_IsInside.I() Then
hv_SelectedButton = hv_Texts.TupleSelect(hv_i.TupleSub(New
HTuple(1)))
End If
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
' so that it can handle events in a standard way.
87
Appendix
System.Windows.Forms.Application.DoEvents()
#End If
Next
' (dev_)set_check ("give_error")
ho_MenuRegion.Dispose()
Exit Sub
Catch HDevExpDefaultException As HalconException
ho_MenuRegion.Dispose()
Throw HDevExpDefaultException
End Try
End Sub
Try
'Display the previously created menu buttons
HOperatorSet.CountObj(ho_MenuRegions, hv_NumberRegions)
hv_NumberTexts = New HTuple(hv_Texts.TupleLength())
If New HTuple(hv_NumberRegions.TupleNotEqual(hv_NumberTexts)).I() Then
HDevelopStop()
'Wrong number of regions or texts
End If
For hv_i = (New HTuple(1)) To hv_NumberRegions Step (New HTuple(1))
ho_MenuRegion.Dispose()
HOperatorSet.SelectObj(ho_MenuRegions, ho_MenuRegion, hv_i)
disp_menu_button(ho_MenuRegion, hv_WindowHandle,
hv_Texts.TupleSelect(hv_i.TupleSub( _
New HTuple(1))))
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
' so that it can handle events in a standard way.
System.Windows.Forms.Application.DoEvents()
#End If
Next
ho_MenuRegion.Dispose()
Exit Sub
Catch HDevExpDefaultException As HalconException
ho_MenuRegion.Dispose()
Throw HDevExpDefaultException
End Try
End Sub
88
Appendix
Try
'Generate a contour in form of a arrow
hv_Length = New HTuple(7)
hv_Angle = New HTuple(40)
hv_MinArrowLength = New HTuple(2)
hv_DRow = hv_Row2.TupleSub(hv_Row1)
hv_DCol = hv_Column2.TupleSub(hv_Column1)
hv_ArrowLength =
((((hv_DRow.TupleMult(hv_DRow))).TupleAdd(hv_DCol.TupleMult( _
hv_DCol)))).TupleSqrt()
If New HTuple(hv_ArrowLength.TupleLess(hv_MinArrowLength)).I() Then
hv_Length = New HTuple(0)
End If
HOperatorSet.TupleAtan2(hv_DRow, hv_DCol.TupleNeg(), hv_Phi)
hv_P1R =
hv_Row2.TupleSub(hv_Length.TupleMult(((hv_Phi.TupleSub(hv_Angle.TupleRad( _
)))).TupleSin()))
hv_P1C =
hv_Column2.TupleAdd(hv_Length.TupleMult(((hv_Phi.TupleSub(hv_Angle.TupleRad( _
)))).TupleCos()))
hv_P2R =
hv_Row2.TupleSub(hv_Length.TupleMult(((hv_Phi.TupleAdd(hv_Angle.TupleRad( _
)))).TupleSin()))
hv_P2C =
hv_Column2.TupleAdd(hv_Length.TupleMult(((hv_Phi.TupleAdd(hv_Angle.TupleRad( _
)))).TupleCos()))
ho_Cross1.Dispose()
HOperatorSet.GenCrossContourXld(ho_Cross1, hv_Row1, hv_Column1, New
HTuple(6), _
New HTuple(0.785398))
ho_Cross2.Dispose()
HOperatorSet.GenCrossContourXld(ho_Cross2, hv_Row2, hv_Column2, New
HTuple(6), _
New HTuple(0.785398))
ho_CrossP1.Dispose()
HOperatorSet.GenCrossContourXld(ho_CrossP1, hv_P1R, hv_P1C, New
HTuple(6), New HTuple(0.785398))
ho_CrossP2.Dispose()
HOperatorSet.GenCrossContourXld(ho_CrossP2, hv_P2R, hv_P2C, New
HTuple(6), New HTuple(0.785398))
89
Appendix
ho_Arrow.Dispose()
HOperatorSet.GenContourPolygonXld(ho_Arrow,
((((((hv_Row1.TupleConcat(hv_Row2))).TupleConcat( _
hv_P1R))).TupleConcat(hv_Row2))).TupleConcat(hv_P2R),
((((((hv_Column1.TupleConcat( _
hv_Column2))).TupleConcat(hv_P1C))).TupleConcat(hv_Column2))).TupleConcat( _
hv_P2C))
ho_Cross1.Dispose()
ho_Cross2.Dispose()
ho_CrossP1.Dispose()
ho_CrossP2.Dispose()
Exit Sub
Catch HDevExpDefaultException As HalconException
ho_Cross1.Dispose()
ho_Cross2.Dispose()
ho_CrossP1.Dispose()
ho_CrossP2.Dispose()
Throw HDevExpDefaultException
End Try
End Sub
' Chapter: Matching-3D
' Short Description: Compute the vector cross product
Public Sub tuple_vector_cross_product(ByVal hv_V1 As HTuple, ByVal hv_V2 As
HTuple, _
ByRef hv_VC As HTuple)
'The caller must ensure that the length of both input vectors is 3
hv_VC = ((((hv_V1.TupleSelect(New
HTuple(1)))).TupleMult(hv_V2.TupleSelect(New HTuple(2))))).TupleSub( _
((hv_V1.TupleSelect(New HTuple(2)))).TupleMult(hv_V2.TupleSelect(New
HTuple(1))))
hv_VC = hv_VC.TupleConcat(((((hv_V1.TupleSelect(New
HTuple(2)))).TupleMult(hv_V2.TupleSelect( _
New HTuple(0))))).TupleSub(((hv_V1.TupleSelect(New
HTuple(0)))).TupleMult(hv_V2.TupleSelect( _
New HTuple(2)))))
hv_VC = hv_VC.TupleConcat(((((hv_V1.TupleSelect(New
HTuple(0)))).TupleMult(hv_V2.TupleSelect( _
New HTuple(1))))).TupleSub(((hv_V1.TupleSelect(New
HTuple(1)))).TupleMult(hv_V2.TupleSelect( _
New HTuple(0)))))
Exit Sub
End Sub
90
Appendix
91
Appendix
hv_D =
((hv_D.TupleConcat(((((hv_P6.TupleSub(hv_ReferencePoint))).TupleMult(hv_P6.TupleSub(
_
hv_ReferencePoint)))).TupleSum()))).TupleMax()
hv_D =
((hv_D.TupleConcat(((((hv_P7.TupleSub(hv_ReferencePoint))).TupleMult(hv_P7.TupleSub(
_
hv_ReferencePoint)))).TupleSum()))).TupleMax()
hv_D =
((hv_D.TupleConcat(((((hv_P8.TupleSub(hv_ReferencePoint))).TupleMult(hv_P8.TupleSub(
_
hv_ReferencePoint)))).TupleSum()))).TupleMax()
'
'Compute the optimum distance to make the projection cover the desired
'image part.
hv_MaxProjectionRadius = (((((New
HTuple(0.5)).TupleMult(hv_ImageCoverage))).TupleMult( _
hv_MinImageSize))).TupleMult(((((hv_CamParam.TupleSelect(New
HTuple(2)))).TupleConcat( _
hv_CamParam.TupleSelect(New HTuple(3))))).TupleMin())
hv_Aperture = hv_MaxProjectionRadius.TupleAtan2(hv_CamParam.TupleSelect(New
HTuple(0)))
hv_Dist = ((hv_D.TupleSqrt())).TupleDiv(hv_Aperture.TupleSin())
Exit Sub
End Sub
92
Appendix
Try
hv_OffsetRowOut = hv_OffsetRowIn.Clone()
hv_OffsetColOut = hv_OffsetColIn.Clone()
If New HTuple(hv_ImageNo.TupleLessEqual(New HTuple(0))).I() Then
ho_BackgroundImageTrans.Dispose()
Exit Sub
End If
HOperatorSet.GetWindowExtents(hv_WindowHandle, hv_Row1, hv_Column1,
hv_Width, _
hv_Height)
' Error variable 'hv_ErrorVar' activated
hv_ErrorVar = New HTuple(2)
HOperatorSet.HomMat2dIdentity(hv_HomMat2DIdentity)
If New HTuple(hv_Button_COPY_INP_TMP.TupleEqual(New HTuple(1))).I() Then
hv_MRow1 = hv_Row_COPY_INP_TMP.Clone()
hv_MCol1 = hv_Column_COPY_INP_TMP.Clone()
Do While New HTuple(hv_Button_COPY_INP_TMP.TupleEqual(New
HTuple(1))).I()
' (dev_)set_check ("~give_error")
Try
hv_ErrorVar = 2
HOperatorSet.GetMposition(hv_WindowHandle,
hv_Row_COPY_INP_TMP, _
hv_Column_COPY_INP_TMP, hv_Button_COPY_INP_TMP)
Catch e As HalconException
hv_ErrorVar = New HTuple(e.GetErrorNumber())
If hv_ErrorVar.I() < 0 Then
Throw e
End If
End Try
hv_Error = hv_ErrorVar.Clone()
' (dev_)set_check ("give_error")
If New HTuple(hv_Error.TupleEqual(New HTuple(2))).I() Then
hv_MRow2 = hv_Row_COPY_INP_TMP.Clone()
hv_MCol2 = hv_Column_COPY_INP_TMP.Clone()
If IsNothing(hv_OffsetRowOut) Then
hv_OffsetRowOut = New HTuple
End If
hv_OffsetRowOut(hv_ImageNo.TupleSub(New HTuple(1))) =
((((hv_OffsetRowOut.TupleSelect( _
hv_ImageNo.TupleSub(New
HTuple(1))))).TupleAdd(hv_MRow2))).TupleSub( _
hv_MRow1)
If IsNothing(hv_OffsetColOut) Then
hv_OffsetColOut = New HTuple
End If
hv_OffsetColOut(hv_ImageNo.TupleSub(New HTuple(1))) =
((((hv_OffsetColOut.TupleSelect( _
hv_ImageNo.TupleSub(New
HTuple(1))))).TupleAdd(hv_MCol2))).TupleSub( _
hv_MCol1)
HOperatorSet.SetColor(hv_WindowHandleBuffer, hv_ModelColor)
If New HTuple(hv_ImageNo.TupleGreater(New HTuple(0))).I()
Then
HOperatorSet.ClearWindow(hv_WindowHandleBuffer)
HOperatorSet.HomMat2dTranslate(hv_HomMat2DIdentity,
hv_OffsetRowOut.TupleSelect( _
hv_ImageNo.TupleSub(New HTuple(1))),
hv_OffsetColOut.TupleSelect( _
hv_ImageNo.TupleSub(New HTuple(1))),
hv_HomMat2DTranslate)
93
Appendix
ho_BackgroundImageTrans.Dispose()
HOperatorSet.AffineTransImage(ho_BackgroundImage,
ho_BackgroundImageTrans, _
hv_HomMat2DTranslate, New HTuple("constant"), New
HTuple("false"))
HOperatorSet.DispImage(ho_BackgroundImageTrans,
hv_WindowHandleBuffer)
HOperatorSet.SetTposition(hv_WindowHandleBuffer, New
HTuple(10), New HTuple(10))
HOperatorSet.WriteString(hv_WindowHandleBuffer, (New
HTuple("Image No.: ")).TupleAdd( _
hv_ImageNo.TupleString((New HTuple("2d")).S())))
Else
HOperatorSet.SetTposition(hv_WindowHandleBuffer, New
HTuple(10), New HTuple(10))
HOperatorSet.WriteString(hv_WindowHandleBuffer, New
HTuple("(No Background Image)"))
End If
HOperatorSet.SetTposition(hv_WindowHandleBuffer, New
HTuple(10), hv_Width.TupleSub( _
New HTuple(200)))
HOperatorSet.WriteString(hv_WindowHandleBuffer, New
HTuple("Mouse Mode: Move Image"))
HOperatorSet.DispXld(ho_ModelContours, hv_WindowHandleBuffer)
'Visualize the trackball if desired
If New HTuple(hv_VisualizeTrackball.TupleEqual(New
HTuple("always"))).I() Then
HOperatorSet.SetColor(hv_WindowHandleBuffer, New
HTuple("dim gray"))
HOperatorSet.DispXld(ho_TrackballContour,
hv_WindowHandleBuffer)
End If
HOperatorSet.CopyRectangle(hv_WindowHandleBuffer,
hv_WindowHandle, New HTuple(0), _
New HTuple(0), hv_Height.TupleSub(New HTuple(1)),
hv_Width.TupleSub( _
New HTuple(1)), New HTuple(0), New HTuple(0))
'
hv_MRow1 = hv_MRow2.Clone()
hv_MCol1 = hv_MCol2.Clone()
End If
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
' so that it can handle events in a standard way.
System.Windows.Forms.Application.DoEvents()
#End If
Loop
End If
ho_BackgroundImageTrans.Dispose()
Exit Sub
Catch HDevExpDefaultException As HalconException
ho_BackgroundImageTrans.Dispose()
Throw HDevExpDefaultException
End Try
End Sub
94
Appendix
95
Appendix
Try
'The procedure inspect_object_mode_3d can be used to visualize a 3d
object
'model. If the 3d object model is used to create a 3d shape mode,
'inspect_object_model_3d can also be used to find the right values for
the
'input control parameters of create_shape_model_3d. The usage is briefly
'described in the following:
'
'Three windows are opened to interact with the user. The upper left
window
'shows the current camera view of the 3d object model. If desired, one of
'several background images can be additionally visualized. In this case,
the
'background images must be passed in the input object parameter
'BackgroundImages as a tuple. If no background images are available an
empty
'tuple must be passed instead. The number of the currently displayed
'background image is displayed in the upper left image corner.
'If the current mouse mode, which is displayed in the upper right image
corner, is
'set to 'Move Camera' the mouse can be used to change the current camera
'view. The position of the camera on a virtual sphere around the 3d
object model
'can be changed by moving the mouse while holding the left mouse
'pressed. For this, a virtual trackball (displayed as a gray circle)
indicates around
'which axis the camera should be rotated. If the mouse is inside the
circle the
' camera is rotated around the x and y axis, while otherwise the rotation
is
'performed around the z axis. The distance between the 3d object model
and the
'camera can be changed by moving the mouse in vertical direction while
holding
'the right button pressed.
'If the current mouse mode is set to 'Move Image', the background image
can be
'moved by using the left mouse button. This is useful, for example, to
make an
'image of the 3d object model coincide with the current camera view. Note
that
96
Appendix
97
Appendix
'- 'Exit' exits the inspect_3d_model procedure and returns the current
values
' for the reference pose angles, the pose range, and the minimum face
angle
' These values can directly be passed to create_shape_model_3d. Note
that
' for most applications it is useful to manually extend the interval of
the
' camera roll angle to the full circle [0,360°].
'
'
'User Defines
'
'TrackballSize defines the diameter of the trackball in the image with
respect
'to the smaller image dimension.
hv_TrackballSize = New HTuple(0.8)
'
'VisualizeTrackball determines whether the Trackball shall be displayed
in
'displayed in the image. Possible values are:
' - 'always': always displays the trackball
' - 'never': never displays the trackball
' - 'on_button': displays the trackball while the mouse button is
pressed
hv_VisualizeTrackball = New HTuple("always")
'VisualizeTrackball := 'never'
'VisualizeTrackball := 'on_button'
'
'VirtualTrackball defines the type of virtual trackball that shall
'shall be used ('shoemake' or 'bell').
hv_VirtualTrackball = New HTuple("shoemake")
'VirtualTrackball := 'bell'
'
'ModelColor defines the color of the visualized model
hv_ModelColor = New HTuple("green")
'
'ImageScale defines the scaling of the displayed image. This is
especially useful
'if the original camera image is too large to fit onto the screen. If
ImageScale is
'set to 1, the image is displayed using its original size. If ImageScale
is set to
'a value smaller than 1, the displayed image will become smaller by this
factor.
hv_ImageScale = New HTuple(0.25)
'
'
'
' dev_set_preferences(...); only in hdevelop
HOperatorSet.GetSystem(New HTuple("clip_region"), hv_ClipRegion)
HOperatorSet.SetSystem(New HTuple("clip_region"), New HTuple("false"))
' dev_update_pc(...); only in hdevelop
' dev_update_window(...); only in hdevelop
' dev_update_var(...); only in hdevelop
' dev_update_time(...); only in hdevelop
hv_Deg2Rad = New HTuple(0.017453292)
'
'Apply the user defined image scaling by adapting the camera parameters
If IsNothing(hv_CamParam_COPY_INP_TMP) Then
hv_CamParam_COPY_INP_TMP = New HTuple
End If
hv_CamParam_COPY_INP_TMP(New HTuple(2)) =
((hv_CamParam_COPY_INP_TMP.TupleSelect( _
New HTuple(2)))).TupleDiv(hv_ImageScale)
98
Appendix
If IsNothing(hv_CamParam_COPY_INP_TMP) Then
hv_CamParam_COPY_INP_TMP = New HTuple
End If
hv_CamParam_COPY_INP_TMP(New HTuple(3)) =
((hv_CamParam_COPY_INP_TMP.TupleSelect( _
New HTuple(3)))).TupleDiv(hv_ImageScale)
If IsNothing(hv_CamParam_COPY_INP_TMP) Then
hv_CamParam_COPY_INP_TMP = New HTuple
End If
hv_CamParam_COPY_INP_TMP(New HTuple(4)) =
((hv_CamParam_COPY_INP_TMP.TupleSelect( _
New HTuple(4)))).TupleMult(hv_ImageScale)
If IsNothing(hv_CamParam_COPY_INP_TMP) Then
hv_CamParam_COPY_INP_TMP = New HTuple
End If
hv_CamParam_COPY_INP_TMP(New HTuple(5)) =
((hv_CamParam_COPY_INP_TMP.TupleSelect( _
New HTuple(5)))).TupleMult(hv_ImageScale)
If IsNothing(hv_CamParam_COPY_INP_TMP) Then
hv_CamParam_COPY_INP_TMP = New HTuple
End If
hv_CamParam_COPY_INP_TMP(New HTuple(6)) =
((((hv_CamParam_COPY_INP_TMP.TupleSelect( _
New HTuple(6)))).TupleMult(hv_ImageScale))).TupleInt()
If IsNothing(hv_CamParam_COPY_INP_TMP) Then
hv_CamParam_COPY_INP_TMP = New HTuple
End If
hv_CamParam_COPY_INP_TMP(New HTuple(7)) =
((((hv_CamParam_COPY_INP_TMP.TupleSelect( _
New HTuple(7)))).TupleMult(hv_ImageScale))).TupleInt()
'
'Scale the background images accordingly
HOperatorSet.ZoomImageFactor(ho_BackgroundImages_COPY_INP_TMP, OTemp(0),
hv_ImageScale, _
hv_ImageScale, New HTuple("weighted"))
ho_BackgroundImages_COPY_INP_TMP.Dispose()
ho_BackgroundImages_COPY_INP_TMP = OTemp(0)
'
hv_Width = hv_CamParam_COPY_INP_TMP.TupleSelect(New HTuple(6))
hv_Height = hv_CamParam_COPY_INP_TMP.TupleSelect(New HTuple(7))
hv_Cx = hv_CamParam_COPY_INP_TMP.TupleSelect(New HTuple(4))
hv_Cy = hv_CamParam_COPY_INP_TMP.TupleSelect(New HTuple(5))
'
hv_WidthPose = New HTuple(300)
hv_HeightPose = ((hv_Height.TupleConcat(New HTuple(480)))).TupleMax()
'
'Open a window containing the menu structure
hv_WidthMenu = ((((((hv_Width.TupleAdd(New
HTuple(7)))).TupleAdd(hv_WidthPose))).TupleConcat( _
New HTuple(840)))).TupleMax()
hv_HeightMenu = New HTuple(100)
'dev_open_window(...);
HOperatorSet.SetPart(hv_WindowHandleMenu, New HTuple(0), New HTuple(0),
hv_HeightMenu.TupleSub( _
New HTuple(1)), hv_WidthMenu.TupleSub(New HTuple(1)))
'
'Open a window containing the pose information
'dev_open_window(...);
HOperatorSet.SetPart(hv_WindowHandlePose, New HTuple(0), New HTuple(0),
hv_HeightPose.TupleSub( _
New HTuple(1)), hv_WidthPose.TupleSub(New HTuple(1)))
HOperatorSet.SetLineWidth(hv_WindowHandlePose, New HTuple(1))
'
'Open one buffer window and one visible window to avoid flickering
'dev_open_window(...);
99
Appendix
100
Appendix
101
Appendix
102
Appendix
HOperatorSet.DispXld(ho_TrackballContour, hv_WindowHandleBuffer)
End If
HOperatorSet.CopyRectangle(hv_WindowHandleBuffer, hv_WindowHandle,
New HTuple(0), _
New HTuple(0), hv_Height.TupleSub(New HTuple(1)),
hv_Width.TupleSub(New HTuple(1)), _
New HTuple(0), New HTuple(0))
'
'Update the parameter ranges
update_pose_information(hv_WindowHandlePose, hv_ObjectModel3DID,
hv_CamParam_COPY_INP_TMP, _
hv_RefPose, hv_RelQuaternion, hv_Dist, hv_LatitudeMin,
hv_LatitudeMax, _
hv_LongitudeMin, hv_LongitudeMax, hv_CamRollMin, hv_CamRollMax,
hv_DistMin, _
hv_DistMax, hv_MinFaceAngle, hv_HiddenSurfaceRemoval,
hv_ModelColor)
'
'Avoid multiple responses for a single mouse click
HOperatorSet.WaitSeconds(New HTuple(0.1))
hv_MenuEvent = New HTuple(0)
hv_GraphEvent = New HTuple(0)
Do While (New HTuple(1)).I()
' (dev_)set_check ("~give_error")
Try
hv_ErrorVar = 2
HOperatorSet.GetMposition(hv_WindowHandle, hv_GraphButtonRow,
hv_GraphButtonColumn, _
hv_GraphButton)
Catch e As HalconException
hv_ErrorVar = New HTuple(e.GetErrorNumber())
If hv_ErrorVar.I() < 0 Then
Throw e
End If
End Try
hv_ErrorGraph = hv_ErrorVar.Clone()
Try
hv_ErrorVar = 2
HOperatorSet.GetMposition(hv_WindowHandleMenu,
hv_MenuButtonRow, hv_MenuButtonColumn, _
hv_MenuButton)
Catch e As HalconException
hv_ErrorVar = New HTuple(e.GetErrorNumber())
If hv_ErrorVar.I() < 0 Then
Throw e
End If
End Try
hv_ErrorMenu = hv_ErrorVar.Clone()
' dev_update_pc(...); only in hdevelop
' (dev_)set_check ("~give_error")
If ((New HTuple(hv_ErrorGraph.TupleEqual(New
HTuple(2))))).TupleAnd(New HTuple( _
hv_GraphButton.TupleNotEqual(New HTuple(0)))).I() Then
hv_GraphEvent = New HTuple(1)
Exit Do
End If
If ((New HTuple(hv_ErrorMenu.TupleEqual(New
HTuple(2))))).TupleAnd(New HTuple( _
hv_MenuButton.TupleNotEqual(New HTuple(0)))).I() Then
hv_MenuEvent = New HTuple(1)
Exit Do
End If
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
103
Appendix
104
Appendix
hv_RefRotZ = ((hv_RefPose.TupleSelect(New
HTuple(5)))).TupleMult(hv_Deg2Rad)
'
'Clean up
Try
hv_ErrorVar = 2
HOperatorSet.SetSystem(New HTuple("clip_region"), hv_ClipRegion)
Catch e As HalconException
hv_ErrorVar = New HTuple(e.GetErrorNumber())
If hv_ErrorVar.I() < 0 Then
Throw e
End If
End Try
Try
hv_ErrorVar = 2
'close_window(...);
Catch e As HalconException
hv_ErrorVar = New HTuple(e.GetErrorNumber())
If hv_ErrorVar.I() < 0 Then
Throw e
End If
End Try
' dev_set_preferences(...); only in hdevelop
'dev_set_window(...);
'dev_close_window(...);
'dev_set_window(...);
'dev_close_window(...);
'dev_set_window(...);
'dev_close_window(...);
ho_BackgroundImages_COPY_INP_TMP.Dispose()
ho_TrackballContour.Dispose()
ho_ModelContours.Dispose()
ho_MenuRegions.Dispose()
ho_BackgroundImage.Dispose()
ho_BackgroundImageTrans.Dispose()
Exit Sub
Catch HDevExpDefaultException As HalconException
ho_BackgroundImages_COPY_INP_TMP.Dispose()
ho_TrackballContour.Dispose()
ho_ModelContours.Dispose()
ho_MenuRegions.Dispose()
ho_BackgroundImage.Dispose()
ho_BackgroundImageTrans.Dispose()
Throw HDevExpDefaultException
End Try
End Sub
105
Appendix
Exit Sub
End Sub
106
Appendix
Try
hv_Cx = hv_CamParam.TupleSelect(New HTuple(4))
hv_Cy = hv_CamParam.TupleSelect(New HTuple(5))
hv_Width = hv_CamParam.TupleSelect(New HTuple(6))
hv_Height = hv_CamParam.TupleSelect(New HTuple(7))
hv_MinImageSize = ((hv_Width.TupleConcat(hv_Height))).TupleMin()
' Error variable 'hv_ErrorVar' activated
hv_ErrorVar = New HTuple(2)
HOperatorSet.HomMat2dIdentity(hv_HomMat2DIdentity)
If New HTuple(hv_Button_COPY_INP_TMP.TupleEqual(New HTuple(1))).I() Then
hv_MRow1 = hv_Row_COPY_INP_TMP.Clone()
hv_MCol1 = hv_Column_COPY_INP_TMP.Clone()
Do While New HTuple(hv_Button_COPY_INP_TMP.TupleEqual(New
HTuple(1))).I()
' (dev_)set_check ("~give_error")
Try
hv_ErrorVar = 2
HOperatorSet.GetMposition(hv_WindowHandle,
hv_Row_COPY_INP_TMP, _
hv_Column_COPY_INP_TMP, hv_Button_COPY_INP_TMP)
Catch e As HalconException
hv_ErrorVar = New HTuple(e.GetErrorNumber())
If hv_ErrorVar.I() < 0 Then
Throw e
End If
End Try
hv_Error = hv_ErrorVar.Clone()
' (dev_)set_check ("give_error")
If New HTuple(hv_Error.TupleEqual(New HTuple(2))).I() Then
hv_MRow2 = hv_Row_COPY_INP_TMP.Clone()
107
Appendix
hv_MCol2 = hv_Column_COPY_INP_TMP.Clone()
'Transform the pixel coordinates to relative image
coordinates
hv_MX1 = ((hv_Cx.TupleSub(hv_MCol1))).TupleDiv((New
HTuple(0.5)).TupleMult( _
hv_MinImageSize))
hv_MY1 = ((hv_Cy.TupleSub(hv_MRow1))).TupleDiv((New
HTuple(0.5)).TupleMult( _
hv_MinImageSize))
hv_MX2 = ((hv_Cx.TupleSub(hv_MCol2))).TupleDiv((New
HTuple(0.5)).TupleMult( _
hv_MinImageSize))
hv_MY2 = ((hv_Cy.TupleSub(hv_MRow2))).TupleDiv((New
HTuple(0.5)).TupleMult( _
hv_MinImageSize))
'Compute the quaternion rotation that corresponds to the
mouse
'movement
trackball(hv_MX1, hv_MY1, hv_MX2, hv_MY2,
hv_VirtualTrackball, hv_TrackballSize, _
hv_DeltaQuatRotation)
'Add the incremental quaternion
HOperatorSet.QuatCompose(hv_DeltaQuatRotation,
hv_RelQuaternionIn_COPY_INP_TMP, _
hv_RelQuaternionIn_COPY_INP_TMP)
hv_NumAddOut = hv_NumAddIn.TupleAdd(New HTuple(1))
'Normalize the quaternion every 1000 additions
If New HTuple(hv_NumAddOut.TupleGreater(New
HTuple(1000))).I() Then
HOperatorSet.QuatNormalize(hv_RelQuaternionIn_COPY_INP_TMP,
hv_RelQuaternionIn_COPY_INP_TMP)
hv_NumAddOut = New HTuple(0)
End If
'Transform the quaternion to a rotation matrix
HOperatorSet.QuatToHomMat3d(hv_RelQuaternionIn_COPY_INP_TMP,
hv_RelHomMat)
HOperatorSet.PoseToHomMat3d(hv_RefPose, hv_RefHomMat)
HOperatorSet.HomMat3dCompose(hv_RelHomMat, hv_RefHomMat,
hv_AbsHomMat)
HOperatorSet.HomMat3dToPose(hv_AbsHomMat, hv_AbsPose)
If IsNothing(hv_AbsPose) Then
hv_AbsPose = New HTuple
End If
hv_AbsPose(New HTuple(2)) = ((hv_AbsPose.TupleSelect(New
HTuple(2)))).TupleAdd( _
hv_DistIn_COPY_INP_TMP)
ho_ModelContours.Dispose()
HOperatorSet.ProjectObjectModel3d(ho_ModelContours,
hv_ObjectModel3DID, _
hv_CamParam, hv_AbsPose, hv_HiddenSurfaceRemoval,
hv_MinFaceAngle)
'
HOperatorSet.ClearWindow(hv_WindowHandleBuffer)
HOperatorSet.SetColor(hv_WindowHandleBuffer, hv_ModelColor)
If New HTuple(hv_ImageNo.TupleGreater(New HTuple(0))).I()
Then
HOperatorSet.HomMat2dTranslate(hv_HomMat2DIdentity,
hv_OffsetRow.TupleSelect( _
hv_ImageNo.TupleSub(New HTuple(1))),
hv_OffsetCol.TupleSelect(hv_ImageNo.TupleSub( _
New HTuple(1))), hv_HomMat2DTranslate)
ho_BackgroundImageTrans.Dispose()
HOperatorSet.AffineTransImage(ho_BackgroundImage,
ho_BackgroundImageTrans, _
108
Appendix
109
Appendix
110
Appendix
End If
HOperatorSet.CopyRectangle(hv_WindowHandleBuffer,
hv_WindowHandle, New HTuple(0), _
New HTuple(0), hv_Height.TupleSub(New HTuple(1)),
hv_Width.TupleSub( _
New HTuple(1)), New HTuple(0), New HTuple(0))
'
hv_MRow1 = hv_MRow2.Clone()
End If
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
' so that it can handle events in a standard way.
System.Windows.Forms.Application.DoEvents()
#End If
Loop
End If
hv_DistOut = hv_DistIn_COPY_INP_TMP.Clone()
hv_RelQuaternionOut = hv_RelQuaternionIn_COPY_INP_TMP.Clone()
ho_ModelContours.Dispose()
ho_BackgroundImageTrans.Dispose()
Exit Sub
Catch HDevExpDefaultException As HalconException
ho_ModelContours.Dispose()
ho_BackgroundImageTrans.Dispose()
Throw HDevExpDefaultException
End Try
End Sub
Try
'dev_get_window(...);
HOperatorSet.GetDraw(hv_WindowHandle, hv_DrawMode)
HOperatorSet.SetColor(hv_WindowHandle, New HTuple("light gray"))
'dev_set_window(...);
HOperatorSet.SetDraw(hv_WindowHandle, New HTuple("fill"))
HOperatorSet.SetColor(hv_WindowHandle, New HTuple("light gray"))
HOperatorSet.DispRegion(ho_MenuRegion, hv_WindowHandle)
'dev_display (MenuRegion)
HOperatorSet.GetRegionContour(ho_MenuRegion, hv_Rows, hv_Cols)
HOperatorSet.SetColor(hv_WindowHandle, New HTuple("dim gray"))
'dev_set_color ('dim gray')
111
Appendix
ho_RegionBorder.Dispose()
HOperatorSet.GenRegionPoints(ho_RegionBorder, hv_Rows, hv_Cols)
HOperatorSet.DispRegion(ho_RegionBorder, hv_WindowHandle)
'dev_display (RegionBorder)
'dev_set_color ('black')
HOperatorSet.SetColor(hv_WindowHandle, New HTuple("black"))
HOperatorSet.GetStringExtents(hv_WindowHandle, hv_Text, hv_Ascent,
hv_Descent, _
hv_Width, hv_Height)
HOperatorSet.SetTposition(hv_WindowHandle,
((hv_Rows.TupleMin())).TupleAdd( _
New HTuple(1)),
((((((hv_Cols.TupleMax())).TupleAdd(hv_Cols.TupleMin()))).TupleDiv( _
New HTuple(2)))).TupleSub(hv_Width.TupleDiv(New HTuple(2))))
'set_tposition (WindowHandle, min(Rows) + 1, min(Cols) + 1)
HOperatorSet.WriteString(hv_WindowHandle, hv_Text)
HOperatorSet.SetDraw(hv_WindowHandle, hv_DrawMode)
'dev_set_window(...);
ho_RegionBorder.Dispose()
Exit Sub
Catch HDevExpDefaultException As HalconException
ho_RegionBorder.Dispose()
Throw HDevExpDefaultException
End Try
End Sub
If ((New HTuple(hv_MX1.TupleEqual(hv_MX2)))).TupleAnd(New
HTuple(hv_MY1.TupleEqual( _
hv_MY2))).I() Then
hv_QuatRotation = (((New
HTuple(1)).TupleConcat(0)).TupleConcat(0)).TupleConcat( _
0)
Exit Sub
End If
'Project the image point onto the track ball
project_point_on_trackball(hv_MX1, hv_MY1, hv_VirtualTrackball,
hv_TrackballSize, _
hv_P1)
project_point_on_trackball(hv_MX2, hv_MY2, hv_VirtualTrackball,
hv_TrackballSize, _
hv_P2)
'The cross product of the projected points defines the rotation axis
tuple_vector_cross_product(hv_P1, hv_P2, hv_RotAxis)
'Compute the rotation angle
hv_D = hv_P2.TupleSub(hv_P1)
112
Appendix
hv_T = ((((((hv_D.TupleMult(hv_D))).TupleSum())).TupleSqrt())).TupleDiv((New
HTuple(2.0)).TupleMult( _
hv_TrackballSize))
If New HTuple(hv_T.TupleGreater(New HTuple(1.0))).I() Then
hv_T = New HTuple(1.0)
End If
If New HTuple(hv_T.TupleLess(New HTuple(-1.0))).I() Then
hv_T = New HTuple(-1.0)
End If
hv_RotAngle = (New HTuple(2.0)).TupleMult(hv_T.TupleAsin())
hv_Len = ((((hv_RotAxis.TupleMult(hv_RotAxis))).TupleSum())).TupleSqrt()
If New HTuple(hv_Len.TupleGreater(New HTuple(0.0))).I() Then
hv_LenInv = (New HTuple(1.0)).TupleDiv(hv_Len)
hv_RotAxis = hv_RotAxis.TupleMult(hv_LenInv)
End If
HOperatorSet.AxisAngleToQuat(hv_RotAxis.TupleSelect(New HTuple(0)),
hv_RotAxis.TupleSelect( _
New HTuple(1)), hv_RotAxis.TupleSelect(New HTuple(2)), hv_RotAngle,
hv_QuatRotation)
Exit Sub
End Sub
113
Appendix
Try
'
'Initialize some values
hv_CoordAxesLength = New HTuple(50)
HOperatorSet.GetWindowExtents(hv_WindowHandle, hv_Row, hv_Column,
hv_Width, _
hv_Height)
ho_Image1.Dispose()
HOperatorSet.GenImageConst(ho_Image1, New HTuple("byte"), hv_Width,
hv_Height)
114
Appendix
ho_Image2.Dispose()
HOperatorSet.GenImageConst(ho_Image2, New HTuple("byte"), hv_Width,
hv_Height)
ho_Image3.Dispose()
HOperatorSet.GenImageConst(ho_Image3, New HTuple("byte"), hv_Width,
hv_Height)
hv_MinImageSize = ((hv_Width.TupleConcat(hv_Height))).TupleMin()
hv_Cx = hv_MinImageSize.TupleDiv(New HTuple(2))
hv_Cy = hv_MinImageSize.TupleDiv(New HTuple(2))
hv_CamParamSmall = hv_CamParam.Clone()
If IsNothing(hv_CamParamSmall) Then
hv_CamParamSmall = New HTuple
End If
hv_CamParamSmall(New HTuple(4)) = hv_Cx
If IsNothing(hv_CamParamSmall) Then
hv_CamParamSmall = New HTuple
End If
hv_CamParamSmall(New HTuple(5)) = hv_Cy
If IsNothing(hv_CamParamSmall) Then
hv_CamParamSmall = New HTuple
End If
hv_CamParamSmall(New HTuple(6)) = hv_MinImageSize
If IsNothing(hv_CamParamSmall) Then
hv_CamParamSmall = New HTuple
End If
hv_CamParamSmall(New HTuple(7)) = hv_MinImageSize
hv_SphereRadius = ((hv_MinImageSize.TupleMult(New
HTuple(0.8)))).TupleDiv(New HTuple(2))
hv_SpherePos = hv_MinImageSize.TupleDiv(New HTuple(2))
'
'Project the viewing sphere
ho_CirclesLon.Dispose()
HOperatorSet.GenContourPolygonXld(ho_CirclesLon,
((hv_SpherePos.TupleSub(hv_SphereRadius))).TupleConcat( _
hv_SpherePos.TupleAdd(hv_SphereRadius)),
hv_SpherePos.TupleConcat(hv_SpherePos))
For hv_Lon = (New HTuple(30)) To (New HTuple(90)) Step (New HTuple(30))
ho_CircleLon.Dispose()
HOperatorSet.GenEllipseContourXld(ho_CircleLon, hv_SpherePos,
hv_SpherePos, _
New HTuple(0),
hv_SphereRadius.TupleMult(((hv_Lon.TupleRad())).TupleSin( _
)), hv_SphereRadius, New HTuple(0), New HTuple(6.28318), New
HTuple("positive"), _
New HTuple(1.5))
HOperatorSet.ConcatObj(ho_CirclesLon, ho_CircleLon, OTemp(0))
ho_CirclesLon.Dispose()
ho_CirclesLon = OTemp(0)
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
' so that it can handle events in a standard way.
System.Windows.Forms.Application.DoEvents()
#End If
Next
ho_CirclesLat.Dispose()
HOperatorSet.GenEmptyObj(ho_CirclesLat)
For hv_Lat = (New HTuple(-60)) To (New HTuple(60)) Step (New HTuple(30))
ho_CircleLat.Dispose()
HOperatorSet.GenContourPolygonXld(ho_CircleLat,
((hv_SpherePos.TupleSub(hv_SphereRadius.TupleMult( _
((hv_Lat.TupleRad())).TupleSin())))).TupleConcat(hv_SpherePos.TupleSub( _
hv_SphereRadius.TupleMult(((hv_Lat.TupleRad())).TupleSin()))),
((hv_SpherePos.TupleSub( _
115
Appendix
hv_SphereRadius.TupleMult((((((New
HTuple(90.0)).TupleSub(hv_Lat))).TupleRad( _
))).TupleSin())))).TupleConcat(hv_SpherePos.TupleAdd(hv_SphereRadius.TupleMult( _
(((((New
HTuple(90.0)).TupleSub(hv_Lat))).TupleRad())).TupleSin()))))
HOperatorSet.ConcatObj(ho_CirclesLat, ho_CircleLat, OTemp(0))
ho_CirclesLat.Dispose()
ho_CirclesLat = OTemp(0)
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
' so that it can handle events in a standard way.
System.Windows.Forms.Application.DoEvents()
#End If
Next
'
'Project the camera position
HOperatorSet.QuatToHomMat3d(hv_RelQuaternion, hv_RelHomMat)
HOperatorSet.HomMat3dToPose(hv_RelHomMat, hv_RelPose)
If IsNothing(hv_RelPose) Then
hv_RelPose = New HTuple
End If
hv_RelPose(New HTuple(2)) = hv_Dist
HOperatorSet.PoseToHomMat3d(hv_RelPose, hv_RelHomMat)
HOperatorSet.HomMat3dInvert(hv_RelHomMat, hv_RelHomMatInv)
HOperatorSet.AffineTransPoint3d(hv_RelHomMatInv, New HTuple(0), New
HTuple(0), _
New HTuple(0), hv_X, hv_Y, hv_Z)
hv_CamPos = ((hv_X.TupleConcat(hv_Y))).TupleConcat(hv_Z)
HOperatorSet.AffineTransPoint3d(hv_RelHomMatInv, New HTuple(1.0), New
HTuple(0), _
New HTuple(0), hv_X, hv_Y, hv_Z)
hv_CamXAx = ((hv_X.TupleConcat(hv_Y))).TupleConcat(hv_Z)
HOperatorSet.AffineTransPoint3d(hv_RelHomMatInv, New HTuple(0), New
HTuple(1.0), _
New HTuple(0), hv_X, hv_Y, hv_Z)
hv_CamYAx = ((hv_X.TupleConcat(hv_Y))).TupleConcat(hv_Z)
HOperatorSet.AffineTransPoint3d(hv_RelHomMatInv, New HTuple(0), New
HTuple(0), _
New HTuple(1.0), hv_X, hv_Y, hv_Z)
hv_CamZAx = ((hv_X.TupleConcat(hv_Y))).TupleConcat(hv_Z)
'Scale the position to the viewing sphere
hv_ScaleFactor =
hv_SphereRadius.TupleDiv(((((hv_CamPos.TupleMult(hv_CamPos))).TupleSum( _
))).TupleSqrt())
hv_CamPosProj = hv_ScaleFactor.TupleMult(hv_CamPos)
hv_CamXAxProj = hv_ScaleFactor.TupleMult(hv_CamXAx)
hv_CamYAxProj = hv_ScaleFactor.TupleMult(hv_CamYAx)
hv_CamZAxProj = hv_ScaleFactor.TupleMult(hv_CamZAx)
'Scale the coordinate axis to the desired length
hv_Vec = hv_CamXAxProj.TupleSub(hv_CamPosProj)
hv_ScaleFactor =
hv_CoordAxesLength.TupleDiv(((((hv_Vec.TupleMult(hv_Vec))).TupleSum( _
))).TupleSqrt())
hv_CamXAxProj =
hv_CamPosProj.TupleAdd(hv_ScaleFactor.TupleMult(hv_CamXAxProj.TupleSub( _
hv_CamPosProj)))
hv_CamYAxProj =
hv_CamPosProj.TupleAdd(hv_ScaleFactor.TupleMult(hv_CamYAxProj.TupleSub( _
hv_CamPosProj)))
hv_CamZAxProj =
hv_CamPosProj.TupleAdd(hv_ScaleFactor.TupleMult(hv_CamZAxProj.TupleSub( _
hv_CamPosProj)))
116
Appendix
hv_CamRow = hv_SpherePos.TupleAdd(hv_CamPosProj.TupleSelect(New
HTuple(1)))
hv_CamCol = hv_SpherePos.TupleAdd(hv_CamPosProj.TupleSelect(New
HTuple(0)))
hv_CamXAxRow = hv_SpherePos.TupleAdd(hv_CamXAxProj.TupleSelect(New
HTuple(1)))
hv_CamXAxCol = hv_SpherePos.TupleAdd(hv_CamXAxProj.TupleSelect(New
HTuple(0)))
hv_CamYAxRow = hv_SpherePos.TupleAdd(hv_CamYAxProj.TupleSelect(New
HTuple(1)))
hv_CamYAxCol = hv_SpherePos.TupleAdd(hv_CamYAxProj.TupleSelect(New
HTuple(0)))
hv_CamZAxRow = hv_SpherePos.TupleAdd(hv_CamZAxProj.TupleSelect(New
HTuple(1)))
hv_CamZAxCol = hv_SpherePos.TupleAdd(hv_CamZAxProj.TupleSelect(New
HTuple(0)))
ho_XAxis.Dispose()
gen_arrow_cont(ho_XAxis, hv_CamRow, hv_CamCol, hv_CamXAxRow,
hv_CamXAxCol)
ho_YAxis.Dispose()
gen_arrow_cont(ho_YAxis, hv_CamRow, hv_CamCol, hv_CamYAxRow,
hv_CamYAxCol)
ho_ZAxis.Dispose()
gen_arrow_cont(ho_ZAxis, hv_CamRow, hv_CamCol, hv_CamZAxRow,
hv_CamZAxCol)
'
'Compute the current longitude, latitude, and camera roll angle
HOperatorSet.ConvertPoint3dCartToSpher(hv_CamPos.TupleSelect(New
HTuple(0)), _
hv_CamPos.TupleSelect(New HTuple(1)), hv_CamPos.TupleSelect(New
HTuple(2)), _
New HTuple("-y"), New HTuple("-z"), hv_CamLon, hv_CamLat, hv_Radius)
hv_CamRoll = ((hv_RelPose.TupleSelect(New HTuple(5)))).TupleNeg()
Do While New HTuple(hv_CamRoll.TupleGreater(New HTuple(180.0))).I()
hv_CamRoll = hv_CamRoll.TupleSub(New HTuple(360.0))
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
' so that it can handle events in a standard way.
System.Windows.Forms.Application.DoEvents()
#End If
Loop
Do While New HTuple(hv_CamRoll.TupleLess(New HTuple(-180.0))).I()
hv_CamRoll = hv_CamRoll.TupleAdd(New HTuple(360.0))
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
' so that it can handle events in a standard way.
System.Windows.Forms.Application.DoEvents()
#End If
Loop
hv_CamRoll = ((hv_CamRoll.TupleMult(New HTuple(3.1416)))).TupleDiv(New
HTuple(180.0))
'
'Indicate longitude and latitude by lines
ho_LineLong.Dispose()
HOperatorSet.GenContourPolygonXld(ho_LineLong,
hv_SpherePos.TupleConcat(hv_SpherePos), _
hv_SpherePos.TupleConcat(hv_SpherePos.TupleAdd(hv_SphereRadius.TupleMult( _
hv_CamLon.TupleSin()))))
hv_XRangeCamPos = New HTuple()
hv_YRangeCamPos = New HTuple()
hv_StepLat = (New HTuple(1)).TupleRad()
If New HTuple(hv_CamLat.TupleGreater(New HTuple(0))).I() Then
117
Appendix
118
Appendix
hv_XRangeLatMin = hv_XRangeLatMin.TupleConcat(hv_X)
hv_YRangeLatMin = hv_YRangeLatMin.TupleConcat(hv_Y)
HOperatorSet.ConvertPoint3dSpherToCart(hv_Long, hv_LatitudeMaxDisp,
hv_SphereRadius, _
New HTuple("-y"), New HTuple("-z"), hv_X, hv_Y, hv_Z)
hv_XRangeLatMax = hv_XRangeLatMax.TupleConcat(hv_X)
hv_YRangeLatMax = hv_YRangeLatMax.TupleConcat(hv_Y)
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
' so that it can handle events in a standard way.
System.Windows.Forms.Application.DoEvents()
#End If
Next
'
'Project the border of the pose range at LongitudeMin and LongitudeMax
hv_XRangeLongMin = New HTuple()
hv_YRangeLongMin = New HTuple()
hv_XRangeLongMax = New HTuple()
hv_YRangeLongMax = New HTuple()
For hv_Lat = hv_LatitudeMinDisp To hv_LatitudeMaxDisp Step ( _
New HTuple(1)).TupleRad()
HOperatorSet.ConvertPoint3dSpherToCart(hv_LongitudeMinDisp, hv_Lat,
hv_SphereRadius, _
New HTuple("-y"), New HTuple("-z"), hv_X, hv_Y, hv_Z)
hv_XRangeLongMin = hv_XRangeLongMin.TupleConcat(hv_X)
hv_YRangeLongMin = hv_YRangeLongMin.TupleConcat(hv_Y)
HOperatorSet.ConvertPoint3dSpherToCart(hv_LongitudeMaxDisp, hv_Lat,
hv_SphereRadius, _
New HTuple("-y"), New HTuple("-z"), hv_X, hv_Y, hv_Z)
hv_XRangeLongMax = hv_XRangeLongMax.TupleConcat(hv_X)
hv_YRangeLongMax = hv_YRangeLongMax.TupleConcat(hv_Y)
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
' so that it can handle events in a standard way.
System.Windows.Forms.Application.DoEvents()
#End If
Next
ho_ContPoseRange.Dispose()
HOperatorSet.GenContourPolygonXld(ho_ContPoseRange,
hv_SpherePos.TupleAdd(((( _
(hv_YRangeLatMin.TupleConcat(hv_YRangeLongMax))).TupleConcat(hv_YRangeLatMax.TupleInv
erse( _
)))).TupleConcat(hv_YRangeLongMin.TupleInverse())),
hv_SpherePos.TupleAdd( _
((((hv_XRangeLatMin.TupleConcat(hv_XRangeLongMax))).TupleConcat(hv_XRangeLatMax.Tuple
Inverse( _
)))).TupleConcat(hv_XRangeLongMin.TupleInverse())))
ho_Image.Dispose()
HOperatorSet.Compose3(ho_Image1, ho_Image2, ho_Image3, ho_Image)
HOperatorSet.PaintXld(ho_ContPoseRange, ho_Image, OTemp(0), ((New
HTuple(80)).TupleConcat( _
0)).TupleConcat(80))
ho_Image.Dispose()
ho_Image = OTemp(0)
'
'Display the graphics
'dev_set_window(...);
HOperatorSet.DispObj(ho_Image, hv_WindowHandle)
HOperatorSet.SetColor(hv_WindowHandle, New HTuple("blue"))
HOperatorSet.DispObj(ho_CirclesLon, hv_WindowHandle)
HOperatorSet.DispObj(ho_CirclesLat, hv_WindowHandle)
119
Appendix
HOperatorSet.SetColor(hv_WindowHandle, hv_ModelColor)
HOperatorSet.DispObj(ho_ModelContours, hv_WindowHandle)
HOperatorSet.SetColor(hv_WindowHandle, New HTuple("light gray"))
HOperatorSet.DispObj(ho_ReferencePointCross, hv_WindowHandle)
HOperatorSet.SetColor(hv_WindowHandle, New HTuple("magenta"))
HOperatorSet.DispObj(ho_ContPoseRange, hv_WindowHandle)
If ((New HTuple(hv_CamLon.TupleGreater((((New
HTuple(90)).TupleRad())).TupleNeg( _
))))).TupleAnd(New HTuple(hv_CamLon.TupleLess((New
HTuple(90)).TupleRad()))).I() Then
HOperatorSet.SetColor(hv_WindowHandle, New HTuple("yellow"))
Else
HOperatorSet.SetColor(hv_WindowHandle, New HTuple("tan"))
End If
HOperatorSet.DispObj(ho_XAxis, hv_WindowHandle)
HOperatorSet.DispObj(ho_YAxis, hv_WindowHandle)
HOperatorSet.DispObj(ho_ZAxis, hv_WindowHandle)
HOperatorSet.SetTposition(hv_WindowHandle, hv_CamXAxRow, hv_CamXAxCol)
HOperatorSet.WriteString(hv_WindowHandle, New HTuple("x"))
HOperatorSet.SetTposition(hv_WindowHandle, hv_CamYAxRow, hv_CamYAxCol)
HOperatorSet.WriteString(hv_WindowHandle, New HTuple("y"))
HOperatorSet.SetTposition(hv_WindowHandle, hv_CamZAxRow, hv_CamZAxCol)
HOperatorSet.WriteString(hv_WindowHandle, New HTuple("z"))
HOperatorSet.GetLineStyle(hv_WindowHandle, hv_LineStyle)
HOperatorSet.SetLineStyle(hv_WindowHandle, (New HTuple(4)).TupleConcat( _
4))
HOperatorSet.DispObj(ho_LineLong, hv_WindowHandle)
HOperatorSet.DispObj(ho_LineLat, hv_WindowHandle)
HOperatorSet.SetLineStyle(hv_WindowHandle, hv_LineStyle)
'
'Display the text
'Compute the format string in dependence of the distance magnitude
hv_MaxDist =
((((hv_Dist.TupleConcat(hv_DistMin))).TupleConcat(hv_DistMax))).TupleMax( _
)
If New HTuple(hv_MaxDist.TupleGreater(New HTuple(0))).I() Then
hv_Precision = (((New HTuple(0)).TupleConcat((New
HTuple(4)).TupleSub(((hv_MaxDist.TupleLog10( _
))).TupleInt())))).TupleMax()
hv_Precision = ((hv_Precision.TupleConcat(New HTuple(4)))).TupleMin()
Else
hv_Precision = New HTuple(4)
End If
hv_DistFormat = (((New
HTuple("6.")).TupleAdd(hv_Precision))).TupleAdd(New HTuple("f"))
HOperatorSet.SetColor(hv_ExpDefaultWinHandle, New HTuple("white"))
HOperatorSet.TupleChr(New HTuple(&HB0), hv_DegreeSign)
HOperatorSet.SetTposition(hv_WindowHandle, hv_MinImageSize, New
HTuple(30))
HOperatorSet.WriteString(hv_WindowHandle, New HTuple("Current Reference
Pose Angles:"))
HOperatorSet.SetTposition(hv_WindowHandle, hv_MinImageSize.TupleAdd(New
HTuple(20)), _
New HTuple(30))
HOperatorSet.WriteString(hv_WindowHandle, (((((((((((((((((((New HTuple("
a =")).TupleAdd( _
((hv_RefPose_COPY_INP_TMP.TupleSelect(New
HTuple(3)))).TupleString((New HTuple("4.0f")).S())))).TupleAdd( _
hv_DegreeSign))).TupleAdd(New HTuple(";")))).TupleAdd(New HTuple(" b
=")))).TupleAdd( _
((hv_RefPose_COPY_INP_TMP.TupleSelect(New
HTuple(4)))).TupleString((New HTuple("4.0f")).S())))).TupleAdd( _
hv_DegreeSign))).TupleAdd(New HTuple(";")))).TupleAdd(New HTuple(" g
=")))).TupleAdd( _
120
Appendix
((hv_RefPose_COPY_INP_TMP.TupleSelect(New
HTuple(5)))).TupleString((New HTuple("4.0f")).S())))).TupleAdd( _
hv_DegreeSign))
HOperatorSet.SetTposition(hv_WindowHandle, hv_MinImageSize.TupleAdd(New
HTuple(50)), _
New HTuple(30))
HOperatorSet.WriteString(hv_WindowHandle, (((((((((((((((((New
HTuple("Longitude: ")).TupleAdd( _
((((hv_CamLon.TupleMult(New HTuple(180)))).TupleDiv(New
HTuple(3.1416)))).TupleString(( _
New HTuple("+4.0f")).S())))).TupleAdd(hv_DegreeSign))).TupleAdd(New
HTuple("; [")))).TupleAdd( _
((((hv_LongitudeMin.TupleMult(New HTuple(180)))).TupleDiv(New
HTuple(3.1416)))).TupleString(( _
New HTuple("+4.0f")).S())))).TupleAdd(hv_DegreeSign))).TupleAdd(New
HTuple("; ")))).TupleAdd( _
((((hv_LongitudeMax.TupleMult(New HTuple(180)))).TupleDiv(New
HTuple(3.1416)))).TupleString(( _
New HTuple("+4.0f")).S())))).TupleAdd(hv_DegreeSign))).TupleAdd(New
HTuple("]")))
HOperatorSet.SetTposition(hv_WindowHandle, hv_MinImageSize.TupleAdd(New
HTuple(70)), _
New HTuple(30))
HOperatorSet.WriteString(hv_WindowHandle, (((((((((((((((((New
HTuple("Latitude: ")).TupleAdd( _
((((hv_CamLat.TupleMult(New HTuple(180)))).TupleDiv(New
HTuple(3.1416)))).TupleString(( _
New HTuple("+4.0f")).S())))).TupleAdd(hv_DegreeSign))).TupleAdd(New
HTuple("; [")))).TupleAdd( _
((((hv_LatitudeMin.TupleMult(New HTuple(180)))).TupleDiv(New
HTuple(3.1416)))).TupleString(( _
New HTuple("+4.0f")).S())))).TupleAdd(hv_DegreeSign))).TupleAdd(New
HTuple("; ")))).TupleAdd( _
((((hv_LatitudeMax.TupleMult(New HTuple(180)))).TupleDiv(New
HTuple(3.1416)))).TupleString(( _
New HTuple("+4.0f")).S())))).TupleAdd(hv_DegreeSign))).TupleAdd(New
HTuple("]")))
HOperatorSet.SetTposition(hv_WindowHandle, hv_MinImageSize.TupleAdd(New
HTuple(90)), _
New HTuple(30))
HOperatorSet.WriteString(hv_WindowHandle, (((((((((((((((((New
HTuple("CamRoll: ")).TupleAdd( _
((((hv_CamRoll.TupleMult(New HTuple(180)))).TupleDiv(New
HTuple(3.1416)))).TupleString(( _
New HTuple("+4.0f")).S())))).TupleAdd(hv_DegreeSign))).TupleAdd(New
HTuple("; [")))).TupleAdd( _
((((hv_CamRollMin.TupleMult(New HTuple(180)))).TupleDiv(New
HTuple(3.1416)))).TupleString(( _
New HTuple("+4.0f")).S())))).TupleAdd(hv_DegreeSign))).TupleAdd(New
HTuple("; ")))).TupleAdd( _
((((hv_CamRollMax.TupleMult(New HTuple(180)))).TupleDiv(New
HTuple(3.1416)))).TupleString(( _
New HTuple("+4.0f")).S())))).TupleAdd(hv_DegreeSign))).TupleAdd(New
HTuple("]")))
HOperatorSet.SetTposition(hv_WindowHandle, hv_MinImageSize.TupleAdd(New
HTuple(110)), _
New HTuple(30))
HOperatorSet.WriteString(hv_WindowHandle, (((((((((((New
HTuple("Distance: ")).TupleAdd( _
hv_Dist.TupleString(hv_DistFormat.S())))).TupleAdd(New HTuple(";
[")))).TupleAdd( _
hv_DistMin.TupleString(hv_DistFormat.S())))).TupleAdd(New HTuple(";
")))).TupleAdd( _
hv_DistMax.TupleString(hv_DistFormat.S())))).TupleAdd(New
HTuple("]")))
121
Appendix
HOperatorSet.SetTposition(hv_WindowHandle, hv_MinImageSize.TupleAdd(New
HTuple(140)), _
New HTuple(30))
HOperatorSet.WriteString(hv_WindowHandle, (((New HTuple("MinFaceAngle:
")).TupleAdd( _
((((hv_MinFaceAngle.TupleMult(New HTuple(180)))).TupleDiv(New
HTuple(3.1416)))).TupleString(( _
New HTuple("4.0f")).S())))).TupleAdd(hv_DegreeSign))
ho_Image1.Dispose()
ho_Image2.Dispose()
ho_Image3.Dispose()
ho_CirclesLon.Dispose()
ho_CircleLon.Dispose()
ho_CirclesLat.Dispose()
ho_CircleLat.Dispose()
ho_XAxis.Dispose()
ho_YAxis.Dispose()
ho_ZAxis.Dispose()
ho_LineLong.Dispose()
ho_LineLat.Dispose()
ho_ModelContours.Dispose()
ho_ReferencePointCross.Dispose()
ho_ContPoseRange.Dispose()
ho_Image.Dispose()
Exit Sub
Catch HDevExpDefaultException As HalconException
ho_Image1.Dispose()
ho_Image2.Dispose()
ho_Image3.Dispose()
ho_CirclesLon.Dispose()
ho_CircleLon.Dispose()
ho_CirclesLat.Dispose()
ho_CircleLat.Dispose()
ho_XAxis.Dispose()
ho_YAxis.Dispose()
ho_ZAxis.Dispose()
ho_LineLong.Dispose()
ho_LineLat.Dispose()
ho_ModelContours.Dispose()
ho_ReferencePointCross.Dispose()
ho_ContPoseRange.Dispose()
ho_Image.Dispose()
Throw HDevExpDefaultException
End Try
End Sub
122
Appendix
123
Appendix
If IsNothing(hv_RelPose) Then
hv_RelPose = New HTuple
End If
hv_RelPose(New HTuple(2)) = hv_Dist
HOperatorSet.PoseInvert(hv_RelPose, hv_RelPoseInv)
hv_CameraPos = ((((hv_RelPoseInv.TupleSelect(New
HTuple(0)))).TupleConcat(hv_RelPoseInv.TupleSelect( _
New HTuple(1))))).TupleConcat(hv_RelPoseInv.TupleSelect(New
HTuple(2)))
'Compute the current longitude, latitude, and camera roll angle
HOperatorSet.ConvertPoint3dCartToSpher(hv_CameraPos.TupleSelect(New
HTuple(0)), _
hv_CameraPos.TupleSelect(New HTuple(1)), hv_CameraPos.TupleSelect(New
HTuple(2)), _
New HTuple("-y"), New HTuple("-z"), hv_CurrentLongitude,
hv_CurrentLatitude, _
hv_Radius)
hv_CurrentCamRoll = hv_RelPose.TupleSelect(New HTuple(5))
Do While New HTuple(hv_CurrentCamRoll.TupleGreater(New
HTuple(180.0))).I()
hv_CurrentCamRoll = hv_CurrentCamRoll.TupleSub(New HTuple(360.0))
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
' so that it can handle events in a standard way.
System.Windows.Forms.Application.DoEvents()
#End If
Loop
Do While New HTuple(hv_CurrentCamRoll.TupleLess(New HTuple(-180.0))).I()
hv_CurrentCamRoll = hv_CurrentCamRoll.TupleAdd(New HTuple(360.0))
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
' so that it can handle events in a standard way.
System.Windows.Forms.Application.DoEvents()
#End If
Loop
hv_CurrentCamRoll = ((hv_CurrentCamRoll.TupleMult(New
HTuple(3.1416)))).TupleDiv( _
New HTuple(180.0))
hv_LongitudeMinOut =
((hv_LongitudeMinOut.TupleConcat(hv_CurrentLongitude))).TupleMin( _
)
hv_LongitudeMaxOut =
((hv_LongitudeMaxOut.TupleConcat(hv_CurrentLongitude))).TupleMax( _
)
hv_LatitudeMinOut =
((hv_LatitudeMinOut.TupleConcat(hv_CurrentLatitude))).TupleMin( _
)
hv_LatitudeMaxOut =
((hv_LatitudeMaxOut.TupleConcat(hv_CurrentLatitude))).TupleMax( _
)
hv_CamRollMinOut =
((hv_CamRollMinOut.TupleConcat(hv_CurrentCamRoll))).TupleMin( _
)
hv_CamRollMaxOut =
((hv_CamRollMaxOut.TupleConcat(hv_CurrentCamRoll))).TupleMax( _
)
hv_DistMinOut = ((hv_DistMinOut.TupleConcat(hv_Dist))).TupleMin()
hv_DistMaxOut = ((hv_DistMaxOut.TupleConcat(hv_Dist))).TupleMax()
End If
If New HTuple(hv_SelectedButton.TupleEqual(New HTuple("Increase
MinFaceAngle"))).I() Then
hv_MinFaceAngleOut = hv_MinFaceAngleOut.TupleAdd((New
HTuple(1)).TupleRad())
124
Appendix
If New HTuple(hv_MinFaceAngleOut.TupleGreater((New
HTuple(180)).TupleRad())).I() Then
hv_MinFaceAngleOut = (New HTuple(180)).TupleRad()
End If
End If
If New HTuple(hv_SelectedButton.TupleEqual(New HTuple("Decrease
MinFaceAngle"))).I() Then
hv_MinFaceAngleOut = hv_MinFaceAngleOut.TupleSub((New
HTuple(1)).TupleRad())
If New HTuple(hv_MinFaceAngleOut.TupleLess(New HTuple(0))).I() Then
hv_MinFaceAngleOut = New HTuple(0)
End If
End If
If New HTuple(hv_SelectedButton.TupleEqual(New HTuple("Reset Reference
Pose"))).I() Then
'Reset the reference pose
hv_RefPoseOut = hv_RefPoseReset.Clone()
'Reset the pose range
hv_LongitudeMinOut = New HTuple(0)
hv_LongitudeMaxOut = New HTuple(0)
hv_LatitudeMinOut = New HTuple(0)
hv_LatitudeMaxOut = New HTuple(0)
hv_CamRollMinOut = New HTuple(0)
hv_CamRollMaxOut = New HTuple(0)
hv_DistMinOut = hv_Dist.Clone()
hv_DistMaxOut = hv_Dist.Clone()
'Reset the current relative pose
hv_RelQuaternionOut = (((New
HTuple(1)).TupleConcat(0)).TupleConcat(0)).TupleConcat( _
0)
End If
If New HTuple(hv_SelectedButton.TupleEqual(New HTuple("Reset Pose
Range"))).I() Then
hv_LongitudeMinOut = New HTuple(0)
hv_LongitudeMaxOut = New HTuple(0)
hv_LatitudeMinOut = New HTuple(0)
hv_LatitudeMaxOut = New HTuple(0)
hv_CamRollMinOut = New HTuple(0)
hv_CamRollMaxOut = New HTuple(0)
hv_DistMinOut = hv_Dist.Clone()
hv_DistMaxOut = hv_Dist.Clone()
End If
If New HTuple(hv_SelectedButton.TupleEqual(New HTuple("Next Image"))).I()
Then
hv_ImageNoOut = hv_ImageNoIn.TupleAdd(New HTuple(1))
End If
If New HTuple(hv_SelectedButton.TupleEqual(New HTuple("Previous Image"))).I()
Then
hv_ImageNoOut = hv_ImageNoIn.TupleSub(New HTuple(1))
End If
If New HTuple(hv_SelectedButton.TupleEqual(New HTuple("Hidden Line
Removal"))).I() Then
If New HTuple(hv_HiddenSurfaceRemovalIn.TupleEqual(New
HTuple("true"))).I() Then
hv_HiddenSurfaceRemovalOut = New HTuple("false")
Else
hv_HiddenSurfaceRemovalOut = New HTuple("true")
End If
End If
If New HTuple(hv_SelectedButton.TupleEqual(New HTuple("Mouse Mode: Move
Camera"))).I() Then
hv_MouseModeOut = New HTuple("move_camera")
End If
If New HTuple(hv_SelectedButton.TupleEqual(New HTuple("Mouse Mode: Move
Image"))).I() Then
125
Appendix
Exit Sub
End Sub
HOperatorSet.CloseAllFramegrabbers()
Try
'Read internal camera parameters from file***
HOperatorSet.ReadCamPar(CamParamDirectory, hv_CamParam)
126
Appendix
'** Prepare the object model for the use within the 3d shape-based
matching***
HOperatorSet.PrepareObjectModel3d(hv_ObjectModel3DID, New
HTuple("shape_based_matching_3d"), _
New HTuple("true"), New HTuple(), New HTuple())
HOperatorSet.CreateShapeModel3d(hv_ObjectModel3DID, hv_CamParam,
hv_RefRotX, _
hv_RefRotY, hv_RefRotZ, New HTuple("gba"), hv_LongitudeMin,
hv_LongitudeMax, _
hv_LatitudeMin, hv_LatitudeMax, hv_CamRollMin, hv_CamRollMax, New
HTuple(0.95), _
New HTuple(1.1), New HTuple(10), New HTuple("lowest_model_level"),
New HTuple(3), _
hv_ShapeModel3DID)
hv_Message = New HTuple("Creation Completed...")
disp_message(hv_ExpDefaultWinHandle, hv_Message, New HTuple("window"),
New HTuple(82), _
New HTuple(12), New HTuple("black"), New HTuple("true"))
127
Appendix
HOperatorSet.CloseFramegrabber(hv_AcqHandle)
ho_Image.Dispose()
End Sub
Sub InitHalcon()
' Default settings used in HDevelop
Call HOperatorSet.SetSystem(New HTuple("width"), New HTuple(512))
End Sub
Sub RunHalconSaveShapeModel()
Call actionSaveShapeModel()
End Sub
End Module
A6.3. CylinderMatching.vb
Option Explicit On
Imports HalconDotNet
Module HDevelopExportCylinderMatching
' Procedures
' External procedures
128
Appendix
'This procedure sets the text font of the current window with
'the specified attributes.
'It is assumed that following fonts are installed on the system:
'Windows: Courier New, Arial Times New Roman
'Mac OS X: CourierNewPS, Arial, TimesNewRomanPS
'Linux: courier, helvetica, times
'Because fonts are displayed smaller on Linux than on Windows,
'a scaling factor of 1.25 is used the get comparable results.
'For Linux, only a limited number of font sizes is supported,
'to get comparable results, it is recommended to use one of the
'following sizes: 9, 11, 14, 16, 20, 27
'(which will be mapped internally on Linux systems to 11, 14, 17, 20, 25, 34)
'
'Input parameters:
'WindowHandle: The graphics window for which the font will be set
'Size: The font size. If Size=-1, the default of 16 is used.
'Bold: If set to 'true', a bold font is used
'Slant: If set to 'true', a slanted font is used
'
HOperatorSet.GetSystem(New HTuple("operating_system"), hv_OS)
' dev_get_preferences(...); only in hdevelop
' dev_set_preferences(...); only in hdevelop
If ((New HTuple(hv_Size_COPY_INP_TMP.TupleEqual(New HTuple())))).TupleOr(New
HTuple( _
hv_Size_COPY_INP_TMP.TupleEqual(New HTuple(-1)))).I() Then
hv_Size_COPY_INP_TMP = New HTuple(16)
End If
If New HTuple(((hv_OS.TupleSubstr(New HTuple(0), New
HTuple(2)))).TupleEqual(New HTuple("Win"))).I() Then
'Set font on Windows systems
If ((((New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("mono"))))).TupleOr( _
New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("Courier")))))).TupleOr( _
New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("courier")))).I() Then
hv_Font_COPY_INP_TMP = New HTuple("Courier New")
129
Appendix
130
Appendix
If ((((New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("mono"))))).TupleOr( _
New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("Courier")))))).TupleOr( _
New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("courier")))).I() Then
hv_Font_COPY_INP_TMP = New HTuple("CourierNewPS")
ElseIf New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("sans"))).I() Then
hv_Font_COPY_INP_TMP = New HTuple("Arial")
ElseIf New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("serif"))).I() Then
hv_Font_COPY_INP_TMP = New HTuple("TimesNewRomanPS")
End If
If ((New HTuple(hv_Bold_COPY_INP_TMP.TupleEqual(New
HTuple("true"))))).TupleOr( _
New HTuple(hv_Slant_COPY_INP_TMP.TupleEqual(New HTuple("true")))).I()
Then
hv_Font_COPY_INP_TMP = ((((hv_Font_COPY_INP_TMP.TupleAdd(New
HTuple("-")))).TupleAdd( _
hv_BoldString))).TupleAdd(hv_SlantString)
End If
hv_Font_COPY_INP_TMP = hv_Font_COPY_INP_TMP.TupleAdd(New HTuple("MT"))
Try
HOperatorSet.SetFont(hv_ExpDefaultWinHandle,
((hv_Font_COPY_INP_TMP.TupleAdd( _
New HTuple("-")))).TupleAdd(hv_Size_COPY_INP_TMP))
' catch (Exception)
Catch HDevExpDefaultException1 As HalconException
HDevExpDefaultException1.ToHTuple(hv_Exception)
'throw (Exception)
End Try
Else
'Set font for UNIX systems
hv_Size_COPY_INP_TMP = hv_Size_COPY_INP_TMP.TupleMult(New HTuple(1.25))
hv_AllowedFontSizes = (((((New
HTuple(11)).TupleConcat(14)).TupleConcat(17)).TupleConcat( _
20)).TupleConcat(25)).TupleConcat(34)
If New
HTuple(((hv_AllowedFontSizes.TupleFind(hv_Size_COPY_INP_TMP))).TupleEqual( _
New HTuple(-1))).I() Then
hv_Distances =
((hv_AllowedFontSizes.TupleSub(hv_Size_COPY_INP_TMP))).TupleAbs( _
)
HOperatorSet.TupleSortIndex(hv_Distances, hv_Indices)
hv_Size_COPY_INP_TMP =
hv_AllowedFontSizes.TupleSelect(hv_Indices.TupleSelect( _
New HTuple(0)))
End If
If ((New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("mono"))))).TupleOr( _
New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("Courier")))).I() Then
hv_Font_COPY_INP_TMP = New HTuple("courier")
ElseIf New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("sans"))).I() Then
hv_Font_COPY_INP_TMP = New HTuple("helvetica")
ElseIf New HTuple(hv_Font_COPY_INP_TMP.TupleEqual(New
HTuple("serif"))).I() Then
hv_Font_COPY_INP_TMP = New HTuple("times")
End If
If New HTuple(hv_Bold_COPY_INP_TMP.TupleEqual(New HTuple("true"))).I()
Then
hv_Bold_COPY_INP_TMP = New HTuple("bold")
131
Appendix
132
Appendix
End Try
End If
' dev_set_preferences(...); only in hdevelop
Exit Sub
End Sub
Try
'This procedure displays a 3D coordinate system.
'It needs the procedure gen_arrow_contour_xld.
'
'Input parameters:
'WindowHandle: The window where the coordinate system shall be displayed
'CamParam: The camera paramters
'Pose: The pose to be displayed
'CoordAxesLength: The length of the coordinate axes in world coordinates
'
'Check, if Pose is a correct pose tuple.
If New HTuple(((New HTuple(hv_Pose.TupleLength()))).TupleNotEqual(New
HTuple(7))).I() Then
ho_Arrows.Dispose()
Exit Sub
End If
'
'Poses with Z position zero cannot be projected
'(that would lead to a division by zero error).
If New HTuple(((hv_Pose.TupleSelect(New HTuple(2)))).TupleEqual(New
HTuple(0.0))).I() Then
ho_Arrows.Dispose()
Exit Sub
End If
'Convert to pose to a transformation matrix
HOperatorSet.PoseToHomMat3d(hv_Pose, hv_TransWorld2Cam)
'Project the world origin into the image
HOperatorSet.AffineTransPoint3d(hv_TransWorld2Cam, New HTuple(0), New
HTuple(0), _
133
Appendix
HOperatorSet.DistancePp(((hv_Row0.TupleConcat(hv_Row0))).TupleConcat(hv_Row0), _
((hv_Column0.TupleConcat(hv_Column0))).TupleConcat(hv_Column0),
((hv_RowAxX.TupleConcat( _
hv_RowAxY))).TupleConcat(hv_RowAxZ),
((hv_ColumnAxX.TupleConcat(hv_ColumnAxY))).TupleConcat( _
hv_ColumnAxZ), hv_Distance)
hv_HeadLength = ((((((((hv_Distance.TupleMax())).TupleDiv(New
HTuple(12.0)))).TupleConcat( _
New HTuple(5.0)))).TupleMax())).TupleInt()
ho_Arrows.Dispose()
gen_arrow_contour_xld(ho_Arrows,
((hv_Row0.TupleConcat(hv_Row0))).TupleConcat( _
hv_Row0),
((hv_Column0.TupleConcat(hv_Column0))).TupleConcat(hv_Column0), _
((hv_RowAxX.TupleConcat(hv_RowAxY))).TupleConcat(hv_RowAxZ),
((hv_ColumnAxX.TupleConcat( _
hv_ColumnAxY))).TupleConcat(hv_ColumnAxZ), hv_HeadLength,
hv_HeadLength)
'
'Display coordinate system
HOperatorSet.DispXld(ho_Arrows, hv_ExpDefaultWinHandle)
'
HOperatorSet.GetRgb(hv_ExpDefaultWinHandle, hv_Red, hv_Green, hv_Blue)
HOperatorSet.SetRgb(hv_ExpDefaultWinHandle, hv_Red.TupleSelect(New
HTuple(0)), _
hv_Green.TupleSelect(New HTuple(0)), hv_Blue.TupleSelect(New
HTuple(0)))
HOperatorSet.SetTposition(hv_ExpDefaultWinHandle, hv_RowAxX.TupleAdd(New
HTuple(3)), _
hv_ColumnAxX.TupleAdd(New HTuple(3)))
HOperatorSet.WriteString(hv_ExpDefaultWinHandle, New HTuple("X"))
HOperatorSet.SetRgb(hv_ExpDefaultWinHandle, hv_Red.TupleSelect((New
HTuple(1)).TupleMod( _
New HTuple(hv_Red.TupleLength()))), hv_Green.TupleSelect((New
HTuple(1)).TupleMod( _
New HTuple(hv_Green.TupleLength()))), hv_Blue.TupleSelect((New
HTuple(1)).TupleMod( _
New HTuple(hv_Blue.TupleLength()))))
HOperatorSet.SetTposition(hv_ExpDefaultWinHandle, hv_RowAxY.TupleAdd(New
HTuple(3)), _
hv_ColumnAxY.TupleAdd(New HTuple(3)))
HOperatorSet.WriteString(hv_ExpDefaultWinHandle, New HTuple("Y"))
134
Appendix
HOperatorSet.SetRgb(hv_ExpDefaultWinHandle, hv_Red.TupleSelect((New
HTuple(2)).TupleMod( _
New HTuple(hv_Red.TupleLength()))), hv_Green.TupleSelect((New
HTuple(2)).TupleMod( _
New HTuple(hv_Green.TupleLength()))), hv_Blue.TupleSelect((New
HTuple(2)).TupleMod( _
New HTuple(hv_Blue.TupleLength()))))
HOperatorSet.SetTposition(hv_ExpDefaultWinHandle, hv_RowAxZ.TupleAdd(New
HTuple(3)), _
hv_ColumnAxZ.TupleAdd(New HTuple(3)))
HOperatorSet.WriteString(hv_ExpDefaultWinHandle, New HTuple("Z"))
HOperatorSet.SetRgb(hv_ExpDefaultWinHandle, hv_Red, hv_Green, hv_Blue)
ho_Arrows.Dispose()
Exit Sub
Catch HDevExpDefaultException As HalconException
ho_Arrows.Dispose()
Throw HDevExpDefaultException
End Try
End Sub
Exit Sub
End Sub
135
Appendix
Exit Sub
End Sub
136
Appendix
137
Appendix
138
Appendix
Exit Sub
End Sub
Try
'This procedure generates arrow shaped XLD contours,
'pointing from (Row1, Column1) to (Row2, Column2).
'If starting and end point are identical, a contour consisting
'of a single point is returned.
'
'input parameteres:
'Row1, Column1: Coordinates of the arrows' starting points
'Row2, Column2: Coordinates of the arrows' end points
'HeadLength, HeadWidth: Size of the arrow heads in pixels
'
'output parameter:
'Arrow: The resulting XLD contour
'
'The input tuples Row1, Column1, Row2, and Column2 have to be of
'the same length.
'HeadLength and HeadWidth either have to be of the same length as
'Row1, Column1, Row2, and Column2 or have to be a single element.
'If one of the above restrictions is violated, an error will occur.
'
'
'Init
ho_Arrow.Dispose()
139
Appendix
HOperatorSet.GenEmptyObj(ho_Arrow)
'
'Calculate the arrow length
HOperatorSet.DistancePp(hv_Row1, hv_Column1, hv_Row2, hv_Column2,
hv_Length)
'
'Mark arrows with identical start and end point
'(set Length to -1 to avoid division-by-zero exception)
hv_ZeroLengthIndices = hv_Length.TupleFind(New HTuple(0))
If New HTuple(hv_ZeroLengthIndices.TupleNotEqual(New HTuple(-1))).I()
Then
If IsNothing(hv_Length) Then
hv_Length = New HTuple
End If
hv_Length(hv_ZeroLengthIndices) = New HTuple(-1)
End If
'
'Calculate auxiliary variables.
hv_DR = (((New
HTuple(1.0)).TupleMult(hv_Row2.TupleSub(hv_Row1)))).TupleDiv(hv_Length)
hv_DC = (((New
HTuple(1.0)).TupleMult(hv_Column2.TupleSub(hv_Column1)))).TupleDiv( _
hv_Length)
hv_HalfHeadWidth = hv_HeadWidth.TupleDiv(New HTuple(2.0))
'
'Calculate end points of the arrow head.
hv_RowP1 =
((hv_Row1.TupleAdd(((hv_Length.TupleSub(hv_HeadLength))).TupleMult( _
hv_DR)))).TupleAdd(hv_HalfHeadWidth.TupleMult(hv_DC))
hv_ColP1 =
((hv_Column1.TupleAdd(((hv_Length.TupleSub(hv_HeadLength))).TupleMult( _
hv_DC)))).TupleSub(hv_HalfHeadWidth.TupleMult(hv_DR))
hv_RowP2 =
((hv_Row1.TupleAdd(((hv_Length.TupleSub(hv_HeadLength))).TupleMult( _
hv_DR)))).TupleSub(hv_HalfHeadWidth.TupleMult(hv_DC))
hv_ColP2 =
((hv_Column1.TupleAdd(((hv_Length.TupleSub(hv_HeadLength))).TupleMult( _
hv_DC)))).TupleAdd(hv_HalfHeadWidth.TupleMult(hv_DR))
'
'Finally create output XLD contour for each input point pair
For hv_Index = (New HTuple(0)) To ( _
(New HTuple(hv_Length.TupleLength()))).TupleSub(New HTuple(1)) Step
(New HTuple(1))
If New HTuple(((hv_Length.TupleSelect(hv_Index))).TupleEqual(New
HTuple(-1))).I() Then
'Create_ single points for arrows with identical start and end
point
ho_TempArrow.Dispose()
HOperatorSet.GenContourPolygonXld(ho_TempArrow,
hv_Row1.TupleSelect(hv_Index), _
hv_Column1.TupleSelect(hv_Index))
Else
'Create arrow contour
ho_TempArrow.Dispose()
HOperatorSet.GenContourPolygonXld(ho_TempArrow,
((((((((((hv_Row1.TupleSelect( _
hv_Index))).TupleConcat(hv_Row2.TupleSelect(hv_Index)))).TupleConcat( _
hv_RowP1.TupleSelect(hv_Index)))).TupleConcat(hv_Row2.TupleSelect(hv_Index)))).TupleC
oncat( _
hv_RowP2.TupleSelect(hv_Index)))).TupleConcat(hv_Row2.TupleSelect(hv_Index)), _
((((((((((hv_Column1.TupleSelect(hv_Index))).TupleConcat(hv_Column2.TupleSelect( _
140
Appendix
hv_Index)))).TupleConcat(hv_ColP1.TupleSelect(hv_Index)))).TupleConcat( _
hv_Column2.TupleSelect(hv_Index)))).TupleConcat(hv_ColP2.TupleSelect( _
hv_Index)))).TupleConcat(hv_Column2.TupleSelect(hv_Index)))
End If
HOperatorSet.ConcatObj(ho_Arrow, ho_TempArrow, OTemp(0))
ho_Arrow.Dispose()
ho_Arrow = OTemp(0)
#If USE_DO_EVENTS Then
' Please note: The call of DoEvents() is only a hack to
' enable VB to react on events. Please change the code
' so that it can handle events in a standard way.
System.Windows.Forms.Application.DoEvents()
#End If
Next
ho_TempArrow.Dispose()
Exit Sub
Catch HDevExpDefaultException As HalconException
ho_TempArrow.Dispose()
Throw HDevExpDefaultException
End Try
End Sub
Try
'*****************************************
'** SHAPE BASED MATCHING WITH STL MODEL***
'*****************************************
dev_update_off()
' dev_get_preferences(...); only in hdevelop
' dev_set_preferences(...); only in hdevelop
'
141
Appendix
142
Appendix
HOperatorSet.HomMat3dToPose(hv_obj_H_cam, hv_PoseTmp1)
HDevelopStopMatch()
Throw HDevExpDefaultException
End Try
ho_ImageMatching.Dispose()
ho_ModelContours.Dispose()
HOperatorSet.CloseFramegrabber(hv_AcqHandle)
143
Appendix
End Sub
Sub InitHalcon()
' Default settings used in HDevelop
Call HOperatorSet.SetSystem(New HTuple("width"), New HTuple(512))
Sub FinishHalcon()
If ShapeRead = True Then
HOperatorSet.ClearShapeModel3d(hv_ShapeModel3DID)
End If
End
End Sub
End Module
A6.4. ConvertPose.vb
Option Explicit On
Imports HalconDotNet
Module HDevelopExportConvertPose
HOperatorSet.PoseToHomMat3d(hv_PoseTmp1, hv_Cam_H_Cylinder)
'Do transformation to obtain coordinate of the cylinder in robot base
coordinate system
'RobBase_H_Cylinder= RobBase_H_Cam * Cam_H_Cylinder
HOperatorSet.HomMat3dInvert(hv_Cam_H_RobBase, hv_RobBase_H_Cam)
HOperatorSet.HomMat3dCompose(hv_RobBase_H_Cam, hv_Cam_H_Cylinder,
hv_RobBase_H_Cylinder)
144
Appendix
HOperatorSet.HomMat3dToPose(hv_RobBase_H_Cylinder,
hv_Pose_Cylinder_in_RobBase)
If IsNothing(hv_Pose_Cylinder_in_RobBase) Then
hv_Pose_Cylinder_in_RobBase = New HTuple
End If
hv_Pose_Cylinder_in_RobBase(New HTuple(0)) =
((hv_Pose_Cylinder_in_RobBase.TupleSelect( _
New HTuple(0)))).TupleSub(New HTuple(0.0045))
If IsNothing(hv_Pose_Cylinder_in_RobBase) Then
hv_Pose_Cylinder_in_RobBase = New HTuple
End If
hv_Pose_Cylinder_in_RobBase(New HTuple(1)) =
((hv_Pose_Cylinder_in_RobBase.TupleSelect( _
New HTuple(1)))).TupleAdd(New HTuple(0.025))
If IsNothing(hv_Pose_Cylinder_in_RobBase) Then
hv_Pose_Cylinder_in_RobBase = New HTuple
End If
hv_Pose_Cylinder_in_RobBase(New HTuple(2)) =
((hv_Pose_Cylinder_in_RobBase.TupleSelect( _
New HTuple(2)))).TupleAdd(New HTuple(0.0041))
If IsNothing(hv_Pose_Cylinder_in_RobBase) Then
hv_Pose_Cylinder_in_RobBase = New HTuple
End If
End Sub
Sub InitHalcon()
' Default settings used in HDevelop
Call HOperatorSet.SetSystem(New HTuple("width"), New HTuple(512))
End Sub
Sub RunHalconConvert()
Call actionConvert()
End Sub
Sub RunHalconSavePose()
Call actionSavePose()
End Sub
End Module
145
Appendix
A6.5. Communication.vb
Option Explicit On
Imports HalconDotNet
Module HDevelopExportCommunication
'closing socket
HOperatorSet.CloseSocket(Socket)
Status = False
End Sub
Private Sub actionConnect()
End Sub
hv_Pose_Cylinder_in_RobBase(New HTuple(0)) =
hv_Pose_Cylinder_in_RobBase.TupleSelect(New HTuple(0)) * 1000
hv_Pose_Cylinder_in_RobBase(New HTuple(1)) =
hv_Pose_Cylinder_in_RobBase.TupleSelect(New HTuple(1)) * 1000
hv_Pose_Cylinder_in_RobBase(New HTuple(2)) =
hv_Pose_Cylinder_in_RobBase.TupleSelect(New HTuple(2)) * 1000
If IsNothing(hv_Pose_Cylinder_in_RobBase) Then
146
Appendix
'sending data
HOperatorSet.SendData(Socket, New HTuple("z"), hv_data_send_write, New
HTuple())
End Sub
Sub InitHalcon()
' Default settings used in HDevelop
Call HOperatorSet.SetSystem(New HTuple("width"), New HTuple(512))
End Sub
Sub RunHalconConnect()
Call actionConnect()
End Sub
Sub RunHalconDisconnect()
Call actionDisconnect()
End Sub
Sub RunHalconSend()
Call actionSend()
End Sub
End Module
Imports HalconDotNet
Imports System.IO
147
Appendix
Inherits System.Windows.Forms.Form
'Variables Declaration
Dim ShapeModelName(2) As String
Dim CamParamName(2) As String
End Sub
148
Appendix
149
Appendix
150
Appendix
Me.grbModel.Name = "grbModel"
Me.grbModel.Size = New System.Drawing.Size(231, 138)
Me.grbModel.TabIndex = 3
Me.grbModel.TabStop = False
Me.grbModel.Text = " Shape Model "
'
'txbShapeModel
'
Me.txbShapeModel.BackColor = System.Drawing.SystemColors.ControlLightLight
Me.txbShapeModel.Enabled = False
Me.txbShapeModel.Location = New System.Drawing.Point(9, 55)
Me.txbShapeModel.Name = "txbShapeModel"
Me.txbShapeModel.Size = New System.Drawing.Size(216, 20)
Me.txbShapeModel.TabIndex = 5
Me.txbShapeModel.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'btnOpenModel
'
Me.btnOpenModel.BackColor = System.Drawing.SystemColors.Menu
Me.btnOpenModel.Cursor = System.Windows.Forms.Cursors.Default
Me.btnOpenModel.Location = New System.Drawing.Point(88, 96)
Me.btnOpenModel.Name = "btnOpenModel"
Me.btnOpenModel.Size = New System.Drawing.Size(139, 29)
Me.btnOpenModel.TabIndex = 4
Me.btnOpenModel.Text = "Open Shape Model"
Me.btnOpenModel.UseVisualStyleBackColor = False
'
'lbl1
'
Me.lbl1.AutoSize = True
Me.lbl1.Location = New System.Drawing.Point(6, 39)
Me.lbl1.Name = "lbl1"
Me.lbl1.Size = New System.Drawing.Size(29, 13)
Me.lbl1.TabIndex = 2
Me.lbl1.Text = "File: "
'
'btnClose
'
Me.btnClose.Cursor = System.Windows.Forms.Cursors.Default
Me.btnClose.Location = New System.Drawing.Point(929, 547)
Me.btnClose.Name = "btnClose"
Me.btnClose.Size = New System.Drawing.Size(122, 30)
Me.btnClose.TabIndex = 4
Me.btnClose.Text = "Close"
Me.btnClose.UseVisualStyleBackColor = True
'
'btnMatching
'
Me.btnMatching.Cursor = System.Windows.Forms.Cursors.Default
Me.btnMatching.Location = New System.Drawing.Point(801, 546)
Me.btnMatching.Name = "btnMatching"
Me.btnMatching.Size = New System.Drawing.Size(122, 31)
Me.btnMatching.TabIndex = 5
Me.btnMatching.Text = "Match Piece"
Me.btnMatching.UseVisualStyleBackColor = True
'
'PictureBox1
'
Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"),
System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(641, 27)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(401, 122)
Me.PictureBox1.TabIndex = 6
Me.PictureBox1.TabStop = False
151
Appendix
'
'grbResults
'
Me.grbResults.BackColor = System.Drawing.SystemColors.MenuBar
Me.grbResults.Controls.Add(Me.txbRotZ)
Me.grbResults.Controls.Add(Me.txbRotY)
Me.grbResults.Controls.Add(Me.txbRotX)
Me.grbResults.Controls.Add(Me.txbPosZ)
Me.grbResults.Controls.Add(Me.txbPosY)
Me.grbResults.Controls.Add(Me.txbPosX)
Me.grbResults.Controls.Add(Me.txbNumPieces)
Me.grbResults.Controls.Add(Me.btnSend)
Me.grbResults.Controls.Add(Me.lbl9)
Me.grbResults.Controls.Add(Me.lbl8)
Me.grbResults.Controls.Add(Me.lbl7)
Me.grbResults.Controls.Add(Me.lbl6)
Me.grbResults.Controls.Add(Me.lbl5)
Me.grbResults.Controls.Add(Me.lbl4)
Me.grbResults.Controls.Add(Me.lbl3)
Me.grbResults.Controls.Add(Me.lbl2)
Me.grbResults.Cursor = System.Windows.Forms.Cursors.Default
Me.grbResults.Location = New System.Drawing.Point(641, 166)
Me.grbResults.Name = "grbResults"
Me.grbResults.Size = New System.Drawing.Size(401, 287)
Me.grbResults.TabIndex = 7
Me.grbResults.TabStop = False
Me.grbResults.Text = "Results of the Matching "
'
'txbRotZ
'
Me.txbRotZ.BackColor = System.Drawing.SystemColors.ControlLightLight
Me.txbRotZ.Enabled = False
Me.txbRotZ.Location = New System.Drawing.Point(106, 211)
Me.txbRotZ.Name = "txbRotZ"
Me.txbRotZ.Size = New System.Drawing.Size(272, 20)
Me.txbRotZ.TabIndex = 22
Me.txbRotZ.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'txbRotY
'
Me.txbRotY.BackColor = System.Drawing.SystemColors.ControlLightLight
Me.txbRotY.Enabled = False
Me.txbRotY.Location = New System.Drawing.Point(106, 180)
Me.txbRotY.Name = "txbRotY"
Me.txbRotY.Size = New System.Drawing.Size(272, 20)
Me.txbRotY.TabIndex = 21
Me.txbRotY.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'txbRotX
'
Me.txbRotX.BackColor = System.Drawing.SystemColors.ControlLightLight
Me.txbRotX.Enabled = False
Me.txbRotX.Location = New System.Drawing.Point(106, 153)
Me.txbRotX.Name = "txbRotX"
Me.txbRotX.Size = New System.Drawing.Size(272, 20)
Me.txbRotX.TabIndex = 20
Me.txbRotX.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'txbPosZ
'
Me.txbPosZ.BackColor = System.Drawing.SystemColors.ControlLightLight
Me.txbPosZ.Enabled = False
Me.txbPosZ.Location = New System.Drawing.Point(106, 126)
Me.txbPosZ.Name = "txbPosZ"
Me.txbPosZ.Size = New System.Drawing.Size(272, 20)
152
Appendix
Me.txbPosZ.TabIndex = 19
Me.txbPosZ.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'txbPosY
'
Me.txbPosY.BackColor = System.Drawing.SystemColors.ControlLightLight
Me.txbPosY.Enabled = False
Me.txbPosY.Location = New System.Drawing.Point(106, 100)
Me.txbPosY.Name = "txbPosY"
Me.txbPosY.Size = New System.Drawing.Size(272, 20)
Me.txbPosY.TabIndex = 18
Me.txbPosY.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'txbPosX
'
Me.txbPosX.BackColor = System.Drawing.SystemColors.ControlLightLight
Me.txbPosX.Enabled = False
Me.txbPosX.Location = New System.Drawing.Point(106, 75)
Me.txbPosX.Name = "txbPosX"
Me.txbPosX.Size = New System.Drawing.Size(272, 20)
Me.txbPosX.TabIndex = 17
Me.txbPosX.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'txbNumPieces
'
Me.txbNumPieces.BackColor = System.Drawing.SystemColors.ControlLightLight
Me.txbNumPieces.Enabled = False
Me.txbNumPieces.Location = New System.Drawing.Point(117, 23)
Me.txbNumPieces.Name = "txbNumPieces"
Me.txbNumPieces.Size = New System.Drawing.Size(47, 20)
Me.txbNumPieces.TabIndex = 16
Me.txbNumPieces.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'btnSend
'
Me.btnSend.BackColor = System.Drawing.SystemColors.Menu
Me.btnSend.Cursor = System.Windows.Forms.Cursors.Default
Me.btnSend.Location = New System.Drawing.Point(240, 253)
Me.btnSend.Name = "btnSend"
Me.btnSend.Size = New System.Drawing.Size(138, 28)
Me.btnSend.TabIndex = 15
Me.btnSend.Text = "Send Pose to Robot"
Me.btnSend.UseVisualStyleBackColor = False
'
'lbl9
'
Me.lbl9.AutoSize = True
Me.lbl9.Location = New System.Drawing.Point(53, 214)
Me.lbl9.Name = "lbl9"
Me.lbl9.Size = New System.Drawing.Size(43, 13)
Me.lbl9.TabIndex = 8
Me.lbl9.Text = "Rot(Z): "
'
'lbl8
'
Me.lbl8.AutoSize = True
Me.lbl8.Location = New System.Drawing.Point(53, 183)
Me.lbl8.Name = "lbl8"
Me.lbl8.Size = New System.Drawing.Size(43, 13)
Me.lbl8.TabIndex = 7
Me.lbl8.Text = "Rot(Y): "
'
'lbl7
'
Me.lbl7.AutoSize = True
153
Appendix
154
Appendix
Me.GroupBox1.Controls.Add(Me.lbl10)
Me.GroupBox1.Controls.Add(Me.btnCameraParameters)
Me.GroupBox1.Location = New System.Drawing.Point(23, 450)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(244, 138)
Me.GroupBox1.TabIndex = 9
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Camera Parameters"
'
'txbCamParam
'
Me.txbCamParam.BackColor = System.Drawing.SystemColors.ControlLightLight
Me.txbCamParam.Enabled = False
Me.txbCamParam.Location = New System.Drawing.Point(9, 55)
Me.txbCamParam.Name = "txbCamParam"
Me.txbCamParam.Size = New System.Drawing.Size(229, 20)
Me.txbCamParam.TabIndex = 6
Me.txbCamParam.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
'
'lbl10
'
Me.lbl10.AutoSize = True
Me.lbl10.Location = New System.Drawing.Point(6, 39)
Me.lbl10.Name = "lbl10"
Me.lbl10.Size = New System.Drawing.Size(26, 13)
Me.lbl10.TabIndex = 5
Me.lbl10.Text = "File:"
'
'btnCameraParameters
'
Me.btnCameraParameters.BackColor = System.Drawing.SystemColors.Menu
Me.btnCameraParameters.Cursor = System.Windows.Forms.Cursors.Default
Me.btnCameraParameters.Location = New System.Drawing.Point(80, 94)
Me.btnCameraParameters.Name = "btnCameraParameters"
Me.btnCameraParameters.Size = New System.Drawing.Size(158, 31)
Me.btnCameraParameters.TabIndex = 5
Me.btnCameraParameters.Text = "Open Camera Parameters"
Me.btnCameraParameters.UseVisualStyleBackColor = False
'
'mnsVisionForm
'
Me.mnsVisionForm.BackColor = System.Drawing.SystemColors.MenuBar
Me.mnsVisionForm.Items.AddRange(New System.Windows.Forms.ToolStripItem()
{Me.FilesToolStripMenuItem, Me.ActionsToolStripMenuItem, Me.HelpToolStripMenuItem})
Me.mnsVisionForm.Location = New System.Drawing.Point(0, 0)
Me.mnsVisionForm.Name = "mnsVisionForm"
Me.mnsVisionForm.Size = New System.Drawing.Size(1059, 24)
Me.mnsVisionForm.TabIndex = 10
'
'FilesToolStripMenuItem
'
Me.FilesToolStripMenuItem.DropDownItems.AddRange(New
System.Windows.Forms.ToolStripItem() {Me.mnsOpenCamParam, Me.mnsOpenShapeModel})
Me.FilesToolStripMenuItem.Name = "FilesToolStripMenuItem"
Me.FilesToolStripMenuItem.Size = New System.Drawing.Size(40, 20)
Me.FilesToolStripMenuItem.Text = "Files"
'
'mnsOpenCamParam
'
Me.mnsOpenCamParam.Name = "mnsOpenCamParam"
Me.mnsOpenCamParam.Size = New System.Drawing.Size(209, 22)
Me.mnsOpenCamParam.Text = "Open Camera Parameters"
'
'mnsOpenShapeModel
'
155
Appendix
Me.mnsOpenShapeModel.Name = "mnsOpenShapeModel"
Me.mnsOpenShapeModel.Size = New System.Drawing.Size(209, 22)
Me.mnsOpenShapeModel.Text = "Open 3D Shape Model "
'
'ActionsToolStripMenuItem
'
Me.ActionsToolStripMenuItem.DropDownItems.AddRange(New
System.Windows.Forms.ToolStripItem() {Me.mnsAcquire, Me.mnsCreateShapeModel,
Me.mnsMatchPiece, Me.mnsClose})
Me.ActionsToolStripMenuItem.Name = "ActionsToolStripMenuItem"
Me.ActionsToolStripMenuItem.Size = New System.Drawing.Size(57, 20)
Me.ActionsToolStripMenuItem.Text = "Actions "
'
'mnsAcquire
'
Me.mnsAcquire.Name = "mnsAcquire"
Me.mnsAcquire.Size = New System.Drawing.Size(187, 22)
Me.mnsAcquire.Text = "Acquire a New Image"
'
'mnsCreateShapeModel
'
Me.mnsCreateShapeModel.Name = "mnsCreateShapeModel"
Me.mnsCreateShapeModel.Size = New System.Drawing.Size(187, 22)
Me.mnsCreateShapeModel.Text = "Create Shape Model "
'
'mnsMatchPiece
'
Me.mnsMatchPiece.Name = "mnsMatchPiece"
Me.mnsMatchPiece.Size = New System.Drawing.Size(187, 22)
Me.mnsMatchPiece.Text = "Match Piece"
'
'mnsClose
'
Me.mnsClose.Name = "mnsClose"
Me.mnsClose.Size = New System.Drawing.Size(187, 22)
Me.mnsClose.Text = "Close Application"
'
'HelpToolStripMenuItem
'
Me.HelpToolStripMenuItem.DropDownItems.AddRange(New
System.Windows.Forms.ToolStripItem() {Me.ForFurtherInformationToolStripMenuItem,
Me.DesignInformationToolStripMenuItem})
Me.HelpToolStripMenuItem.Name = "HelpToolStripMenuItem"
Me.HelpToolStripMenuItem.Size = New System.Drawing.Size(40, 20)
Me.HelpToolStripMenuItem.Text = "Help"
'
'ForFurtherInformationToolStripMenuItem
'
Me.ForFurtherInformationToolStripMenuItem.DropDownItems.AddRange(New
System.Windows.Forms.ToolStripItem() {Me.WwwacrobeToolStripMenuItem,
Me.WwwhalconcomToolStripMenuItem})
Me.ForFurtherInformationToolStripMenuItem.Name =
"ForFurtherInformationToolStripMenuItem"
Me.ForFurtherInformationToolStripMenuItem.Size = New System.Drawing.Size(197,
22)
Me.ForFurtherInformationToolStripMenuItem.Text = "For Further information"
'
'WwwacrobeToolStripMenuItem
'
Me.WwwacrobeToolStripMenuItem.Name = "WwwacrobeToolStripMenuItem"
Me.WwwacrobeToolStripMenuItem.Size = New System.Drawing.Size(167, 22)
Me.WwwacrobeToolStripMenuItem.Text = "www.acro.be"
'
'WwwhalconcomToolStripMenuItem
'
156
Appendix
Me.WwwhalconcomToolStripMenuItem.Name = "WwwhalconcomToolStripMenuItem"
Me.WwwhalconcomToolStripMenuItem.Size = New System.Drawing.Size(167, 22)
Me.WwwhalconcomToolStripMenuItem.Text = "www.halcon.com"
'
'DesignInformationToolStripMenuItem
'
Me.DesignInformationToolStripMenuItem.DropDownItems.AddRange(New
System.Windows.Forms.ToolStripItem()
{Me.DevelopedByJoseManuelPastorAlcarazForACROKHLimToolStripMenuItem})
Me.DesignInformationToolStripMenuItem.Name =
"DesignInformationToolStripMenuItem"
Me.DesignInformationToolStripMenuItem.Size = New System.Drawing.Size(197, 22)
Me.DesignInformationToolStripMenuItem.Text = "Design Information"
'
'DevelopedByJoseManuelPastorAlcarazForACROKHLimToolStripMenuItem
'
Me.DevelopedByJoseManuelPastorAlcarazForACROKHLimToolStripMenuItem.Name =
"DevelopedByJoseManuelPastorAlcarazForACROKHLimToolStripMenuItem"
Me.DevelopedByJoseManuelPastorAlcarazForACROKHLimToolStripMenuItem.Size = New
System.Drawing.Size(373, 22)
Me.DevelopedByJoseManuelPastorAlcarazForACROKHLimToolStripMenuItem.Text =
"Developed by Jose Manuel Pastor Alcaraz for ACRO (KHLim)"
'
'VisionTool
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(1059, 600)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.btnCreateShapeModel)
Me.Controls.Add(Me.grbResults)
Me.Controls.Add(Me.PictureBox1)
Me.Controls.Add(Me.btnMatching)
Me.Controls.Add(Me.btnClose)
Me.Controls.Add(Me.grbModel)
Me.Controls.Add(Me.Status)
Me.Controls.Add(Me.btnAcquirement)
Me.Controls.Add(Me.HWinCtrl)
Me.Controls.Add(Me.mnsVisionForm)
Me.Cursor = System.Windows.Forms.Cursors.Default
Me.HelpButton = True
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MainMenuStrip = Me.mnsVisionForm
Me.Name = "VisionTool"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "3D Shape-Based Matching "
Me.grbModel.ResumeLayout(False)
Me.grbModel.PerformLayout()
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
Me.grbResults.ResumeLayout(False)
Me.grbResults.PerformLayout()
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox1.PerformLayout()
Me.mnsVisionForm.ResumeLayout(False)
Me.mnsVisionForm.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
157
Appendix
End Sub
If Len(ofdShapeModel.FileName) = 0 Then
'Do nothing
Else
ShapeModelName = Split(ofdShapeModel.SafeFileName, ".")
End Sub
Call FinishHalcon()
End
End Sub
End Sub
158
Appendix
If Len(ofdCamera.FileName) = 0 Then
'Do nothing
Else
CamParamName = Split(ofdCamera.SafeFileName, ".")
If CamParamName(CamParamName.Length - 1) = "cal" Then
txbCamParam.Text = ofdCamera.SafeFileName()
CamParamDirectory = (ofdCamera.FileName())
Else
txbCamParam.Text = "File extension invalid, charge again"
End If
End If
End Sub
If Len(ofdCamera.FileName) = 0 Or Len(ofdShapeModel.FileName) = 0 Or
CamParamName(CamParamName.Length - 1) <> "cal" Or
ShapeModelName(ShapeModelName.Length - 1) <> "sm3" Then
End Sub
159
Appendix
End Sub
Imports HalconDotNet
Imports System.IO
End Sub
If Len(ofdSTLModel.FileName) = 0 Then
'Do nothing
Else
160
Appendix
End Sub
ShapeCreated = False
Me.Close()
End Sub
End Sub
ShapeCreated = False
161
Appendix
End If
End Sub
Imports HalconDotNet
Imports System.IO
'Variables Declaration
Dim CamRobName(2) As String
Dim Poseconverted As Boolean = False
txbIP.Text = IpMemo
txbPort.Text = PortMemo
txbIP.Enabled = True
txbPort.Enabled = True
btnDisconnect.Enabled = False
btnConnect.Enabled = True
btnSend.Enabled = False
txbStatus.Text = "Disconnected"
End Sub
162
Appendix
Call RunHalconConvert()
Poseconverted = True
End If
End Sub
If Len(ofdCamRob.FileName) = 0 Then
'Do nothing
Else
CamRobName = Split(ofdCamRob.SafeFileName, ".")
Else
txbCamRobPos.Text = "File extension invalid, charge again"
End If
End If
End Sub
163
Appendix
Else
Call MessageBox.Show("Pose has to be converted", Me.Text,
MessageBoxButtons.OK)
End If
End Sub
End Sub
IPParts = IPstring.Split(".")
If IPParts.Length = 4 Then
If IsNumeric(CInt(IPParts(0)) > 0 And CInt(IPParts(0)) < 255) Then
If IsNumeric(CInt(IPParts(1)) > 0 And CInt(IPParts(1)) < 255)
Then
If IsNumeric(CInt(IPParts(2)) > 0 And CInt(IPParts(2)) < 255)
Then
If IsNumeric(CInt(IPParts(3)) > 0 And CInt(IPParts(3)) <
255) Then
'Run the procedure of connection
Call RunHalconConnect()
txbIP.Enabled = False
txbPort.Enabled = False
btnDisconnect.Enabled = True
btnConnect.Enabled = False
btnSend.Enabled = True
txbStatus.Text = "Connected"
IpMemo = txbIP.Text
PortMemo = txbPort.Text
Else
Call MessageBox.Show("IP is not correct", Me.Text,
MessageBoxButtons.OK)
End If
Else
Call MessageBox.Show("IP is not correct", Me.Text,
MessageBoxButtons.OK)
End If
Else
Call MessageBox.Show("IP is not correct", Me.Text,
MessageBoxButtons.OK)
End If
164
Appendix
Else
Call MessageBox.Show("IP is not correct", Me.Text,
MessageBoxButtons.OK)
End If
Else
Call MessageBox.Show("IP is not correct", Me.Text,
MessageBoxButtons.OK)
End If
Else
Call MessageBox.Show("Introduce correct IP and Port", Me.Text,
MessageBoxButtons.OK)
End If
End Sub
165
Appendix
A6.10. Module1.vb
Imports HalconDotNet
Imports System.IO
Module Module1
'Communication
Public ip As HTuple = New HTuple, Port As Integer
Public Status As Boolean = False
Public Socket As HTuple = New HTuple
Public IpMemo As String = "10.10.107.25"
Public PortMemo As String = "9901"
End Module
166