Reference Guide
GdPicture14 Namespace / GdPictureSegmenter Class / GetCharacterCount Method
The unique result identifier of the executed segmentation process obtained by the RunSegmentation method.
Example





In This Topic
    GetCharacterCount Method (GdPictureSegmenter)
    In This Topic
    Returns the number of characters within the segmentation result specified by its index.
    Syntax
    'Declaration
     
    
    Public Function GetCharacterCount( _
       ByVal SegmentationResultID As String _
    ) As Integer
    public int GetCharacterCount( 
       string SegmentationResultID
    )
    public function GetCharacterCount( 
        SegmentationResultID: String
    ): Integer; 
    public function GetCharacterCount( 
       SegmentationResultID : String
    ) : int;
    public: int GetCharacterCount( 
       string* SegmentationResultID
    ) 
    public:
    int GetCharacterCount( 
       String^ SegmentationResultID
    ) 

    Parameters

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

    Return Value

    The number of detected characters. Please always use the GetStat method to determine if this method has been successful.
    Remarks
    It is recommend to use the GetStat method to identify the specific reason for the method's failure, if any.
    Example
    How to find out the number of detected characters within the segmentation result.
    Dim caption As String = "Example: GetCharacterCount"
    Using oGdPictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
        'Set up the image you want to process.
        Using oGdPictureImage As GdPictureImaging = New GdPictureImaging()
            'The standard open file dialog displays to allow you to select the file.
            Dim image As Integer = oGdPictureImage.CreateGdPictureImageFromFile("")
            If (oGdPictureImage.GetStat() = GdPictureStatus.OK) AndAlso
               (oGdPictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
                'Set the segmentation mode.
                oGdPictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
                'Run the segmentation process.
                Dim resultID As String = oGdPictureSegmenter.RunSegmentation()
                If oGdPictureSegmenter.GetStat() = GdPictureStatus.OK Then
                    'Check the results.
                    Dim characterCount As Integer = oGdPictureSegmenter.GetCharacterCount(resultID)
                    If oGdPictureSegmenter.GetStat() = GdPictureStatus.OK Then
                        MessageBox.Show("The number of detected characters: " + characterCount.ToString(), caption)
                        'Continue ...
                    Else
                        MessageBox.Show("The GetCharacterCount() method has failed with the status: " + oGdPictureSegmenter.GetStat().ToString(), caption)
                    End If
                Else
                    MessageBox.Show("The segmentation process has failed with the status: " + oGdPictureSegmenter.GetStat().ToString(), caption)
                End If
                'Release the used image.
                oGdPictureImage.ReleaseGdPictureImage(image)
            Else
                MessageBox.Show("The error occurred when setting up the image: " + oGdPictureImage.GetStat().ToString() + " or " + oGdPictureSegmenter.GetStat().ToString(), caption)
            End If
        End Using
        'Release resources.
        oGdPictureSegmenter.ReleaseSegmentationResults()
    End Using
    string caption = "Example: GetCharacterCount";
    using (GdPictureSegmenter oGdPictureSegmenter = new GdPictureSegmenter())
    {
        //Set up the image you want to process.
        using (GdPictureImaging oGdPictureImage = new GdPictureImaging())
        {
            //The standard open file dialog displays to allow you to select the file.
            int image = oGdPictureImage.CreateGdPictureImageFromFile("");
            if ((oGdPictureImage.GetStat() == GdPictureStatus.OK) &&
                (oGdPictureSegmenter.SetImage(image) == GdPictureStatus.OK))
            {
                //Set the segmentation mode.
                oGdPictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
                //Run the segmentation process.
                string resultID = oGdPictureSegmenter.RunSegmentation();
                if (oGdPictureSegmenter.GetStat() == GdPictureStatus.OK)
                {
                    //Check the results.
                    int characterCount = oGdPictureSegmenter.GetCharacterCount(resultID);
                    if (oGdPictureSegmenter.GetStat() == GdPictureStatus.OK)
                    {
                        MessageBox.Show("The number of detected characters: " + characterCount.ToString(), caption);
                        //Continue ...
                    }
                    else
                        MessageBox.Show("The GetCharacterCount() method has failed with the status: " + oGdPictureSegmenter.GetStat().ToString(), caption);
                }
                else
                    MessageBox.Show("The segmentation process has failed with the status: " + oGdPictureSegmenter.GetStat().ToString(), caption);
                //Release the used image.
                oGdPictureImage.ReleaseGdPictureImage(image);
            }
            else
                MessageBox.Show("The error occurred when setting up the image: " + oGdPictureImage.GetStat().ToString() + " or " + oGdPictureSegmenter.GetStat().ToString(), caption);
        }
        //Release resources.
        oGdPictureSegmenter.ReleaseSegmentationResults();
    }
    See Also