Java Code Examples for org.neuroph.core.NeuralNetwork#getPlugin()

The following examples show how to use org.neuroph.core.NeuralNetwork#getPlugin() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageRecognitionSample.java    From NeurophFramework with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
      // load trained neural network saved with NeurophStudio (specify existing neural network file here)
      NeuralNetwork nnet = NeuralNetwork.createFromFile("MyImageRecognition.nnet");
      // get the image recognition plugin from neural network
      ImageRecognitionPlugin imageRecognition = (ImageRecognitionPlugin)nnet.getPlugin(ImageRecognitionPlugin.class);

      try {
            // image recognition is done here
            HashMap<String, Double> output = imageRecognition.recognizeImage(new File("someImage.jpg")); // specify some existing image file here
            System.out.println(output.toString());
      } catch(IOException ioe) {
          System.out.println("Error: could not read file!");
      } catch (VectorSizeMismatchException vsme) {
          System.out.println("Error: Image dimensions dont !");
      }
}
 
Example 2
Source File: OcrHelper.java    From NeurophFramework with Apache License 2.0 5 votes vote down vote up
public static List<Character> recognize (NeuralNetwork nnet, List<BufferedImage> images, Dimension charDimension){
    OcrPlugin  ocrPlugin = (OcrPlugin) nnet.getPlugin(OcrPlugin.class);      
    List<Character> letters = new ArrayList<Character>();

    for (BufferedImage img : images) {
        Character letter = ocrPlugin.recognizeCharacter(new ImageJ2SE(img), charDimension);
        letters.add(letter);
    }
    return letters;
}
 
Example 3
Source File: OcrSample.java    From NeurophFramework with Apache License 2.0 5 votes vote down vote up
public static void main(String[]args) {
    NeuralNetwork nnet = NeuralNetwork.load("C:\\Users\\zoran\\Desktop\\nn.nnet");
    OcrPlugin ocrPlugin = (OcrPlugin) nnet.getPlugin(OcrPlugin.class);
    
    // load letter images
    Image charImage = ImageFactory.getImage("C:\\Users\\zoran\\Desktop\\Letters\\A.png");
    Character ch = ocrPlugin.recognizeCharacter(charImage);
    System.out.println(ch);
}
 
Example 4
Source File: RecognizeLetter.java    From NeurophFramework with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {

        // User input parameters
//***********************************************************************************************************************************
        String networkPath = "C:/Users/Mihailo/Desktop/OCR/nnet/nnet-12-0.01.nnet"; // path to the trained network                *
        String letterPath = "C:/Users/Mihailo/Desktop/OCR/letters/259.png"; // path to the letter for recognition                   *
//***********************************************************************************************************************************
        
        NeuralNetwork nnet = NeuralNetwork.createFromFile(networkPath);
        ImageRecognitionPlugin imageRecognition = (ImageRecognitionPlugin) nnet.getPlugin(ImageRecognitionPlugin.class);
        Map<String, Double> output = imageRecognition.recognizeImage(new File(letterPath));
        System.out.println("Recognized letter: "+OCRUtilities.getCharacter(output));

    }
 
Example 5
Source File: OCRTextRecognition.java    From NeurophFramework with Apache License 2.0 4 votes vote down vote up
/**
 * @param nnet trained neural network
 */
public void setNeuralNetwork(NeuralNetwork nnet) {
    this.nnet = nnet;
    plugin = (ImageRecognitionPlugin) nnet.getPlugin(ImageRecognitionPlugin.class);
}