Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to convert a bufferedImage into a string

 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




Can Anyone tell me how to convert an BufferedImage into a String, i tried it using the code which in in 'green' text., bt it's an error in the getPixel().
so how can i convert a bufferedImage into a String here???

again here is the code, which i used to convert, that i also have mentioned earlier in the program:

for(int y=0; y<image.getHeight(); y++){
for(int x=0; x<image.getWidth(); x++){
str1+=(String)image.getPixel(x,y);
}
}
 
Stephan van Hulst
Bartender
Pie
Posts: 5893
63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you possibly convert an image to a String?
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:Why would you possibly convert an image to a String?


I have a label in my other class, and that label is converting into image, i want to print the text/string of that label, therefore i need to convert, is it possible to convert??
 
Tim Moores
Bartender
Posts: 2848
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the realm of Optical character recognition; Tesseract is a well-known library for this.
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:That's the realm of Optical character recognition; Tesseract is a well-known library for this.


I have not used this type of library ever, can you please tell me how can i implement it here??
Here is two other classes i used:



one i have added earlier in this thread.
if is there any other way to get the text of the label, than please let me know.
 
Rob Spoor
Sheriff
Pie
Posts: 20546
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you even looked for the Tesseract library? Also, have you tried searching for java ocr?
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:Have you even looked for the Tesseract library? Also, have you tried searching for java ocr?


i have not been looked it earlier, is there any other way to get my requirements, i added two classes also, if there is any other way, please tell me..
 
Tim Moores
Bartender
Posts: 2848
46
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not a trivial problem, and it cannot be explained in a short forum posting. You will need to spend a significant amount of time learning about OCR and any OCR library like Tesseract you intend to use. You should not expect to have a solution up and running today or tomorrow, and possibly some time after that. And if you have it running, it may not work, or not work well, for the particular type of image you're using.
 
Punit Jain
Ranch Hand
Posts: 1012
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:This is not a trivial problem, and it cannot be explained in a short forum posting. You will need to spend a significant amount of time learning about OCR and any OCR library like Tesseract you intend to use. You should not expect to have a solution up and running today or tomorrow, and possibly some time after that. And if you have it running, it may not work, or not work well, for the particular type of image you're using.


Thanks for your helpful advice..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic