• Welcome to OS2World OLD-STATIC-BACKUP Forum.
 

News:

This is an old OS2World backup forum for reference only. IT IS READ ONLY!!!

If you need help with OS/2 - eComStation visit http://www.os2world.com/forum

Main Menu

Tesseract Font Box Editor (PM/GUI)

Started by jep, 2009.01.18, 12:15:56

Previous topic - Next topic

jep

Marked as: Advanced
Hello,

I've been working an a GUI tool so tesseract can handle more languages, but now I need some help from you to complete it. It's written in/for DrDialog, though the actual rexx code reside in a plain text file (eFTBE.rex), just as one write for command line mode and should therefore not cause you troubles to read, just open it with EPM¹.



Please log on to this forum to download the zip-file with the code and to see the image I've prepared how it look and behave in its current state. To try it out and see what each part does, download DrDialog from hobbes for free with additional fixes to look at the graphical stuff.

You may also look at Douglas Clark's excellent articles about DrDialog at OS/2 eZine on how to install it, what each part of it does and how to use it.

What I want you to do is to add another function, select one below and try, see more info about it at the Tesseract training page.

  • Fix current limitations and problems
  • Generate training images
  • Make Box Files (*Done, may need patch/fix)
  • Bootstrapping a new character set
  • Run Tesseract for Training
  • Clustering
  • Compute the Character Set
  • Dictionary Data
  • The last file (intrinsic ambiguity between characters)





¹) You can turn on syntax highlighting as well in EPM so you can read the code easier.
a) Open EPM
b) Right click next to the buttons on a free area
c) Select "Buffet..." from the menu
d) Click on the narrow button to the right to scroll to the right
e) Look for a button with the text KwdHilit, drag it to the toolbar below
f) Click on the button OK to close the window
g) A message tell you to save the changes to the toolbar or you'll loose it the next time you open EPM.
h) Therefore, right click next to the buttons again and select "Save as..." this time
i) Type "Highlight" (without the quotes) in input field that appear in a small window.
j) Make this toolbar the one to always use by selecting "Options->Preferences->Settings..." from the menu
k) Click on the last tab (Toolbar) in the window that appear
l) Select the toolbar you just saved from the dropdown menu
m) Click on the button "Make current" and ensure that "Display toolbar" is checked.
n) Click on the tab labeled "Colors", as wee need to make an adjustment.
o) Select "Text" in the list and background on the radio buttons below.
p) Select "Light_grey" in the list to the right for color selection to ensure that known Rexxutil functions are viewable too.
q) Close and Select "Options->Save options" from the menu.
r) You now have another button, click on it to get syntax highlighting.





Note 1: You have to open a file first before you can use syntax highlighting.
Note 2: Syntax higlighting only work on known file types (.c, .cpp, .rex, .cmd and several more)
Note 3: Rexxutil functions appear in white, so they disappear if we don't change the background color to light grey.

//Jan-Erik

Batchheizer

Hi Jep!
Great idea. I'm working with tesseract for OCR on a WIKI-SOURCE project. Therefore I need the old-german language-support (fractur). But it has some problems with "A" and other characters. If your program could solve these problems it would be great.
I build the WPI and got therefor from Paul the updated 2.03-binaries. There were some problems on compiling the training-programs. Hope this is no problem for your project. Maybe new GCC can fix the porblems?
I don not know, if I find time for test it - but I can write a WPI for it if it's ready.

DavidG


jep

#3
Hello Batchheizer,

Glad to hear that you're working on tesseract, perhaps we could get some inside info or rexx support dll?!
Are you sure you tried an image saved in Black and White only, not gray scale? I made that mistake the first 20 times to take an image that looked all right to me that contained anti aliased text. I was ashamed for my mistake when I found out about what I did wrong.





Anyway, I've used eTFBE to test a text I wrote for a paper magazine that we distribute to members (not OS/2-eCS related tough) in the region where I live here in Sweden. I may add that Swedish contain the additional letters åäö (ÅÄÖ) over the English ones, something tesseract doesn't recognize unless one teach it to first. That were eTFBE come in, as one should use it to create the support configuration for each language that tell it that e.g. the "dirt" over "A", "O" etc. should be considered as well.

eTFBE can do a few more tricks to help you as user.
Type space to make the Editor add a space in the view, nothing will be added to the box file though, but you can save it as text (ascii or utf8) and then reuse it in eTFBE.
If you store the original text in a text file and open it in the editor, it will re flow and analyze the text automatically (until it find a problem). The unicode support contain a function that can disassemble characters for comparison. It is very useful in the import/open project and text routines as it then can adjust characters that tesseract interpret as A even though they're Ä (remember the "dirt" above), but it will stop and report on problems like "rn" that tesseract may interpret as the single character "m". Note that eTFBE does in no way interpret the image itself, but rather (re)use knowledge presented in a text file that should represent the truth. ("baseline"/answer).

eTFBE won't be affected by problems in tesseract and the supporting executables, unless they provide strange output. Another thing is that it hasn't progressed that long that it use so many of those, but it will hopefully do soon, with help from you, the reader.

