Friday, August 28, 2009

Second Interaction with Tesseract OCR

I had quite some fun during the first interaction with Tesseract. While some of the outputs of the recognizer was good, others were not reasonable at all. I want to debug it -- but the best possible way seems to be their new viewer in java. To make it run, I followed the instructions as given on the above link (the only problem was that they call piccolo-1.2.jar/piccolox-1.2.jar while the downloaded file was named piccolo.jar/piccolox.jar).

After this I tried running
tesseract phototest.tif test1 segdemo inter
as per their instructions, but it would not work. I realized this is because of missing file at /usr/local/share/tessdata. Therefore, I did:

sudo cp -R /tessdata/* /usr/local/share/tessdata/

But this undid the change done previously (in the first installment) for english recognition. Therefore I had to copy the eng data files again:

sudo cp -R /tessdata/eng.* /usr/local/share/tessdata/

After this I ran the viewer on my own image. It worked but it kept on saying

ScrollView: Waiting for server...
ScrollView: Waiting for server...
ScrollView: Waiting for server...
ScrollView: Waiting for server...

Some problem with starting the server. I retried with the image they provide in as instructed on their page and it worked. If it does not work for you (it did fail for me once or twice), make the change as described under "Java problems" on the link above and make, copy the new tesseract binary to /usr/local/bin.

Sometimes I had to manually kill the previous java GUI as it would not allow the GUI to start the next time.

I still have not not been able to run the viewer with my own images. Some catch there.

Thursday, August 27, 2009

Rdesktop woes: Connecting from Linux to Windows Vista

I use rdesktop on Ubuntu to connect to Windows Vista on univ lan. Some time after I connect, the connection hangs. A little search on Ubuntu forums revealed that setting Control Panel > Mouse > styles to (none) can reduce/eliminate the hanging. Even now the connection intermittently freezes, but the frequency is much lesser and the duration of freeze is lesser too.

I also installed "GRDC" Gnome RDC client, which works quite well (as well as windows rdesktop client).

Still in lookout for a better solution to connect to Vista, without the freezes.

Excluding Multiple Directories using Doxygen EXCLUDE tag

After a lot of search I found at http://developer.kde.org/documentation/library/howto.php how one can specify multiple excluded sub-directories in the following format:

EXCLUDE = {directory 1} {directory 2} ...

Doxygen is such a nifty tool. The pleasure would have been additional if the config files contained very simple format examples.

Default Doxyfile for Code Understanding

The most often use-case of doxygen for me is to quickly understand the source code. Several of the configurations within the default-generated doxyfile are different from the way you would like it to be to generate detailed information for understanding the code. Below I paste the diff that can be used to patch the default generated doxyfile to configure it for code understanding. The config below assumes we have installed the "dot" tool (installing dot is a good idea anyway as it is a nifty graph display tool).

28c28
< project_name =" ---"> PROJECT_NAME = project_name
300c300
< extract_all =" NO"> EXTRACT_ALL = YES
305c305
< extract_private =" NO"> EXTRACT_PRIVATE = YES
310c310
< extract_static =" NO"> EXTRACT_STATIC = YES
473c473
< show_directories =" NO"> SHOW_DIRECTORIES = YES
590c590
< recursive =" NO"> RECURSIVE = YES
683c683
< source_browser =" NO"> SOURCE_BROWSER = YES
688c688
< inline_sources =" NO"> INLINE_SOURCES = YES
700c700
< referenced_by_relation =" NO"> REFERENCED_BY_RELATION = YES
706c706
< references_relation =" NO"> REFERENCES_RELATION = YES
738c738
< alphabetical_index =" NO"> ALPHABETICAL_INDEX = YES
977c977
< generate_latex =" YES"> GENERATE_LATEX = NO
1342c1342
< have_dot =" NO"> HAVE_DOT = YES
1390c1390
< uml_look =" NO"> UML_LOOK = YES
1482c1482
< dot_transparent =" NO"> DOT_TRANSPARENT = YES

First Interactions with Tesseract OCR on Ubuntu Linux

I am on Ubuntu 9.04. My primarily goal here is to informally evaluate how Tesseract performs on some documents, including handwritten samples. After downloading, building and installing tesseract as at http://code.google.com/p/tesseract-ocr/w/list I ran tesseract over a jpg file containing the sample text.

$> tesseract text_image.jpg result
Unable to load unicharset file /usr/local/share/tessdata/eng.unicharset

I made the changes as per comment by caitifty on Feb 28, 2009 (sigh, there is no permalink) at http://code.google.com/p/tesseract-ocr/wiki/ReadMe . The change is to replace/add the tessdata directory at /usr/local/share/tessdata . After this, I get

$> tesseract text_image.jpg result
Tesseract Open Source OCR Engine
name_to_image_type:Error:Unrecognized image type:text_image.jpg
IMAGE::read_header:Error:Can't read this image type:text_image.jpg
tesseract:Error:Read of file failed:text_image.jpg
Segmentation fault

It appears that it does not recognize jpg file input. So I use imagemagick's "convert" tool to convert to tif format that tesseract seems to recognize.

$> convert text_image.jpg text_image.tif

and then

$> tesseract text_image.tif result
Tesseract Open Source OCR Engine
Image has 8 * 3 bits per pixel, and size (1000,171)
Resolution=200

$> cat result.txt

The last command produced the recognized text. The results were quite good.

Wednesday, August 19, 2009

Sourceforge: Recovering Wikispaces Dump after Migration to Mediawiki

Are you confused with what they at sourceforge say about the process to recover wikispaces dump? https://sourceforge.net/apps/wordpress/sourceforge/2009/07/29/wikispaces-being-removed-from-sourceforge-net-2009-07-30/

Don't be. It is easy. I did this (as described at https://sourceforge.net/apps/trac/sourceforge/wiki/SFTP):

:~$ sftp {user name},{project name}@frs.sourceforge.net
Connecting to frs.sourceforge.net...
The authenticity of host 'frs.sourceforge.net (216.34.181.57)' can't be established.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'frs.sourceforge.net,216.34.181.57' (RSA) to the list of known hosts.
{user name},{project name}@frs.sourceforge.net's password:
sftp> help
sftp> cd /home/groups/c/cr/crackpot
sftp> ls
cgi-bin htdocs persistent wikispaces-dump.zip
sftp> get wikispaces-dump.zip
Fetching /home/groups/c/cr/crackpot/wikispaces-dump.zip to wikispaces-dump.zip
/home/groups/c/cr/crackpot/wikispaces-dump.zip 100% 648KB 49.8KB/s 00:13
sftp> quit

Monday, August 10, 2009

Flickr with Linux (Aug 10, 2009)

I am trying to upload a large number of photos onto my pro flickr account. I tried the following tools:
* Postr
* Fireuploader (firefox plugin)
* jUploader

Postr and Fireuploader appear buggy and have a somewhat unintuitive interface. I struggled with them a lot. Finally I read somewhere on the net about jUploader.

I downloaded jUploader (not present in Synaptic Package Manager on my ubuntu). After authentication, the first problem I faced is that it does not recognize "JPG" (uppercase) extension. So I had to change all my filenames to lowercase using

rename 'y/A-Z/a-z/' *

I also changed the default permission on upload from public to private from its menu. Then I just dragged and dropped my photos onto jUploader, selected all photos, added to photoset and clicked on upload. It worked just fine after this. Although not perfect, jUploader was close.

Note: I faced the problem of "I don't recognize this file format" because there was no privilege to read the image file as my current user.

I installed the flock browser, which also worked just fine (or should I say marvellously fine).