Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » Bazaar » Leptonica library support
Leptonica library support [message #23004] Sun, 06 September 2009 18:12 Go to next message
mdelfede is currently offline  mdelfede
Messages: 1259
Registered: September 2007
Senior Contributor
Hi,

I started the porting to UPP of Leptonica image library ( http://www.leptonica.com/ ).

The library provides many high-level raster operations on almost all pixel formats, like morphing, blending, pattern finding, document layout recognition and much more.

The library in bazaar by now wraps just a small amount of Leptonica functions, as the list is really huge, and will be extended in time.

There are 2 packages plus a test application :

PixRaster package : provides PixRaster class wich encapsulates PIX and PIXA Leptonica images and array of images.
It's a multipaged raster class, similar of MemoryRaster, but with many extensions.
Documenting is in progress (almost) with the function wrapping.

PixRasterCtrl package : provides PixRasterCtrl control, which (similar to RasterCtrl for StreamRaster class) provides display and more of Pixraster objects.

The test application demonstrates the usage of both; by now it duplicates just one of the huge amount of examples of Leptonica library, but it'll be extended too.
The example demonstrates background line removal, i.e. the "cleaning" of a scanned drawing originally drawn on a paper with horizontal lines. It uses deskewing of image (elimination of page rotation during scanning process), gray morphing and mask blending, with a really nice result.

On next days I'll add an example about document layout recognition, i.e. the separation of graphic and text parts of a scanned document.

Please beware, the porting has just begun, so it's surely not bug-free nor complete.
If somebody wants to help me with extending the lib/docs is wellcome !

Ciao

Max
Re: Leptonica library support [message #23006 is a reply to message #23004] Sun, 06 September 2009 23:51 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1259
Registered: September 2007
Senior Contributor
Added a simple document page layout analysis function, with the TestLeptonica demo updated.

I think this one shows one of the most interesting stuffs that can be done with Leptonica.

Ciao

Max
Re: Leptonica library support [message #23018 is a reply to message #23006] Tue, 08 September 2009 01:00 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1259
Registered: September 2007
Senior Contributor
Added routine for text baseline finding, with demo.

This one is able to :

1) Deskew (i.e. eliminate rotation of text scanned page)

2) Locate all baselines of text lines in the page.

The demo simply load a page, locates the baselines and shows them on a PixRasterCtrl.
Must be fed by 1 bpp (monochrome binary) image.

Ciao

Max
Re: Leptonica library support [message #23064 is a reply to message #23018] Sun, 13 September 2009 11:49 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1259
Registered: September 2007
Senior Contributor
I completely restructured the code, as it was becoming ugly Smile

Now we have :

PixBase class, a base for all Leptonica derived image classes
(Abstract class -- mainly used by PixRasterCtrl)

Pix class, encapsulating a single Leptonica image (PIX). It behaves as a single-paged Raster object.

PixRaster class, adding multipaged behaviour.

I started adding polygon markers to images too, useful for document analysis and extraction.

Ciao

Max
Re: Leptonica library support [message #23164 is a reply to message #23064] Sun, 20 September 2009 17:07 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1259
Registered: September 2007
Senior Contributor
Added rectangular marker handling on PixRaster/PixRasterCtrl.
They allow to mark rectangular (in future will be polygonal) areas
of images; markers are editable on PixRasterCtrl.
By now the demo supports just editing of pre-existing markers, next I'll add creation of them by point'n click.

Use : Page layout analysis of scanned documents, image parts extraction, and more.

Ciao

Max
index.php?t=getfile&id=1935&private=0
  • Attachment: lept.jpg
    (Size: 79.02KB, Downloaded 819 times)
Re: Leptonica library support [message #28177 is a reply to message #23164] Fri, 20 August 2010 14:27 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 2944
Registered: August 2008
Veteran
Hello Massimo

I wanted to compile TestLeptonica package in Windows but I have had some problems. I have used MinGW as it has simpler errors.

As there was errors for not finding png.h, tif.h and zlib.h I have added these internal includes to package:

../../uppsrc/plugin/png
../../uppsrc/plugin/tif/lib
../../uppsrc/plugin/z/lib

Compiling I get this errror:

In file included from C:\upp\uppsrc/Draw/Draw.h:6:0,
from C:\upp\uppsrc\plugin\png/png.h:4,
from C:\upp\bazaar\PixRaster\lib\pngio.c:110:
C:\upp\uppsrc/Core/Core.h:39:20: fatal error: typeinfo: No such file or directory

Do you have any idea?


Best regards
IƱaki
Re: Leptonica library support [message #28202 is a reply to message #28177] Mon, 23 August 2010 00:50 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1259
Registered: September 2007
Senior Contributor
Hi Koldo,

no clues, sorry... I just tried to compile with MSC8, but got tons of errors.
For the graphics libs, you can disable them in 'environ.h' include file, but then you'll have no I/O support for them.

I'll try to check it on windows when I'll have a bit more time.

Ciao

Max
Re: Leptonica library support [message #30048 is a reply to message #28177] Sun, 05 December 2010 07:16 Go to previous message
o_wild is currently offline  o_wild
Messages: 28
Registered: December 2008
Location: Urmqi
Promising Member

koldo wrote on Fri, 20 August 2010 14:27

Hello Massimo

I wanted to compile TestLeptonica package in Windows but I have had some problems. I have used MinGW as it has simpler errors.

As there was errors for not finding png.h, tif.h and zlib.h I have added these internal includes to package:

../../uppsrc/plugin/png
../../uppsrc/plugin/tif/lib
../../uppsrc/plugin/z/lib

Compiling I get this errror:

In file included from C:\upp\uppsrc/Draw/Draw.h:6:0,
from C:\upp\uppsrc\plugin\png/png.h:4,
from C:\upp\bazaar\PixRaster\lib\pngio.c:110:
C:\upp\uppsrc/Core/Core.h:39:20: fatal error: typeinfo: No such file or directory

Do you have any idea?


You should add 'lib' as internal includes to package plugin/jpg, plugin/tif and plugin/z using package organizer. I've solved it.
However, another error occurs. My platform is Win32, so 'fh' is defined as 'HANDLE',but my compiler(mingw) report an error about the function 'fdopen', see below.

bool Pix::Load(FileIn &fs, int page)
{
int format;
#ifdef WIN32
HANDLE fh;
#else
int fh;
#endif

Destroy();

fh = fs.GetHandle();
if (!fh)
return false;
FILE *fp = fdopen(fh, "r");
if(!fp)
return false;
...
}
error message:
G:\MyApps\PixRaster\PixRaster.cpp:792:27: error: invalid conversion from 'void*' to 'int'
G:\MyApps\PixRaster\PixRaster.cpp:792:27: error: initializing argument 1 of 'FILE* fdopen(int, const char*)'

Wild
Previous Topic: PlotCtrl revisited
Next Topic: Simple app-wide "macros"
Goto Forum:
  


Current Time: Mon Apr 22 00:06:47 CEST 2019

Total time taken to generate the page: 0.01207 seconds