Important alert: (current site time 7/15/2013 2:26:53 PM EDT)
 

article

Image Text Extraction from Remote Image URL by REST API in Java Apps

Email
Submitted on: 1/2/2013 2:31:47 PM
By: Saaspose 
Level: Intermediate
User Rating: Unrated
Compatibility: Java (JDK 1.3), Java (JDK 1.4), Java (JDK 1.5)
Views: 1988
(About the author)
 
     This technical tip allows developers to extract image text from remote image URL using Saaspose.OCR REST API in their Java applications.

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
				This technical tip allows developers to extract image text from remote image URL using Saaspose.OCR REST API in their Java applications. Some important steps for performing this task is to build URI to extract text, sign URI, execute signed URI request and get response, Parse and deserialize the JSON to an object and Display the value and type of all the extracted text. 
Sample Code for Extracting Image Text from Remote Image URL
//build URI to extract text
	String strURI = "";
strURI = "http://api.saaspose.com/v1.0/ocr/recognize?url=http://s017.radikal.ru/i406/1202/7b/70183bef7a09.jpg&language=english&useDefaultDictionaries=true";
	//sign URI
	String signedURI = Sign(strURI);
	//execute signed URI request and get response
	InputStream responseStream = ProcessCommand(signedURI, "POST");
	String strJSON = StreamToString(responseStream);
	// Parse and deserialize the JSON to a object.
	OCRResponse ocrResponse = gson.fromJson(strJSON, OCRResponse.class);
// Display the value and type of all the recognized barcodes
for (Part part : ocrResponse.getPartsInfo().getList())
{
System.out.println("Text: " + part.getText());
System.out.println("Font Name: " + part.getFontName());
System.out.println("Font Size: " + part.getFontSize());
System.out.println("Bold: " + part.getBold());
System.out.println("Italic: " + part.getItalic());
System.out.println("Underline: " + part.getUnderline());
}
	//Here is the OCRResponse class
	public class OCRResponse extends BaseResponse 
	{
	private String Text;
		private OCREnvelop PartsInfo;
		public String getText() { return Text; }
		public OCREnvelop getPartsInfo() { return PartsInfo; }
	}
	//Here is the OCREnvelop class
	public class OCREnvelop 
	{
		private List Parts;
		public List getList() { return Parts; }
	}
 	//Here is the Part class
	public class Part 
	{
	public Part() { }
	private String FontName;
	private float FontSize;
	private boolean Bold;
	private boolean Italic;
	private boolean Underline;
	private String Text;
	public String getFontName() { return FontName; }
	public float getFontSize() { return FontSize; }
	public boolean getBold() { return Bold; }
	public boolean getItalic() { return Italic; }
	public boolean getUnderline() { return Underline; }
	public String getText() { return Text; }
	}
More about Saaspose.OCR
- Homepage of Saaspose.OCR: http://saaspose.com/api/ocr 
- More Technical Tips by Saaspose.OCR: http://saaspose.com/docs/display/ocr/1.2+-+Saaspose.OCR+Examples


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.