Class TextRecognitionModel


  • public class TextRecognitionModel
    extends Model
    This class represents high-level API for text recognition networks. TextRecognitionModel allows to set params for preprocessing input image. TextRecognitionModel creates net from file with trained weights and config, sets preprocessing input, runs forward pass and return recognition result. For TextRecognitionModel, CRNN-CTC is supported.
    • Constructor Detail

      • TextRecognitionModel

        protected TextRecognitionModel​(long addr)
      • TextRecognitionModel

        public TextRecognitionModel​(Net network)
        Create Text Recognition model from deep learning network Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method
        Parameters:
        network - Net object
      • TextRecognitionModel

        public TextRecognitionModel​(String model,
                                    String config)
        Create text recognition model from network represented in one of the supported formats Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method
        Parameters:
        model - Binary file contains trained weights
        config - Text file contains network configuration
      • TextRecognitionModel

        public TextRecognitionModel​(String model)
        Create text recognition model from network represented in one of the supported formats Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method
        Parameters:
        model - Binary file contains trained weights
    • Method Detail

      • setDecodeType

        public TextRecognitionModel setDecodeType​(String decodeType)
        Set the decoding method of translating the network output into string
        Parameters:
        decodeType - The decoding method of translating the network output into string: {'CTC-greedy': greedy decoding for the output of CTC-based methods}
        Returns:
        automatically generated
      • getDecodeType

        public String getDecodeType()
        Get the decoding method
        Returns:
        the decoding method
      • setVocabulary

        public TextRecognitionModel setVocabulary​(List<String> vocabulary)
        Set the vocabulary for recognition.
        Parameters:
        vocabulary - the associated vocabulary of the network.
        Returns:
        automatically generated
      • getVocabulary

        public List<String> getVocabulary()
        Get the vocabulary for recognition.
        Returns:
        vocabulary the associated vocabulary
      • recognize

        public String recognize​(Mat frame)
        Given the input frame, create input blob, run net and return recognition result
        Parameters:
        frame - The input image
        Returns:
        The text recognition result
      • recognize

        public void recognize​(Mat frame,
                              List<Mat> roiRects,
                              List<String> results)
        Given the input frame, create input blob, run net and return recognition result
        Parameters:
        frame - The input image
        roiRects - List of text detection regions of interest (cv::Rect, CV_32SC4). ROIs is be cropped as the network inputs
        results - A set of text recognition results.