below is the bar code image that i'm going to read from my HD
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.File;
import javax.imageio.ImageIO;
import com.asprise.util.ocr.OCR;
public class Test2 {
public static void main(String[] args) throws Exception {
//Creates a new object and assign the image location
BufferedImage image = ImageIO.read(new File("D:\\TEST\\Bar_code.jpg"));
//Creates a string variable and assign the bar code values
String s = new OCR().recognizeBarcode(image);
//Creates a string variable and assign other character values
String imageText = new OCR().recognizeCharacters((RenderedImage) image);
//Prints the bar code values
System.out.println("Text From Image : \n"+s);
//Prints the other character values
System.out.println("Text From Image : \n"+ imageText);
//Prints the length of the texts
System.out.println("Length of total text : \n"+ imageText.length());
}
}
The output of the program is :
Text From Image :
123456789012
Text From Image :
Asprise OCR
Speed. Accuracy.
Length of total text :
33

Thank you.
ReplyDeleteVery useful code sample for reading barcode from WebDriver.
I am getting,
Deleteimport of com.asprise.util.ocr.OCR cannot be resolved error, may we know how did u resolve this ?
Please share the maven dependency or library which u have used
Hi ,..I tried using the code. It is asking for the OCR class file.
ReplyDeleteI tried to download the javaocr-plugins-distribution-1.0-bin jars and added to the build path. But no luck.
Could you please help me out.
same issue here . can some guide to get com.asprise.util.ocr.OCR jar file
ReplyDeletesame issue here . can some guide to get com.asprise.util.ocr.OCR jar file
ReplyDeletesame issue here . can some guide to get com.asprise.util.ocr.OCR jar file
ReplyDelete