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

Tesseract always saying image is "Bad Base-64" #13

Open
carlo318 opened this issue Dec 2, 2016 · 5 comments
Open

Tesseract always saying image is "Bad Base-64" #13

carlo318 opened this issue Dec 2, 2016 · 5 comments

Comments

@carlo318
Copy link

carlo318 commented Dec 2, 2016

Hi,
I have installed the plugin in an App for Android made with Ionic Framework.
I am trying to get an image with cordova-image-camera which is getting a base64 image, which is correct (if I use it in an it show the image correctly).
I pass that base64 as imageData input, but Tesseract always get an Exception "Bad Base-64".
Do you what could be the reason?

Example code:

try {
	TesseractPlugin.loadLanguage('ita', function(response) {
		debugLog('Loading OCR language successful');
	}, function(reason) {
		debugLog('Error on loading OCR file for your language. ' + reason);
	});

	var _testImage ="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAANCAIAAAArLKlOAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABvSURBVChTpZBRFgARCEWty4JaT6tpMxbTiITDOI25X9S7QuArfmsJY1CAtCbUesSk+4JpBK1DYKIsI1IW37SOHD+llsJOqxPG0FmTfGF6WsY1rf7BqPq0JXbQcqsN+DSthBXL2HMVa+wu6eBKY34AAZZMtGg8cLgAAAAASUVORK5CYII=";
	TesseractPlugin.recognizeText(_testImage  , 'ita', function(recognizedText) {
		debugLog("Tesseract recognized text: " + recognizedText);
	}, function(error) {
		debugLog('Error recognizing text from image: ' + error);
	});
}
catch(e) {
	debugLog("Tesseract Error: " + objToString(e.message) );
}

The loadLanguage() call works successfully.
The recognizeText() always returns the function(reason), with the message: "Bad Base-64";

Thankyou.
Carlo

@NBAMj
Copy link

NBAMj commented Jun 12, 2017

I'm also getting the same error. Any update?

@NBAMj
Copy link

NBAMj commented Jun 12, 2017

I was passing the wrong option to the Camera Plugin.
It should be cameraOptions.DestinationType.DATA_URL

@carlo318 in your case, pass the _testImage without prefixing it with data:image/jpep:base64,
and that should be it

@carlo318
Copy link
Author

carlo318 commented Jun 16, 2017

I tried your suggestion @NBAMj , but now it does'nt give me any feedback, neither successful, nor failed.
With or without the prefix data:image/jpeg:base64,
How comes?

I also put try catch outside Tesseract and inside any function (successful or failed), but nothing happens.
Could it be any issue with Java?
The last version is always 0.0.1?

Thankyou.

@ShailBag
Copy link

Any resolution to this? I am getting same issue.

@rjurado01
Copy link

I resolve the problem like this:

var myimage = document.getElementById('smallImage').src.replace('data:image/jpeg;base64,', '');

TesseractPlugin.recognizeText(myimage, 'eng', function(recognizedText) {
  console.log(recognizedText);
}, function(reason) {
  console.log('Error on recognizing text from image. ' + reason);
});

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

4 participants