When you start eTFBE it will tell you what support functions it can't load/find, click on each link to go to each developers page and download each function.

Download Tesseract from: hobbes
Download DrDlgCtrl from: Chris Wolgemuth's page
Download REXXULS from: Alex Taylor's page
Download GBM from: Heiko Nitzsche's page
Download rxImgSze from: Jan-Erik Lärka's page

//Jan-Erik

jep

Hello DavidG,

Yes, it's currently used for the image viewer and tooltip part in the project. I've got an issue with it though that has to be fixed, e.g. that RexxFuncQuery doesn't think that DRCtrlVersion has been loaded so it show the download link/page all of the time instead of version info.





Additional info:
To create a function for the second point in the list "Generate training images" we also need a rexx support .dll that can take text and output it as a .tiff-image in B&W.

//Jan-Erik

Batchheizer

Hi Jep!
Of cause I run only B/W-Tiffs with tesseract.
I tried to run your rexx-script - but I have no time to learn about Dr.Dialog and so on. If you build an executable I could test it. Write me a message for this. I hope you find hints to get this done.

Is the purpose of the project to build and improve language-packs? If so, is the training software on google-code better for this purpose? Can other platforms read and use the new/improved packs (created with your software)?

warpcafe

Hej jep,

Quote from: jep on 2009.01.18, 18:38:13
To create a function for the second point in the list "Generate training images" we also need a rexx support .dll that can take text and output it as a .tiff-image in B&W.

not sure but I guess gbm can do that...(?)
And if not... how about ghostscript in the background?

And, ehhh... sorry but regarding DrDialog, if someone wants to learn about it, there's also a quite extensive series of articles about it on the VOICE newsletter (both English and also German).

Cheers,
Thomas
"It is not worth an intelligent man's time to be in the majority.
By definition, there are already enough people to do that"
- G.H. Hardy

jep

Hello Batchheizer,

Quote from: Batchheizer on 2009.01.18, 22:35:51
Hi Jep!
Of cause I run only B/W-Tiffs with tesseract.
I tried to run your rexx-script - but I have no time to learn about Dr.Dialog and so on. If you build an executable I could test it. Write me a message for this. I hope you find hints to get this done.
If you've got DrDialog installed, then you just have to open it and run it. It'll run just as any executable except for the debug window. Then you cn drag & drop it on the Rex2Exe Icon and it'll give you what you want.

At the moment it output text files (ascii or utf8-encoded) and the box file mentioned in the list as *Done.
You can teach it/improve the .box file with it.

Text to image: Not yet, I want you readers to code a section for that.

Quote
Is the purpose of the project to build and improve language-packs? If so, is the training software on google-code better for this purpose? Can other platforms read and use the new/improved packs (created with your software)?

Yes, it is intended to create language packs.
Do you mean the training software included with tesseract (text mode apps)?
If so, that's the ones it'll use.
If not, you mean the GUI software other people has made in some compiled code that one can get from google?
Well, its meant to be the equivalent for OS/2-eCS, but not do things forced on us by how other OSes does it. If the google-code (GUI) is better? Probably at the moment, if it can do more of the things mentioned on the traning tesseract page, yes. But to what I've read, they're not that far ahead.

The purpose is to create files that follow the standard and not produce any specific to this software.

//Jan-Erik

jep

#8
Hello warpcafe,

Quote from: warpcafe on 2009.01.19, 00:25:05
not sure but I guess gbm can do that...(?)
And if not... how about ghostscript in the background?
Heiko may have the answer if GBM can be used, but I don't think so in its current form, it's aimed at other things. I know there are libraries that can do it, but perhaps not to TIFF directly.

Text -> Ghostscript -> TIFF
Sounds interesting, but can you or someone else give a hint how to do it? I don't feel I have the knowledge.

Quote
And, ehhh... sorry but regarding DrDialog, if someone wants to learn about it, there's also a quite extensive series of articles about it on the VOICE newsletter (both English and also German).

Ohhh, yes, quite right, your series cover alot of what one can do with DrDialog. I waited and read through them all when they came out, great reading as well.

Links to each of the OS2VOICE Newsletters:
DrDialog, or: How I learned to stop worrying and love REXX - Part 1
DrDialog, or: How I learned to stop worrying and love REXX - Part 2
DrDialog, or: How I learned to stop worrying and love REXX - Part 3
DrDialog, or: How I learned to stop worrying and love REXX - Part 4
DrDialog, or: How I learned to stop worrying and love REXX - Part 5
DrDialog, or: How I learned to stop worrying and love REXX - Part 6
DrDialog, or: How I learned to stop worrying and love REXX - Part 7
DrDialog, or: How I learned to stop worrying and love REXX - Part 8
DrDialog, or: How I learned to stop worrying and love REXX - Part 9
DrDialog, or: How I learned to stop worrying and love REXX - Part 10
DrDialog, or: How I learned to stop worrying and love REXX - Part 11
DrDialog, or: How I learned to stop worrying and love REXX - Part 12
DrDialog, or: How I learned to stop worrying and love REXX - Part 13
DrDialog, or: How I learned to stop worrying and love REXX - Part 14

