其实Kofax提供的VBDemo就有这个东西在Form上添加扫描控件(Kscan)和图像处理控件(Kimgp),由于其条码识别是在扫描或导入中 处理,所有必须添加扫描控件,并将Kimgp与Kscan关联。即Kimgp1.ImageProcCtl=KScan1.将 Kimgp1的Barcode先Enable,最后在KScan的PageEnd中进行条码识别,如下是识别大概处理:Static Function BarcodesInterpretScannerSettings(kscn As KScan) As Integer '***** Parameters ' kscn (I) KScan control
Dim nPos As Integer Dim nColonPos As Integer Dim nBarCnt As Integer Dim nStatus As Integer Dim sSetting As String Dim sValue As String Dim errmsg As String '***** Exit right away if no bar codes were found If frmAnalysis!KImgp1.PEBarCodeCount = 0 Then BarcodesInterpretScannerSettings = SUCCESS Exit Function End If '***** For each bar code found on the page For nBarCnt = 1 To frmAnalysis!KImgp1.PEBarCodeCount nPos = 0
'***** Break the bar code into two parts, the setting and the value nPos = InStr(1, frmAnalysis!KImgp1.PEBarCodeString(nBarCnt), ":") If (nPos > 0) Then sValue = Right$(frmAnalysis!KImgp1.PEBarCodeString(nBarCnt), Len(frmAnalysis!KImgp1.PEBarCodeString(nBarCnt)) - nPos) sSetting = Left$(frmAnalysis!KImgp1.PEBarCodeString(nBarCnt), nPos - 1) End If
'***** See if we can act upon the bar code found If StrComp(sSetting, "ANGLE", 1) = 0 Then nStatus = ChangeRotation(kscn, sValue) ElseIf StrComp(sSetting, "DPI", 1) = 0 Then nStatus = ChangeDPI(kscn, sValue) ElseIf StrComp(sSetting, "SIZE", 1) = 0 Then nStatus = ChangeSize(kscn, sValue) ElseIf StrComp(sSetting, "CONTRAST", 1) = 0 Then nStatus = ChangeContrast(kscn, sValue) ElseIf StrComp(sSetting, "DENSITY", 1) = 0 Then nStatus = ChangeDensity(kscn, sValue) ElseIf StrComp(sSetting, "ORIENTATION", 1) = 0 Then nStatus = ChangeOrientation(kscn, sValue) ElseIf StrComp(sSetting, "DUPLEX", 1) = 0 Then nStatus = ChangeDuplex(kscn, sValue) ElseIf StrComp(sSetting, "DIR", 1) = 0 Then nStatus = ChangeDir(kscn, sValue) Else nStatus = INVALID_SETTING End If '***** If the bar code was not successfully processed display error If (nStatus = INVALID_SETTING) Then errmsg = "Invalid Setting " + frmAnalysis!KImgp1.PEBarCodeString(nBarCnt) Call KFErrorMsgBoxWithString(errmsg) End If Next nBarCnt '***** SetSettings to make them take effect nStatus = KFSetAction(kscn, KSACTIONSETSETTINGS) If nStatus <> SUCCESS Then Call KFErrorMsgBox(nStatus) Exit Function End If '***** Set return value BarcodesInterpretScannerSettings = nStatus End Function可以取出条码坐标、类型、识别结果等等。 还是建议你好好看看Kofax那个Demo。
处理,所有必须添加扫描控件,并将Kimgp与Kscan关联。即Kimgp1.ImageProcCtl=KScan1.将
Kimgp1的Barcode先Enable,最后在KScan的PageEnd中进行条码识别,如下是识别大概处理:Static Function BarcodesInterpretScannerSettings(kscn As KScan) As Integer '***** Parameters
' kscn (I) KScan control
Dim nPos As Integer
Dim nColonPos As Integer
Dim nBarCnt As Integer
Dim nStatus As Integer
Dim sSetting As String
Dim sValue As String
Dim errmsg As String '***** Exit right away if no bar codes were found
If frmAnalysis!KImgp1.PEBarCodeCount = 0 Then
BarcodesInterpretScannerSettings = SUCCESS
Exit Function
End If '***** For each bar code found on the page
For nBarCnt = 1 To frmAnalysis!KImgp1.PEBarCodeCount
nPos = 0
'***** Break the bar code into two parts, the setting and the value
nPos = InStr(1, frmAnalysis!KImgp1.PEBarCodeString(nBarCnt), ":")
If (nPos > 0) Then
sValue = Right$(frmAnalysis!KImgp1.PEBarCodeString(nBarCnt), Len(frmAnalysis!KImgp1.PEBarCodeString(nBarCnt)) - nPos)
sSetting = Left$(frmAnalysis!KImgp1.PEBarCodeString(nBarCnt), nPos - 1)
End If
'***** See if we can act upon the bar code found
If StrComp(sSetting, "ANGLE", 1) = 0 Then
nStatus = ChangeRotation(kscn, sValue)
ElseIf StrComp(sSetting, "DPI", 1) = 0 Then
nStatus = ChangeDPI(kscn, sValue)
ElseIf StrComp(sSetting, "SIZE", 1) = 0 Then
nStatus = ChangeSize(kscn, sValue)
ElseIf StrComp(sSetting, "CONTRAST", 1) = 0 Then
nStatus = ChangeContrast(kscn, sValue)
ElseIf StrComp(sSetting, "DENSITY", 1) = 0 Then
nStatus = ChangeDensity(kscn, sValue)
ElseIf StrComp(sSetting, "ORIENTATION", 1) = 0 Then
nStatus = ChangeOrientation(kscn, sValue)
ElseIf StrComp(sSetting, "DUPLEX", 1) = 0 Then
nStatus = ChangeDuplex(kscn, sValue)
ElseIf StrComp(sSetting, "DIR", 1) = 0 Then
nStatus = ChangeDir(kscn, sValue)
Else
nStatus = INVALID_SETTING
End If '***** If the bar code was not successfully processed display error
If (nStatus = INVALID_SETTING) Then
errmsg = "Invalid Setting " + frmAnalysis!KImgp1.PEBarCodeString(nBarCnt)
Call KFErrorMsgBoxWithString(errmsg)
End If Next nBarCnt '***** SetSettings to make them take effect
nStatus = KFSetAction(kscn, KSACTIONSETSETTINGS)
If nStatus <> SUCCESS Then
Call KFErrorMsgBox(nStatus)
Exit Function
End If '***** Set return value
BarcodesInterpretScannerSettings = nStatus
End Function可以取出条码坐标、类型、识别结果等等。
还是建议你好好看看Kofax那个Demo。