I am trying to do an OCR where it take an image and return the content of the image in text file. The current code is working fine but it is not writing in text. Can anyone suggest/show me the way to make the output to be written in text file (.txt)?
Here is the code:
package assignment10; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.io.*; import java.util.Arrays; import javax.imageio.ImageIO; public class A10Driver { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { String name = "Translation_Standard_Galactic_Alphabet.png"; double factor = 0.3; System.out.println(Arrays.toString(args)); // if(args.length < 1){ // System.out.println("Usage: java -jar Filename.jpg"); // System.out.println("Exiting ..."); // System.exit(0); // } // // // String name = args[0]; // double factor = Double.parseDouble(args[1]); String[] arr = name.split("\\."); String format = arr[1]; BufferedImage image = ImageIO.read(new File(name)); BoundaryFilterOp bOp = new BoundaryFilterOp(factor); BufferedImage bImg = bOp.filter(image, null); // IPUtil.displayMatrix(IPUtil.readImageAsMatrix(image)); File file = new File("boundaryFilter-"+name); ImageIO.write(bImg, format, file); } }
Please look into it as your help will mean a lot for my project. Thanks in advance!