One thing I thnik they didn't cover, not related either, but useful non the less, is how to extract the images built in to drrexx.exe, alter them to something modern looking and use rc.exe to put them back into drrexx.exe. That way one doesn't have to use extra image dll's but just call the images inside the executable. Something like the example on how to tweak the looks of OS2Chess. I've tried it, and the result looked... awful... because the images I used, didn't look that great. ;-)

//Jan-Erik

DavidG

Hi Jan-Erik

I was playing around and made a few bitmaps for DrDialog.  If you like, I would try to make more when I have time.  I have attached them below.

David

jep

Hello David,

I like 'em, they look real good, great work David! :)
Would be nice if we could get a unified look on all buttons in as many apps as possible. May we use your work?

One button I have a concern about is the group box though, it look like it display a group of people on an image/picture on a box (just as "group box" sounds like), though one might want to let it portray something like a "named container with a border" or something closer to what the developer will see/get as he/she push the button. The same goes for many development tools, I guess. End user apps are different.

Can you disassemble drrexx.exe, drdialog.exe some time and suggest more improvements just as these?
Perhaps create some equivalent/replacement to drdialog.dll as well?

[hr width="70%"]
I'll look into the issue where TFBE doesn't load the image when one open an existing project.

//Jan-Erik

jep

#11
A small instruction how to use the current version of the Tesseract Font Box Editor

You need some additional libraries to do various things, e.g. convert images, calculate sizes and color depth, convert between different codepages and allow you to view then image. See the About screen for links, click on each link to visit those pages and download the libraries.

"Image of eTFBE and a test image (German)"

1. Create a black and white tiff image with some text you want to test
2. Open eTFBE
3. Select and open the image
   a) Menu: File -> Open -> B&W TIFF...
   b) Select: Image
4. Create a box file
   a) Menu: OCR -> Box
5. Save your work as a Project
   a) Menu: File -> Save As -> Project
   b) State a name of the Project, e.g. "Deutsch"
6. Edit each character in the Editor (or Selection window)
   a) Keyboard: a, b, c ...
      * It change the selected character, jump to the next and wait for the next key stroke
   b) Keyboard: " "
      * (space) add a space to make the text more readable, but doesn't save to the box-file
   c) Keyboard: ½
      * (half sign) split a character in 2
   d) Keyboard: Arrow
      * (Up/Down/Left/Right) to move between characters and rows
   e) Keyboard: Alt + number
      * ONLY WORK PARTIALLY, PLEASE ADVICE FIX
7. Remember to adjust the selection for each character that you join and split in the Selection window
   a) Click the button OK to store changes for that character
8. Save your work
   a) Menu: File -> Save
9. Close Project to work on something else
   a) Menu: File -> Close
10. Open (another) Project
   a) Menu: File -> Open -> Project
11. Select folder with the name of the Project that contain the project files
12. The image will load, the last saved state will be read, restored and presented, with window sizes restored.


________
Need 4 speed, or just in a hurry?

eTFBE can analyse the text and adjust it, report ambiguities and let you type only letters that doesn't look right.
5.1) Create the text file (ASCII or UTF-8) with the original text and layout (newline for each row on the image).
5.2) Open the prepared text file
   a) Menu: File -> Open -> ASCII Text File...
   or
   b) Menu: File -> Open -> UTF-8 Text File...

7.1) If it complain about a problematic character, adjust it as in 6) and 7), then repeat step 5), 5.1), 5.2) etc. until you're done.

_________

Please help me make it better, have a look at it and try to figure out if things aren't working, or behave strange. Let's hear about it in the forum. There are some things that I can't do much about though (load the image viewer the second time one start it), but I appreciate if you have suggestions and/or code snippets to improve it.

Batchheizer

Hi Jep,
Thanks for this new version. I'll try it in the next days. All above URLs in your postings are invalid - put I got the files. Except one: How can I get "Download rxImgSze from: Jan-Erik Lärka's page"?

Batchheizer

jep

Hello Batchheizer,

Ohhps, sorry about that, thank you for notifying me of the problem. SMF apparently add extra http:// and doesn't like quote signs around links. :-(
I've now corrected all the links in this thread so that they work (Thomas articles about DrDialog at OS/2Voice and the links to required libraries from various sources).

The link to my own server (rxImgSze from: Jan-Erik Lärka's page) should also work now :-)

You can also find rxImgSze in another topic here in the rexx forum regarding Resizing of Images and require you to have GBM installed to work.

//Jan-Erik

warpcafe

Hi all,

Quote from: jep on 2009.01.22, 09:19:18
Can you disassemble drrexx.exe, drdialog.exe some time and suggest more improvements just as these?
Perhaps create some equivalent/replacement to drdialog.dll as well?

Goodness! If someone is able to do that, can he/she please-please have a look at the famous "Warp4 style notebook" topic and let us know how to patch /reassemble DrDialog such that it is able to use the "warp" (more contemporary) style for notebook controls? :)

Cheers,
Thomas
"It is not worth an intelligent man's time to be in the majority.
By definition, there are already enough people to do that"
- G.H. Hardy