Skip to main content
Kofax

Line Detection Locator

17765

QAID # 17765 Published

Question / Problem:

Line Detection Locator

Answer / Solution:

The following Script Locator detects lines on each page and returns them as alternatives so you can see the lines in Project Builder. You can customize it to look for any type of lines.

This script shows you how to get the line objects, whereas the script in Classification by Graphical Lines only counts lines.

Private Sub LineLocator_LocateAlternatives(ByRef pXDoc As CASCADELib.CscXDocument, _
ByRef pLocator As CASCADELib.CscXDocField)
'You need to include a reference to "Kofax Cascade Forms Processing"
'c:\Program Files (x86)\Common Files\Kofax\Components\CscForms2.dll
Dim pLD As CscLinesDetection
Dim hL As CscLineInfo
Dim vL As CscLineInfo
Dim pImage As CscImage
Dim xLeft As Long
Dim xWidth As Long
Dim yTop As Long
Dim yHeight As Long
Dim alt As CscXDocFieldAlternative
Dim i, j, k As Integer
Set pImage = pXDoc.CDoc.Pages(0).GetImage()
Set pLD = New CscLinesDetection
pLD.DetectHorCombs = False
pLD.DetectHorDotLines = False
pLD.DetectHorLines = True
pLD.DetectVerLines = True
pLD.MinHorLineLenMM = 8
pLD.MinVerLineLenMM = 5
'SET SEARCHING AREA
xLeft = pImage.Width * 0.44
xWidth = pImage.Width * 0.54
yTop = pImage.Height * 0.05
yHeight = pImage.Height * 0.9
'DETECT LINES
pLD.DetectLines pImage, xLeft, yTop, xWidth, yHeight
For i = 0 To pLD.HorLineCount - 1
Set hL = pLD.GetHorLine(i)
Set alt = pLocator.Alternatives.Create
alt.Left = hL.StartX
alt.Top = hL.StartY - 3
alt.Width = hL.EndX - hL.StartX
alt.Height = hL.EndY - hL.StartY + 6
alt.PageIndex = 0
alt.Text = "Line " & Str(i)
alt.Confidence = 1
Next
For i = 0 To pLD.VerLineCount - 1
Set hL = pLD.GetVerLine(i)
Set alt = pLocator.Alternatives.Create
alt.Left = hL.StartX - 3
alt.Top = hL.StartY
alt.Width = hL.EndX - hL.StartX + 6
alt.Height = hL.EndY - hL.StartY
alt.PageIndex = 0
alt.Text = "Line " & Str(i)
alt.Confidence = 1
Next
End Sub

Applies to

Product Version Category
AXPRO 5.5 Project Builder
  • Was this article helpful?