maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   OCR on jolla (https://talk.maemo.org/showthread.php?t=95583)

szopin 2015-06-03 19:10

OCR on jolla
 
As not (yet?) on open repos thought would post here:
https://github.com/skvark/Textractor...ses/tag/v0.1-1
Author is looking for icon and banner for harbour (@unpixels on twitter)

skvark 2015-06-03 19:15

Re: OCR on jolla
 
Thanks for posting this here, I got the icon and banner already. Next release will be in the Jolla store when I got some things sorted out.

szopin 2015-06-03 19:37

Re: OCR on jolla
 
Quote:

Originally Posted by skvark (Post 1472471)
Thanks for posting this here, I got the icon and banner already. Next release will be in the Jolla store when I got some things sorted out.

Oops, sorry, didn't notice your tmo handle in the url, and THANKS! Awesome app!

szopin 2015-06-03 21:56

Re: OCR on jolla
 
This really is great (except it throws an error when using screenshots, might need to change output format if possible), having only ancient greek/maths and english it still recognized half of a greek airport sign (english parts in higher percentage), the brussels sign to throw paper INTO the toilet (seemed funny as most of the time it was reverse, don't clog our precious pipes), sadly 0 accuracy, but it was in weird font anyway. When will realtime OCR/translation come? :D

edit: just an extract I find amazing:

Code:

Litterin‘g in the terminal is not permitted. Please dispose of cigarette butts,gUm,y 1
etc in the rubbish bins provided and make proper use of the bins separating, plastic

and. paperfrom other trash.

 

CKo'rn‘VIopa o Smoking > I I . . f .. _
’ I Aev. errnpérrerou ro Kornvropor orouc xrbpouc rou Aapoororepofi smog omo rouc npoKoreopiopsvouc _‘
V r to: «uni To oxom') or orroior (pépouv Tnv orvorhoyn onpoivon. V r » _

[gmoking is not permitted the It only allowed in the designated‘areésré,

And this is from this pic:
https://pbs.twimg.com/media/CGm9PYGWcAIMfo_.jpg
(don't ask me why it is turned around, gallery upload to twitter? (photofunia had similar bug with initial pre-4.29 release) or the textractor is impacted, not sure)

skvark 2015-06-04 06:02

Re: OCR on jolla
 
Quote:

Originally Posted by szopin (Post 1472496)
This really is great (except it throws an error when using screenshots, might need to change output format if possible), having only ancient greek/maths and english it still recognized half of a greek airport sign (english parts in higher percentage), the brussels sign to throw paper INTO the toilet (seemed funny as most of the time it was reverse, don't clog our precious pipes), sadly 0 accuracy, but it was in weird font anyway. When will realtime OCR/translation come? :D

edit: just an extract I find amazing:

Code:

Litterin‘g in the terminal is not permitted. Please dispose of cigarette butts,gUm,y 1
etc in the rubbish bins provided and make proper use of the bins separating, plastic

and. paperfrom other trash.

 

CKo'rn‘VIopa o Smoking > I I . . f .. _
’ I Aev. errnpérrerou ro Kornvropor orouc xrbpouc rou Aapoororepofi smog omo rouc npoKoreopiopsvouc _‘
V r to: «uni To oxom') or orroior (pépouv Tnv orvorhoyn onpoivon. V r » _

[gmoking is not permitted the It only allowed in the designated‘areésré,

And this is from this pic:
https://pbs.twimg.com/media/CGm9PYGWcAIMfo_.jpg
(don't ask me why it is turned around, gallery upload to twitter? (photofunia had similar bug with initial pre-4.29 release) or the textractor is impacted, not sure)

The error was related to too low resolution and it is fixed now. I haven't tested yet properly other formats than jpg.

I'll check why images gets mirrored.

szopin 2015-06-04 07:13

Re: OCR on jolla
 
Thanks! (weird thing is that image still displays properly in gallery, but after textractor went through it and gallery upload to twitter it ended up turned sideways (just checked with fresh image from gallery, behaves as expected), yeah some things in jolla work in mysterious ways C: )

skvark 2015-06-04 15:23

Re: OCR on jolla
 
Quote:

Originally Posted by szopin (Post 1472558)
Thanks! (weird thing is that image still displays properly in gallery, but after textractor went through it and gallery upload to twitter it ended up turned sideways (just checked with fresh image from gallery, behaves as expected), yeah some things in jolla work in mysterious ways C: )

Can you give the steps how to reproduce this? I found one rotation bug (when usb port was pointing to right) in which the image was rotated too much but this is not the same one.

I tried to reproduce that mirroring issue by uploading some images taken in Textractor/selected via Textractor to Twitter and everything worked correctly. Did you scale the image before upload in the gallery app and did you take the image in Textractor or did you select the image?

szopin 2015-06-04 15:27

Re: OCR on jolla
 
Quote:

Originally Posted by skvark (Post 1472638)
Can you give the steps how to reproduce this? I found one rotation bug (when usb port was pointing to right) in which the image was rotated too much but this is not the same one.

I tried to reproduce that mirroring issue by uploading some images taken in Textractor/selected via Textractor to Twitter and everything worked correctly. Did you scale the image before upload in the gallery app and did you take the image in Textractor or did you select the image?

I really don't think I can. I just threw at it a ton of pictures/screenshots and after being impressed by the greek sign, uploaded it to twitter as an example of great reading and this was turned. Let me check, brb

edit: yeah, tried to reproduce, but bukowski's quote is oriented correctly (opening the image by the app 'modifies it' as in shuffles to the top of available options, even if nothing was done with it)

szopin 2015-06-04 15:42

Re: OCR on jolla
 
Aaaah and got it, picture from mexico I took (no text, just for test:
https://twitter.com/szopin/status/60...479424/photo/1
This got turned left-right, this is the resulting B/W OCR image (already turned) https://twitter.com/szopin/status/60...356288/photo/1 )

skvark 2015-06-04 15:45

Re: OCR on jolla
 
Quote:

Originally Posted by szopin (Post 1472639)
I really don't think I can. I just threw at it a ton of pictures/screenshots and after being impressed by the greek sign, uploaded it to twitter as an example of great reading and this was turned. Let me check, brb

edit: yeah, tried to reproduce, but bukowski's quote is oriented correctly (opening the image by the app 'modifies it' as in shuffles to the top of available options, even if nothing was done with it)

Hmm, hopefully it was just some one time glitch.

Yes, it shuffles to the top of options because it is actually modified even if you see message "An error occured. Image could not be preprocessed." because before preprocessing the image is opened, the dots per meter value is changed and rotation is applied if necessary -> original image is overwritten by these changes.

skvark 2015-06-04 15:58

Re: OCR on jolla
 
Quote:

Originally Posted by szopin (Post 1472640)
Aaaah and got it, picture from mexico I took (no text, just for test:
https://twitter.com/szopin/status/60...479424/photo/1
This got turned left-right, this is the resulting B/W OCR image (already turned) https://twitter.com/szopin/status/60...356288/photo/1 )

How old this picture is, was it taken on an earlier version of Sailfish OS? Does the gallery show the image still correctly? I'll do some fixes but I'm not sure yet what is the root cause for this behaviour.

szopin 2015-06-04 16:02

Re: OCR on jolla
 
Quote:

Originally Posted by skvark (Post 1472643)
How old this picture is, was it taken on an earlier version of Sailfish OS? Does the gallery show the image still correctly? I'll do some fixes but I'm not sure yet what is the root cause for this behaviour.

Yes, this is probably it, this picture was taken (and all impacted so far) some half a year ago and more, so most likely it is old jolla exif bug, pictures taken with the app have no such bug (they are shown correctly in gallery)

edit: yea, old pictures not taken by jolla camera - display/upload correct, taken by jolla camera - display correct in gallery view, turned left-rigth when uploaded to twitter, seems like jolla bug (unless touching by the app is also needed edit: yeah, untouched pictures from gallery display correctly after uploading, so the 'touching' by textractor is involved)

skvark 2015-06-04 16:14

Re: OCR on jolla
 
Quote:

Originally Posted by szopin (Post 1472644)
Yes, this is probably it, this picture was taken (and all impacted so far) some half a year ago and more, so most likely it is old jolla exif bug, pictures taken with the app have no such bug (they are shown correctly in gallery)

edit: yea, old pictures not taken by jolla camera - display/upload correct, taken by jolla camera - display correct in gallery view, turned left-rigth when uploaded to twitter, seems like jolla bug (unless touching by the app is also needed

Thank you, I believe this is some old Jolla bug which somehow just makes the images flip when uploaded. Can you confirm if the old images get flipped even if they are not touched by Textractor?

Edit: Ah, I made changes so the image is copied before preprocessing - this should fix the problem at least partly.

szopin 2015-06-04 16:15

Re: OCR on jolla
 
Quote:

Originally Posted by skvark (Post 1472646)
Thank you, I believe this is some old Jolla bug which somehow just makes the images flip when uploaded. Can you confirm if the old images get flipped even if they are not touched by Textractor?

Checked, they are fine when just uploaded (but jolla specific on-the-fly fixes are to be expected), let me know if you want an example of an image that should flip

skvark 2015-06-04 16:18

Re: OCR on jolla
 
Quote:

Originally Posted by szopin (Post 1472647)
Checked, they are fine when just uploaded (but jolla specific on-the-fly fixes are to be expected), let me know if you want an example of an image that should flip

That would help, could you upload one somewhere?

szopin 2015-06-04 16:18

Re: OCR on jolla
 
Quote:

Originally Posted by skvark (Post 1472646)
Edit: Ah, I made changes so the image is copied before preprocessing - this should fix the problem at least partly.

AWESOME, the fact image was 'touched' was bit troubling (usually your source is left alone when processing, glad to have this)

skvark 2015-06-04 16:22

Re: OCR on jolla
 
Quote:

Originally Posted by szopin (Post 1472649)
AWESOME, the fact image was 'touched' was bit troubling (usually your source is left alone when processing, glad to have this)

Yes, there's a reason why this app is not yet in the Jolla store - bugs and things like that are to be found :)

szopin 2015-06-04 16:22

Re: OCR on jolla
 
Quote:

Originally Posted by skvark (Post 1472648)
That would help, could you upload one somewhere?

https://www.dropbox.com/home?preview=20141025_002.jpg
this should be untouched by any post processing (outside of jollas)

this is DL link for unmodified in any way (I hope) file:
https://www.dropbox.com/s/f1p7d8ff3f...5_002.jpg?dl=0

skvark 2015-06-04 17:07

Re: OCR on jolla
 
New release available with some bugfixes: https://github.com/skvark/Textractor...ses/tag/v0.2-1

skvark 2015-06-04 17:23

Re: OCR on jolla
 
Quote:

Originally Posted by szopin (Post 1472652)
https://www.dropbox.com/home?preview=20141025_002.jpg
this should be untouched by any post processing (outside of jollas)

this is DL link for unmodified in any way (I hope) file:
https://www.dropbox.com/s/f1p7d8ff3f...5_002.jpg?dl=0

Could not reproduce (original image is not affected anymore so I tested with the preprocessed one): https://twitter.com/unpixels/status/606509136323477505

If someone sees that bug still in some situation, please report. And those who had some photos affected by this, you can mirror/rotate the image back in some image manipulation program. I'm not sure does the Qt's QImage retain exif data after read -> save operation with same name. If not, I'm sorry for any inconvenience caused by this unintended "feature".

szopin 2015-06-04 17:32

Re: OCR on jolla
 
Quote:

Originally Posted by skvark (Post 1472671)
Could not reproduce (original image is not affected anymore so I tested with the preprocessed one): https://twitter.com/unpixels/status/606509136323477505

If someone sees that bug still in some situation, please report. And those who had some photos affected by this, you can mirror/rotate the image back in some image manipulation program. I'm not sure does the Qt's QImage retain exif data after read -> save operation with same name. If not, I'm sorry for any inconvenience caused by this unintended "feature".

I believe this is as cool example of an edge case bug (jolla should deal with it, really, not every qt lib user), pics taken with app are fine, go ahead, this needs more eyes/more text

skvark 2015-06-04 17:47

Re: OCR on jolla
 
Quote:

Originally Posted by szopin (Post 1472673)
I believe this is as cool example of an edge case bug (jolla should deal with it, really, not every qt lib user), pics taken with app are fine, go ahead, this needs more eyes/more text

Yes, but in any case the app should not have touched the original pictures :) And thanks for the debugging help.

skvark 2015-06-16 13:14

Re: OCR on jolla
 
Textractor is now available in the Jolla Store :cool:

Please report bugs and other stuff (feature requests) to the issues of the Textractor Github repository: https://github.com/skvark/Textractor/issues

Tsippaduida 2015-06-17 11:37

Re: OCR on jolla
 
Wow. I tried this on a shop receipt and it worked well (language: Finnish). I'm impressed.

Casanunda 2015-06-17 13:42

Re: OCR on jolla
 
Seems like photos have to be taken in "landscape view". Is that supposed to be like this?
Did some tests and all the pictures I took in portrait mode result in complete rubbish shown after processing...

But in correct view, recognition is actually quite good (Language: German).

pichlo 2015-06-17 14:23

Re: OCR on jolla
 
I've been waiting for an OCR on a mobile device for years! My first exposure to it was when PC/AT with 80286 CPUs running at 16 MHz were all the rage and I found it strange that it had all but disappeared from the surface of the earth.

Now finally my waiting is over! Thank you!

Of course, I played with it a bit and must say the results are pretty good. There are a few cases when a glare etc can cause some distortion and spoil the result but that is kinda expected. My favourite was trying to render a shot taken from the computer screen. This is what I got from the shot covering the second and third post in this thread:

Code:



“1‘ in!†5 ’, VSï¬Mâ€™ï¬ y; {fixijï¬i

Mm}: ‘3‘ “mgâ€? 957"“ ‘5‘ ‘14? gm 35;me 's gr Exam: [ï¬rm scar:

magi ;1"¢";;?
57311;, :51 ‘;—._r 3L »_, If aw; 21,1 ,

Ay‘

SM“ 1 $6.1m 3’ 2?in 1; {mm
p i ' . _ I
the N; '13") ($353“ Van "A c " 11::st 1 w 'fkevz ’c»z~;.$|i Puma: ï¬vnsw Ifu: YEW“! ’i

3 7‘"; “V31 “‘V‘;"’-}Y""‘8r%ï¬"fl "22"†'. 2;» n‘r". mum:

03496-38 , was
mmâ€- ' fl

. f I

II’T' ‘wum? ‘é' wad: wwi: u ‘ ‘ Q rm,st

Cm :‘mci'm: «an inï¬wazm It. Mme? 3 umii harm

M 1m 5" W1 3:» Em 0.1: in mm M: aw 9mg gm?†Vim, ‘99:?“

Wait} 8333mm 3pm; 5:11:92 :“gr “imam:

WG-15 . $137
1'1

O sz‘opm

wan ‘ . “3139113561 .‘* ~' T‘t @er 7 er ‘

Cs Wï¬mmwmï¬
i ï¬mï¬a m

Of course, this is not a fair test but I still found it somewhat entertaining :)

If I may have a feature request, I would like to see rendering of some common programming languages. Particularly C and C++. Most of them look like English so it should not be a big problem.

willi6868 2015-06-18 08:49

Re: OCR on jolla
 
You also maybe should add a .nomedia-file to your app folder because the pictures will show up e.g. in Android Whats**p. :)

pichlo 2015-06-18 09:06

Re: OCR on jolla
 
Quote:

Originally Posted by willi6868 (Post 1473940)
You also maybe should add a .nomedia-file to your app folder because the pictures will show up e.g. in Android Whats**p. :)

What pictures? The ones Textractor takes? That might be tricky. The pictures are saved in your standard Pictures folder with all your other pictures.

They also show in Gallery. Unless Textractor deletes them immediately or provides a means to do that within the app, I prefer to leave it as it is so I can delete them in Gallery.

skvark 2015-06-18 18:11

Re: OCR on jolla
 
Why should the app save the images to some other location than in the gallery? As pichlo noted, I'm not going to invent the wheel again if some other app already provides means to for example delete the image.

Quote:

If I may have a feature request, I would like to see rendering of some common programming languages. Particularly C and C++. Most of them look like English so it should not be a big problem.
What do you mean by "rendering of some common programming languages"?

And yes, taking an image of a screen is not going to work so well in most cases, the background is too hard for the preprocessing step unless there are clearly pure black/white regions.

pichlo 2015-06-18 20:43

Re: OCR on jolla
 
Quote:

Originally Posted by skvark (Post 1474060)
What do you mean by "rendering of some common programming languages"?

Sorry if I used a wrong term. What I mean is, take a picture of a snippet of e.g. a C code from a book and convert it to text. The formatting may come out wrong but most languages do not care. In pathological cases like e.g. Python, the user will have to do some post-processing.

Quote:

And yes, taking an image of a screen is not going to work so well in most cases, the background is too hard for the preprocessing step unless there are clearly pure black/white regions.
Mine was black text on pure white background but it did not work because you could clearly see the raster in the photo, even though it was invisible with a naked eye. I am aware that this is a challenge and was not expecting miracles.

skvark 2015-06-20 18:59

Re: OCR on jolla
 
Quote:

Originally Posted by Casanunda (Post 1473842)
Seems like photos have to be taken in "landscape view". Is that supposed to be like this?
Did some tests and all the pictures I took in portrait mode result in complete rubbish shown after processing...

But in correct view, recognition is actually quite good (Language: German).

The images are rotated according to orientation sensor readings. This means that the images will end likely in wrong orientation if the camera is pointing down - there's no way to detect the orientation reliably in this situation. How could the phone know which is the correct orientation?

I will add an feature which allows to lock the orientation in camera mode.

objectifnul 2015-06-20 21:06

Re: OCR on jolla
 
Best results so far when Textractor used combined with Sailfish Scanner to make pictures.

skvark 2015-06-21 17:35

Re: OCR on jolla
 
Quote:

Originally Posted by objectifnul (Post 1474289)
Best results so far when Textractor used combined with Sailfish Scanner to make pictures.

Similar feature is going to be added to Textractor.

I'm not sure if resuing Sailfish Scanner code is good solution for this since it would introduce additional dependencies to Python and to some Python modules. I believe I can replicate the same functionality with less code utilizing native QTransform class. However, depending on license (I didn't see any), the qml side could be useful to look at.

objectifnul 2015-06-21 20:36

Re: OCR on jolla
 
Excellent. One thing that makes sailfish-scanner an adequate image maker for Textractor (besides its edit features) is that it privileges short exposure time so it reduces the risk of fuzziness. Perhaps a good idea would be to allow short exposure time with ISO value increased accordingly.

skvark 2015-08-21 21:33

Re: OCR on jolla
 
I finally found some time to implement some new features. The work is still ongoing, but currently following new features are implemented:
  • orientation modes (automatic, portrait, landscape)
    • automatic mode uses orientation sensor to rotate the image, portrait and landscape will lock the orientation
  • Cropping possible after image has been taken/selected

I'll probably add support for text extraction from PDF files too. Some small enchancements for example to camera behaviour will be done too.

skvark 2015-09-19 20:49

Re: OCR on jolla
 
There's now a pre-release available for testing: https://github.com/skvark/Textractor...ses/tag/v0.5-0

If there are no big bugs, I will push next release to the Jolla Store in near future.

Changelog:

New features:
  • Camera orientation modes: automatic, landscape, portrait
  • Cropping with perspective correction
  • Reordering in language selection dialog: already downloaded languages are on top of the list
  • Text extraction from PDF files
  • Preprocessed image now shows up at the processing page (known issue: some images show up completely black but in reality they are ok)
  • OCR status in application cover

Bug fixes:
  • Increased scaling factor for small images to prevent preprocessing error during background normalization
  • SFOS 2.0 specific: replace missing icons with available ones

Miscellaneous:
  • Update Tesseract OCR from 3.04rc1 to 3.04.00 release
  • Poll tesseract monitor faster (500 ms -> 250 ms)
  • Fixed some typos and updated hints page
  • Small UI fixes and changes

skvark 2015-10-18 12:32

Re: OCR on jolla
 
I added i486 build to GitHub: https://github.com/skvark/Textractor...ses/tag/v0.6-0

Can someone who has the tablet test it? I can't test the app completely on emulator.

This version is identical to the phone version, no changes in code. Locked in portrait mode and doesn't look very good on the tablet. I'll add this version to the store if it works correctly. I will enhance the tablet UI when I have time.

KylliOrvokki 2015-10-18 15:04

Re: OCR on jolla
 
Quote:

Originally Posted by skvark (Post 1485925)
I added i486 build to GitHub: https://github.com/skvark/Textractor...ses/tag/v0.6-0

Can someone who has the tablet test it?

Installed and it seems to work at least with finnish language.
Any specific test you would want me to try?



One usability proposal:
When cropping those corner points -> they are really close to edge so its difficult to move them without app starting to minimize.
So those "balls" could be little bit "in" all ready to make cropping easier.

skvark 2015-10-18 15:42

Re: OCR on jolla
 
Quote:

Originally Posted by KylliOrvokki (Post 1485935)
Installed and it seems to work at least with finnish language.
Any specific test you would want me to try?



One usability proposal:
When cropping those corner points -> they are really close to edge so its difficult to move them without app starting to minimize.
So those "balls" could be little bit "in" all ready to make cropping easier.

I'm mostly interested about the camera page and of course the app should not crash in any situation.

Yes, I have noticed the same usability issue and I'll fix it :)

I just noticed also that Harbour validation fails due to different allowed requires on i486 target (vs. armvhl7) so I have to make some changes to the app anyway before I can submit it to the store.

n950 2016-01-28 09:16

Re: OCR on jolla
 
2 Attachment(s)
Hello,

I take a picture from a Poker machine on CRT screen.

I want to extract all Counters from this machine to text format.

I select French and English languages but No/bad results.

Check attached pictures.

Why it's not possible to have all numbers correctly?

Thanks for help.


All times are GMT. The time now is 08:07.

vBulletin® Version 3.8.8