Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not get text from image if image contains some background objects #19

Closed
shamsher31 opened this issue Oct 13, 2016 · 11 comments
Closed

Comments

@shamsher31
Copy link

Im building mobile app for Motivation qoutes, where any one can add qoutes and send image link that contains qoutes in it. I used the following image.
img3

it gives me text with proper line breaks, happy to see this.
"YOU LEARNED
TO LAUGH
BEFORE
YOU LEARNED
TO TALK."

But when I use this image
img

It gives me following text.

w?-
3 <5"
I! r

  • WRI‘Cf' v EALWAvs“
    TEA WUERIGHT
    1“ CE 0N5
    *‘ A‘ £ I

Just want to ask if the lib only works with image without any background.

@mjurczyk
Copy link

Have you tried to detect the text after desaturation, adjustment of contrast plus, optional, inversion of colors?

a692cd96-9143-11e6-83de-282cc8416256

It should work just fine with just these small changes.

@shamsher31
Copy link
Author

Im writing service in nodejs which will take image as a input and will use tesseract.js to process it and get the text out of it. There will not be any interaction in between. I will appreciate if you point me to some libs that will help me to do what you mentioned.

@mjurczyk
Copy link

I have not tried it myself, but https://github.com/oliver-moran/jimp seems to provide what you need.

According to the examples:

image
  .greyscale()
  .contrast(+1)

Although you may also try to detect whether the image is rather dark or rather bright, and invert its colors accordingly.

@shamsher31
Copy link
Author

Thanks @mjurczyk that worked for me.

@NikithShetty
Copy link

@shamsher31 can u share how you implemented color inversion using jimp?

@shamsher-synerzip31
Copy link

@NikithShetty you can use the following code. It's just POC to understand how JIMP and tesseract works together.

var Tesseract = require('tesseract.js');
var Jimp = require("jimp");


Jimp.read("img.jpg").then(function (image) {
    image.greyscale()
        .contrast(+1)    
        .normalize()
        .write("img-opt.jpg");
})
.then(function() {
  Tesseract.recognize('img-opt.jpg')
    .progress(function(message){console.log(message)})
    .catch(function(err){console.error(err)})
    .then(function(result){console.log(result.text)})
})
.catch(function (err) {
    console.error(err);
});

@NikithShetty
Copy link

NikithShetty commented Jul 12, 2017

Thanks @shamsher-synerzip31

@aditya0salaria
Copy link

Hi Guys,

I need help regarding tesseract functionality. I am using below code, Output is coming but not getting clear output. Is there any way, we can get clear output. Below is the code:

Library used below:

<script src='https://cdn.rawgit.com/naptha/tesseract.js/1.0.10/dist/tesseract.js'></script>

function used below:
setTimeout(function(){
var myImage= document.getElementById('ImageId');
Tesseract.recognize(myImage).then(function(result){
$('#Output').val(result.text);
});
},1000);

I have attached few images as an example which i need to convert to text
75985eb8-8299-4139-80dd-ea3826b5d104
.
receipt

@monikacapternal
Copy link

bank transfer ocbc personal

@monikacapternal
Copy link

not getting text

@mjurczyk
Copy link

mjurczyk commented Nov 4, 2020

Why am I still getting notifications for this :')

@monikacapternal @aditya0salaria - you probably have to desaturate the image and increase the contrast for readability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants