GdPicture.NET.14.API
GdPicture14 Namespace / GdPictureSegmenter Class / GetParagraphFirstTextLineIndex Method
The unique result identifier of the executed segmentation process obtained by the GdPictureSegmenter.RunSegmentation method.
The 0-based index of the paragraph within the specified segmentation result. It must be a value between 0 and GdPictureSegmenter.GetParagraphCount(SegmentationResultID)-1.
Example





GetParagraphFirstTextLineIndex Method (GdPictureSegmenter)
Returns the index of the first text line in the specified paragraph, that is a part of the segmentation result specified by its index.
Syntax
'Declaration
 
Public Function GetParagraphFirstTextLineIndex( _
   ByVal SegmentationResultID As String, _
   ByVal ParagraphIdx As Integer _
) As Integer
 

Parameters

SegmentationResultID
The unique result identifier of the executed segmentation process obtained by the GdPictureSegmenter.RunSegmentation method.
ParagraphIdx
The 0-based index of the paragraph within the specified segmentation result. It must be a value between 0 and GdPictureSegmenter.GetParagraphCount(SegmentationResultID)-1.

Return Value

The index of the first text line in the specified paragraph. Please always use the GdPictureSegmenter.GetStat method to determine if this method has beensuccessful.
Remarks
It is recommend to use the GdPictureSegmenter.GetStat method to identify the specific reason for the method's failure, if any.
Example
How to find out the number of detected text lines within the paragraph and the index of the first text line.
Dim caption As String = "Example: GetParagraphFirstTextLineIndex"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
    'Set up the image you want to process.
    Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
        'The standard open file dialog displays to allow you to select the file.
        Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
        If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
           (gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
            'Set the segmentation mode.
            gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
            'Run the segmentation process.
            Dim resultID As String = gdpictureSegmenter.RunSegmentation()
            If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
                'Check the results.
                Dim paragraphCount As Integer = gdpictureSegmenter.GetParagraphCount(resultID)
                If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
                    Dim textlineCount As Integer = 0, index As Integer = 0
                    For i As Integer = 0 To paragraphCount - 1
                        textlineCount = gdpictureSegmenter.GetParagraphTextLineCount(resultID, i)
                        If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
                            index = gdpictureSegmenter.GetParagraphFirstTextLineIndex(resultID, i)
                            If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
                                'Continue ...
                            Else
                                'handle the error
                            End If
                        Else
                            'handle the error
                        End If
                    Next
                Else
                    MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
                End If
            Else
                MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
            End If
            'Release the used image.
            gdpictureImaging.ReleaseGdPictureImage(image)
        Else
            MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
        End If
    End Using
    'Release resources.
    gdpictureSegmenter.ReleaseSegmentationResults()
End Using
See Also