taobin_project/xml/page_identity_verification.xml
2023-08-04 15:29:38 +07:00

657 lines
16 KiB
XML

<Popup>
<Cache> "Enable" </Cache>
<Width> 1080 </Width>
<Height> 1920 </Height>
<Background> "0xeae6e1" </Background>
<Volume> SoundVolume </Volume>
<EventOpen>
Var KornCropCountDown = 5
Var KornIsShuttered = "false"
Var KornOpenFaceCompareCountDown = 10
Var KornIsCropped = "false"
; Note:
; - Can't change roi and camera params in xml,
; because the java code is not dynamic.
; (It's a work-around method. (Maybe) Improve later.)
; Absolute positions
Var KornRoiX = 440
Var KornRoiY = 909
Var KornRoiW = 200
Var KornRoiH = 200
Var KornRoiStepY = 40
; Re-calculate these values when either,
; - CameraX size changes
; - CameraX's hidden part size changes
Var KornCamDisplayX = 285
Var KornCamDisplayY = 781
Var KornCamDisplayW = 500
Var KornCamDisplayH = 680
Var KornCamYHidden = 208
Var KornCamX = KornCamDisplayX
Var KornCamY = KornCamDisplayY - KornCamYHidden
Var KornCamW = KornCamDisplayW
Var KornCamH = KornCamDisplayH + KornCamYHidden
Var KornRoiYMin = KornCamDisplayY
Var KornRoiYRange = 220
Var KornRoiYMax = KornCamDisplayY + KornRoiYRange
; To shrink the roi size, use this variable,
; (value is between 0 and 100 (unit = percent))
Var KornRoiPercentShrink = 30
Var KornCamRoiDeltaX = KornRoiW * KornRoiPercentShrink
Var KornCamRoiDeltaX = KornCamRoiDeltaX / 100
Var KornCamRoiDeltaY = KornRoiH * KornRoiPercentShrink
Var KornCamRoiDeltaY = KornCamRoiDeltaY / 100
Var KornCamRoiW = KornRoiW - KornCamRoiDeltaX
Var KornCamRoiH = KornRoiH - KornCamRoiDeltaY
; CameraX params
Var KornCameraXOffsetX = 150
Var KornCameraXX = KornCamDisplayX - KornCameraXOffsetX
Var KornCameraXY = KornCamDisplayY
Var KornCameraXW = 800
Var KornCameraXH = 800
; 800 = magic number
Var CamFlag = 0
Var CamCount = 0
Var Timeout = 0
Var ShutterResult = "-"
Var AdultFlag = 1
If AdultFlag = 1 Then
Var AdultFlag = 0
DEBUGVAR SystemDate
Var sdate = ""
Var sdate = SystemDate
Var sdateday = ""
Var sdatemonth = ""
Var sdateyear = ""
SPLIT sdate "/" 1 sdateday
SPLIT sdate "/" 2 sdatemonth
SPLIT sdate "/" 3 sdateyear
INT sdateday
INT sdatemonth
INT sdateyear
Var AdultState = "Enable"
Var AdultState1 = "Enable"
Var countAdultS2 = 0
Var AdultFlag2 = 1
EndIf
If show_eng = "true" Then
Var DirImage = "ROOT/taobin_project/image/page_payment_en/page_payment"
Var DirImage2 = "ROOT/taobin_project/image/page_payment_cash_extend_en"
Var page_doing_show_time_image = "ROOT/taobin_project/image/page_doing/img2.png"
Else
Var DirImage = "ROOT/taobin_project/image/page_payment"
Var DirImage2 = "ROOT/taobin_project/image/page_payment_cash_extend"
Var page_doing_show_time_image = "ROOT/taobin_project/image/page_doing/img2.png"
EndIf
If CameraCount = 1 Then
EndIf
Var IDBirthdate = ""
Var LivenessResult = ""
Var CountDownDelayReadCardID = 3
DEBUGVAR CameraCount
;STOPCARDID
Var LivenessShowString = ""
Var CameraStage = "Invisible"
Var IDcardStage = "Enable"
Var IDcardStageText = "Enable"
Var load_gif_stage = "Invisible"
Var IDcardTextStatus = "โปรดเสียบบัตรประชาชน \nเพื่อดำเนินการต่อ"
Var LivenessRestartCount = 0
Var FailTrickCount = 0
Var FrameOfFaceStepMoveY = 40
Var FrameOfFaceXPosition = 440
Var FrameOfFaceYPosition = 909
Var FrameOfFaceCropImageYPosition = 230
</EventOpen>
<EventActionOk>
</EventActionOk>
<EventActionError>
</EventActionError>
<EventIDCard>
DEBUGVAR IDCardStatus
DEBUGVAR IDCardReady
DEBUGVAR IDCardData
DEBUGVAR IDBirthdate
DEBUGVAR IDFullNameEng
If IDCardStatus = "OK" Then
If IDCardReady = "OK" Then
If IDCardData = "START" Then
Var load_gif_stage = "Enable"
Var IDcardStageText = "Invisible"
RefreshAll
EndIf
EndIf
EndIf
If IDCardStatus = "OK" Then
If IDCardReady = "OK" Then
If IDCardData = "ERROR" Then
Var load_gif_stage = "Invisible"
Var IDcardStageText = "Enable"
Var IDcardTextStatus = "อ่านบัตรไม่ได้อะ"
Refresh
EndIf
EndIf
EndIf
If IDCardStatus = "ERROR" Then
Var load_gif_stage = "Invisible"
Var IDcardStageText = "Enable"
Var IDcardTextStatus = "อ่านบัตรไม่ได้เลยนะ"
Refresh
EndIf
If IDCardStatus = "OK" Then
If IDCardReady = "OK" Then
If IDCardData = "DONE" Then
;Var birthDate = IDBirthdate
Var StrYear = ""
Var StrMon = ""
Var StrDay = ""
SUBSTRING IDBirthdate 0 4 StrYear
SUBSTRING IDBirthdate 4 6 StrMon
SUBSTRING IDBirthdate 6 8 StrDay
INT StrYear
INT StrMon
INT StrDay
Var Adult20 = 0
DEBUGVAR StrYear
DEBUGVAR StrMon
DEBUGVAR StrDay
DEBUGVAR sdatemonth
DEBUGVAR sdateday
Var sdateyear = sdateyear + 543
Var AgeNumber = sdateyear - StrYear
DEBUGVAR AgeNumber
If AgeNumber >= 20 Then
If AgeNumber = 20 Then
If sdatemonth > StrMon Then
Var Adult20 = 1
Else
If sdatemonth = StrMon Then
If sdateday >= StrDay Then
Var Adult20 = 1
EndIf
EndIf
EndIf
Else
Var Adult20 = 1
EndIf
Else
EndIf
If Adult20 = 1 Then
LivenessCommand "SetY" KornRoiY
LivenessCommand "SetX" KornRoiX
LivenessCommand "start" 0
Var load_gif_stage = "Invisible"
Var IDcardStageText = "Invisible"
Var IDcardStage = "Invisible"
Var IDcardTextStatus = "แสกนหน้า"
Var CameraStage = "Enable"
Refresh
EndIf
EndIf
EndIf
EndIf
</EventIDCard>
<Timeout> 1000 </Timeout>
<EventTimeout>
DEBUGVAR IDCardStatus
DEBUGVAR IDCardReady
DEBUGVAR IDCardData
DEBUGVAR IDBirthdate
DEBUGVAR CountDownDelayReadCardID
DEBUGVAR ShutterResult
DEBUGVAR IDCardState
Var KornCamRoiDeltaXTmp = KornCamRoiDeltaX / 2
Var KornCamRoiX = KornRoiX + KornCamRoiDeltaXTmp
Var KornCamRoiY = KornRoiY
If IDBirthdate = "" Then
Var CountDownDelayReadCardID = CountDownDelayReadCardID - 1
If CountDownDelayReadCardID = 0 Then
READCARDID
Var CountDownDelayReadCardID = 600
EndIf
EndIf
DEBUGVAR Timeout
Var Timeout = Timeout + 1
If Timeout > 120 Then
Open "ROOT/taobin_project/xml/page_catalog2.xml"
EndIf
;If ShutterResult = "ok" Then
; Open "ROOT/taobin_project/xml/page_face_compare.xml"
;EndIf
DEBUGVAR LivenessResult
If LivenessResult = "pass" Then
If KornCropCountDown > 0 Then
DEBUGVAR KornCropCountDown
Var KornCropCountDown = KornCropCountDown - 1
Var LivenessShowString = "Pass "
Var load_gif_stage = "Enable"
If KornIsShuttered = "false" Then
CameraCmd "usbfront" "shutter" "/mnt/sdcard/camera1.jpg"
Var KornShutter = "Shuttered"
DEBUGVAR KornShutter
Var KornIsShuttered = "true"
EndIf
EndIf
If KornCropCountDown <= 0 Then
If KornIsCropped = "false" Then
CROP_IMAGE "/mnt/sdcard/camera1.jpg" "/mnt/sdcard/camera1_alter.jpg"
Var KornCrop = "Cropped"
DEBUGVAR KornCrop
Var KornIsCropped = "true"
EndIf
DEBUGVAR KornOpenFaceCompareCountDown
Var KornOpenFaceCompareCountDown = KornOpenFaceCompareCountDown - 1
If KornOpenFaceCompareCountDown <= 0 Then
Open "ROOT/taobin_project/xml/page_face_compare.xml"
EndIf
EndIf
EndIf
If LivenessResult = "fail" Then
Var LivenessRestartCount = LivenessRestartCount + 1
If LivenessRestartCount = 2 Then
Var LivenessRestartCount = 0
LivenessCommand "stop" 0
LivenessCommand "start" 0
Var LivenessResult = "-"
EndIf
EndIf
If IDCardState = "PRESENT" Then
If IDCardStatus = "ERROR" Then
Var load_gif_stage = "Invisible"
Var IDcardStageText = "Enable"
Var IDcardTextStatus = "อ่านบัตรไม่ได้อะ"
Refresh
EndIf
EndIf
DEBUGVAR LivenessFramePositionX
DEBUGVAR LivenessFramePositionY
Refresh
TimerReset
</EventTimeout>
<Video>
<X> 0 </X>
<Y> 0 </Y>
<Width> 1080</Width>
<Height> 380 </Height>
<Loop> "true" </Loop>
<Filename> video_menu_0 </Filename>
</Video>
<Image>
<X> 0 </X>
<Y> 380 </Y>
<State> "Enable" </State>
<Filename> "ROOT/taobin_project/image/page_payment/alpha.png" </Filename>
</Image>
<Image>
<X> 123 </X>
<Y> 598 </Y>
<State> CameraStage </State>
<Filename> "ROOT/taobin_project/image/liveness/bg2.png" </Filename>
</Image>
<Text>
<X> 0 </X>
<Y> 602 </Y>
<Width> 1080</Width>
<Align> Center </Align>
<Size> 60 </Size>
<Font> KanitMediumTTF </Font>
<Color> 0xDE794E </Color>
<State> CameraStage </State>
<Value> LivenessShowString </Value>
</Text>
; back
<Button>
<X> 356 </X>
<Y> 1608 </Y>
<Filename> "ROOT/taobin_project/image/liveness/bn_cancel.png" </Filename>
<FilenamePress> "ROOT/taobin_project/image/liveness/bn_cancel.png" </FilenamePress>
<Sound> "/mnt/sdcard/coffeevending/wav/click.wav" </Sound>
<Volume> SoundVolume </Volume>
<EventClick>
SAVELOG "Liveness Result - Cancel"
Open "ROOT/taobin_project/xml/page_catalog2.xml"
</EventClick>
</Button>
; arrow up
<Button>
<X> 20 </X>
<Y> 888 </Y>
<Width>180</Width>
<Height>180</Height>
<Filename> "ROOT/taobin_project/image/liveness/arrow_up.png" </Filename>
<FilenamePress> "ROOT/taobin_project/image/liveness/arrow_up.png" </FilenamePress>
<Sound> "/mnt/sdcard/coffeevending/wav/click.wav" </Sound>
<Volume> SoundVolume </Volume>
<EventClick>
SAVELOG "Allow up"
Var KornRoiYTmp = KornRoiY - KornRoiStepY
If KornRoiYTmp > KornRoiYMin Then
Var KornRoiY = KornRoiYTmp
DEBUGVAR KornRoiY
LivenessCommand "SetY" KornRoiY
LivenessCommand "stop" 0
LivenessCommand "start" 0
EndIf
</EventClick>
</Button>
; arrow down
<Button>
<X> 20 </X>
<Y> 1249 </Y>
<Width>180</Width>
<Height>180</Height>
<Filename> "ROOT/taobin_project/image/liveness/arrow_down.png" </Filename>
<FilenamePress> "ROOT/taobin_project/image/liveness/arrow_down.png" </FilenamePress>
<Sound> "/mnt/sdcard/coffeevending/wav/click.wav" </Sound>
<Volume> SoundVolume </Volume>
<EventClick>
SAVELOG "Allow down"
Var KornRoiYTmp = KornRoiY + KornRoiStepY
If KornRoiYTmp < KornRoiYMax Then
Var KornRoiY = KornRoiYTmp
DEBUGVAR KornRoiY
LivenessCommand "SetY" KornRoiY
LivenessCommand "stop" 0
LivenessCommand "start" 0
EndIf
</EventClick>
</Button>
; arrow up
<Button>
<X> 892 </X>
<Y> 888 </Y>
<Width>180</Width>
<Height>180</Height>
<Filename> "ROOT/taobin_project/image/liveness/arrow_up.png" </Filename>
<FilenamePress> "ROOT/taobin_project/image/liveness/arrow_up.png" </FilenamePress>
<Sound> "/mnt/sdcard/coffeevending/wav/click.wav" </Sound>
<Volume> SoundVolume </Volume>
<EventClick>
SAVELOG "Allow up"
Var KornRoiYTmp = KornRoiY - KornRoiStepY
If KornRoiYTmp > KornRoiYMin Then
Var KornRoiY = KornRoiYTmp
DEBUGVAR KornRoiY
LivenessCommand "SetY" KornRoiY
LivenessCommand "stop" 0
LivenessCommand "start" 0
EndIf
</EventClick>
</Button>
; arrow down
<Button>
<X> 892 </X>
<Y> 1249 </Y>
<Width>180</Width>
<Height>180</Height>
<Filename> "ROOT/taobin_project/image/liveness/arrow_down.png" </Filename>
<FilenamePress> "ROOT/taobin_project/image/liveness/arrow_down.png" </FilenamePress>
<Sound> "/mnt/sdcard/coffeevending/wav/click.wav" </Sound>
<Volume> SoundVolume </Volume>
<EventClick>
SAVELOG "Allow down"
;Var KornRoiYTmp = KornRoiY + KornRoiStepY
;If KornRoiYTmp < KornRoiYMax Then
; Var KornRoiY = KornRoiYTmp
; DEBUGVAR KornRoiY
; LivenessCommand "SetY" KornRoiY
; LivenessCommand "stop" 0
; LivenessCommand "start" 0
;EndIf
Var LivenessResult = "pass"
</EventClick>
</Button>
<Image>
<X> 196 </X>
<Y> 737 </Y>
<Filename> "ROOT/taobin_project/image/liveness/bg_21.png" </Filename>
</Image>
<CameraX>
<X> KornCameraXX </X>
;140
<Y> KornCameraXY </Y>
;781
<Name>"usbfront"</Name>
<Width> KornCameraXW </Width>
;800
; Display width is about 500, (full width is about the same)
<Height> KornCameraXH </Height>
;800
; Display height is about 680, (full height = 888)
<LivenessParameterWhenOK> "FileName=/mnt/sdcard/camera1_alter.jpg" </LivenessParameterWhenOK>
</CameraX>
<Image>
<X> KornCamRoiX </X>
;FrameOfFaceXPosition
<Y> KornCamRoiY </Y>
;FrameOfFaceYPosition
<Width> KornCamRoiW </Width>
;200
<Height> KornCamRoiH </Height>
;200
<State> CameraStage </State>
<Filename> "ROOT/taobin_project/image/liveness/bg3.png" </Filename>
</Image>
<Image>
<X> 196 </X>
<Y> 737 </Y>
<State> IDcardStage </State>
<Filename> "ROOT/taobin_project/image/liveness/bg_21.png" </Filename>
</Image>
<Text>
<X> 0 </X>
<Y> 1050 </Y>
<State> IDcardStageText </State>
<Width> 1080</Width>
<Align> Center </Align>
<Size> 56 </Size>
<Font> KanitMediumTTF </Font>
<Color> 0xDE794E </Color>
<Value> IDcardTextStatus </Value>
</Text>
<GIF>
<X> 440 </X>
<Y> 988 </Y>
<State> load_gif_stage </State>
<Filename> "ROOT/taobin_project/image/page_payment/loading.gif"</Filename>
</GIF>
<EventCamera>
DEBUGVAR BugFlag
If BugFlag = 0 Then
Var BugFlag = 1
EndIf
</EventCamera>
<EventLivenessState>
DEBUGVAR LivenessStateString
DEBUGVAR LivenessStateForPlaySound
Var SoundWavFileName = "/mnt/sdcard/coffeevending/taobin_project/liveness/sound/" + LivenessStateForPlaySound
Var SoundWavFileName = SoundWavFileName + ".wav"
DEBUGVAR SoundWavFileName
DEBUGVAR PrevSoundWavFileName
If PrevSoundWavFileName = SoundWavFileName Then
Else
Play SoundWavFileName
Var PrevSoundWavFileName = SoundWavFileName
EndIf
If LivenessResult = "pass" Then
Else
Var LivenessShowString = LivenessStateString
EndIf
Refresh
</EventLivenessState>
<EventLivenessResult>
DEBUGVAR LivenessResult
If LivenessResult = "pass" Then
Var strlog_liveness = "Liveness Result - pass " + FailTrickCount
SAVELOG strlog_liveness
Else
Var FailTrickCount = FailTrickCount + 1
Var strlog_liveness = "Liveness Result - fail " + FailTrickCount
SAVELOG strlog_liveness
EndIf
</EventLivenessResult>
<EventUnitTest1>
Var IDCardStatus = "OK"
Var IDCardReady = "OK"
Var IDCardData = "START"
EventEvaluate "EventIDCard"
</EventUnitTest1>
<EventUnitTest2>
Var IDBirthdate = 25271014
Var IDCardStatus = "OK"
Var IDCardReady = "OK"
Var IDCardData = "DONE"
EventEvaluate "EventIDCard"
</EventUnitTest2>
<EventUnitTest3>
Var LivenessResult = "pass"
EventEvaluate "EventLivenessState"
</EventUnitTest3>
<EventUnitTest4>
Var IDCardState = "PRESENT"
Var IDCardStatus = "ERROR"
Var IDCardReady = "ERROR"
Var IDCardData = "ERROR"
</EventUnitTest4>
</Popup>