GdPicture.NET.14.API
GdPicture14 Namespace / GdPictureSegmenter Class / GetTextLineCount Method
The unique result identifier of the executed segmentation process obtained by the GdPictureSegmenter.RunSegmentation method.
Example





In This Topic
GetTextLineCount Method (GdPictureSegmenter)
In This Topic
Returns the number of text lines within the segmentation result specified by its index. The resulting value doesn't contain any empty lines, as they are not provided in the segmentation result.
Syntax
'Declaration
 
Public Function GetTextLineCount( _
   ByVal SegmentationResultID As String _
) As Integer
public int GetTextLineCount( 
   string SegmentationResultID
)
public function GetTextLineCount( 
    SegmentationResultID: String
): Integer; 
public function GetTextLineCount( 
   SegmentationResultID : String
) : int;
public: int GetTextLineCount( 
   string* SegmentationResultID
) 
public:
int GetTextLineCount( 
   String^ SegmentationResultID
) 

Parameters

SegmentationResultID
The unique result identifier of the executed segmentation process obtained by the GdPictureSegmenter.RunSegmentation method.

Return Value

The number of detected lines in text. Please always use the GdPictureSegmenter.GetStat method to determine if this method has been successful.
Remarks
It is recommend to use the GdPictureSegmenter.GetStat method to identify the specific reason for the method's failure, if any.

Please note that the resulting value doesn't contain any empty lines, if they have been recognized.

Example
How to find out the number of detected text lines within the segmentation result.
Dim caption As String = "Example: GetTextLineCount"
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 textlineCount As Integer = gdpictureSegmenter.GetTextLineCount(resultID)
                If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
                    MessageBox.Show("The number of detected text lines: " + textlineCount.ToString(), caption)
                    'Continue ...
                Else
                    MessageBox.Show("The GetTextLineCount() 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
string caption = "Example: GetTextLineCount";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
    //Set up the image you want to process.
    using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
    {
        //The standard open file dialog displays to allow you to select the file.
        int image = gdpictureImaging.CreateGdPictureImageFromFile("");
        if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
            (gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
        {
            //Set the segmentation mode.
            gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
            //Run the segmentation process.
            string resultID = gdpictureSegmenter.RunSegmentation();
            if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
            {
                //Check the results.
                int textlineCount = gdpictureSegmenter.GetTextLineCount(resultID);
                if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
                {
                    MessageBox.Show("The number of detected text lines: " + textlineCount.ToString(), caption);
                    //Continue ...
                }
                else
                    MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
            }
            else
                MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
            //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);
    }
    //Release resources.
    gdpictureSegmenter.ReleaseSegmentationResults();
}
See Also