Giter VIP home page Giter VIP logo

danbloomberg / leptonica Goto Github PK

View Code? Open in Web Editor NEW
1.7K 76.0 382.0 21.48 MB

Leptonica is an open source library containing software that is broadly useful for image processing and image analysis applications. The official github repository for Leptonica is: danbloomberg/leptonica. See leptonica.org for more documentation.

License: Other

Shell 0.18% C 97.81% PostScript 0.03% HTML 0.79% CMake 0.33% Makefile 0.11% M4 0.09% C++ 0.62% Lua 0.03%

leptonica's Introduction

Leptonica Library

sw

www.leptonica.org

The library supports many operations that are useful on

  • Document images
  • Natural images

Fundamental image processing and image analysis operations

  • Rasterop (aka bitblt)
  • Affine transforms (scaling, translation, rotation, shear) on images of arbitrary pixel depth
  • Projective and bilinear transforms
  • Binary and grayscale morphology, rank order filters, and convolution
  • Seedfill and connected components
  • Image transformations with changes in pixel depth, both at the same scale and with scale change
  • Pixelwise masking, blending, enhancement, arithmetic ops, etc.

Ancillary utilities

  • I/O for standard image formats (jpg, png, tiff, webp, jp2, bmp, pnm, gif, ps, pdf)
  • Utilities to handle arrays of image-related data types (e.g., pixa, boxa, pta)
  • Utilities for stacks, generic arrays, queues, heaps, lists, sets, ordered maps, hashmaps; number and string arrays; etc.

Examples of some applications enabled and implemented

  • Octcube-based color quantization (w/ and w/out dithering)
  • Modified median cut color quantization (w/ and w/out dithering)
  • Determination of skew and orientation of text images
  • Adaptive background normalization and binarization
  • Segmentation of page images with mixed text and images
  • Color segmentation by clustering and seed-filling
  • Location of baselines and local skew determination
  • jbig2 unsupervised classifier
  • Border representations of 1 bpp images and raster conversion for SVG
  • Postscript generation (levels 1, 2 and 3) of images for device-independent output
  • PDF generation (G4, DCT, FLATE) of images for device-independent output
  • Connectivity-preserving thinning and thickening of 1 bpp images
  • Image warping (captcha, stereoscopic)
  • Image dewarping based on content (textlines)
  • Watershed transform
  • Greedy splitting of components into rectangles
  • Location of largest fg or bg rectangles in 1 bpp images
  • Search for least-cost paths on binary and grayscale images
  • Barcode reader for 1D barcodes (very early version as of 1.55)

Implementation characteristics

  • Efficient: image data is packed binary (into 32-bit words); operations on 32-bit data whenever possible
  • Simple: small number of data structures; simplest implementations provided that are efficient
  • Consistent: data allocated on the heap with simple ownership rules; function names usually begin with primary data structure (e.g., pix); simple code patterns throughout
  • Robust: all ptr args checked; extensive use of accessors; exit not permitted
  • Tested: over 140 regression tests provided for basic functions and applications; valgrind tested
  • ANSI C: automatically generated prototype header file
  • Portable: endian-independent; builds in Linux, macOS, MinGW, Cygwin, Windows
  • Thread-safe: uses atomic operations for reference counting
  • Documentation: large number of in-line comments; doxygen; web pages for further background
  • Examples: many programs provided to test and show usage of over 2700 functions in the library

Open Source Projects that use Leptonica

  • tesseract (optical character recognition)
  • OpenCV (computer vision library)
  • jbig2enc (encodes multipage binary image documents with jbig2 compression)

Major contributors to Leptonica

  • Tom Powers: Tom supported the port of Leptonica to Windows for many years. He made many contributions to code quality and documentation, including the beautiful "unofficial documentation" on the web site.
  • David Bryan: David has worked for years to support Leptonica on multiple platforms. He designed many nice features in Leptonica, such as the severity-based error messaging system, and has identified and fixed countless bugs. And he has built and tested each distribution many times on cross-compilers.
  • James Le Cuirot: James has written and supported the autotools scripts on Leptonica distributions for many years, and has helped test every distribution since 1.67.
  • Jeff Breidenbach: Jeff has built every Debian distribution for Leptonica. He has also made many improvements to formatted image I/O, including tiff, png and pdf. He is a continuous advocate for simplification.
  • Egor Pugin: Egor is co-maintainer of Leptonica on GitHub. He ported everything, including all the old distributions, from Google Code when it shut down. He set Leptonica up for appveyor and travis testing, and has implemented the sw project, which simplifies building executables on Windows.
  • Jürgen Buchmüller: Jürgen wrote text converters to modify Leptonica source code so that it generates documentation using doxygen. He also wrote tiff wrappers for memory I/O.
  • Stefan Weil: Stefan has worked from the beginning to clean up the Leptonica GitHub distribution, including removing errors in the source code. He also: suggested and implemented the use of Coverity Scan; implemented atomic ops for ref counting; helped removing internal struct data from the public interface.
  • Zdenko Podobny: Zdenko has worked, mostly behind the scenes as a primary maintainer of tesseract, to help with leptonica builds on all platforms, and coordinate with its use in tesseract.
  • Adam Korczynski: Adam is an expert in testing libraries for safety. He has built most of the open source fuzzers for leptonica in the oss-fuzz project, with significant code coverage.

Installing leptonica (vcpkg)

  • You can build and install leptonica using vcpkg dependency manager:
    git clone https://github.com/Microsoft/vcpkg.git
    cd vcpkg
    ./bootstrap-vcpkg.sh # "./bootstrap-vcpkg.bat" for powershell
    ./vcpkg integrate install
    ./vcpkg install leptonica
  • The leptonica port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

leptonica's People

Contributors

1480c1 avatar adamkorcz avatar amitdo avatar atykhyy avatar autoantwort avatar borismansencal avatar chewi avatar cysp avatar danbloomberg avatar davidkorczynski avatar diizzyy avatar egorpugin avatar gerhobbelt avatar haikusw avatar ionic avatar neheb avatar peirick avatar pullmoll avatar robinwatts avatar rofl0r avatar shatur avatar sthibaul avatar stweil avatar sumedhghaisas avatar tdhintz avatar theirix avatar vjeranc avatar vrabaud avatar xcorail avatar zdenop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leptonica's Issues

Cygwin-specific instructions inside Makefile inconsistent with README.html

What steps will reproduce the problem?
1. Line 122 in src/Makefile reads: on cygwin, comment out viewfiles.c
2. Compare to 6.(b)(1) in README.html
3. Line 122 should read: on cygwin, delete viewfiles.c

What is the expected output? 
A liblept.a which includes writefile.o (includes a reference to _pixWrite)

What do you see instead?
If the viewfiles.c line is commented out instead of deleted, GNU make will
also omit writefile.c from the build because it respects the escaped
newline in the comment.  liblept.a still builds successfully but when
linked to other code (such as in prog) this error results:
liblept.a(readfile.o):readfile.c:(.text+0x5c6): undefined reference to
`_pixWrite'

What version of the product are you using? 
leptonlib-1.37

On what operating system?
WinXP SP2 with Cygwin DLL 1.5.21 (GCC 3.4.4 and GNU Make 3.81)

Please provide any additional information below.
1. Used g++ for CC instead of gcc.  If g++ is used in src/Makefile but not
in prog/Makefile, this error occurs:
adaptmaptest.c:1: warning: -fPIC ignored for target (all code is position
independent)
make: *** [adaptmaptest.o] Error 1

2. README.html has as a minor typo: 
"source list IPLIB_C" 
  should read 
"source list LEPTLIB_C"

Original issue reported on code.google.com by [email protected] on 23 Aug 2006 at 6:50

doesn't build on Ubuntu

What steps will reproduce the problem?
1. tar xvf leptonlib-1.67.tar
2. cd leptonlib-1.67
3. ./configure && make && make install

What is the expected output? What do you see instead?

[...]
/bin/bash ../libtool --tag=CC   --mode=link gcc  -g -O2 -no-undefined  -o 
xtractprotos xtractprotos.o liblept.la 
libtool: link: gcc -g -O2 -o .libs/xtractprotos xtractprotos.o  
./.libs/liblept.so -Wl,-rpath -Wl,/local/uplib/lib
./.libs/liblept.so: undefined reference to `sincos'
./.libs/liblept.so: undefined reference to `sqrt'
./.libs/liblept.so: undefined reference to `ceil'
./.libs/liblept.so: undefined reference to `tan'
./.libs/liblept.so: undefined reference to `powf'
./.libs/liblept.so: undefined reference to `sqrtf'
./.libs/liblept.so: undefined reference to `expf'
./.libs/liblept.so: undefined reference to `log'
./.libs/liblept.so: undefined reference to `sincosf'
./.libs/liblept.so: undefined reference to `atan'
./.libs/liblept.so: undefined reference to `logf'
./.libs/liblept.so: undefined reference to `floorf'
./.libs/liblept.so: undefined reference to `sin'
./.libs/liblept.so: undefined reference to `tanf'
./.libs/liblept.so: undefined reference to `atan2'
collect2: ld returned 1 exit status
make[1]: *** [xtractprotos] Error 1
make[1]: Leaving directory `/tmp/leptonlib-1.67/src'
make: *** [install-recursive] Error 1
%

What version of the product are you using? 1.67

On what operating system?  Ubuntu


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 26 Jan 2011 at 5:50

Suggested BMP Change - bug in pixReadStreamBmp

What steps will reproduce the problem?
1. try to load attached file

What is the expected output? What do you see instead?
Expect attached file to loads ok - instead get 'invalid image bytes' error

What version of the product are you using? On what operating system?
Latest: 1.66 - Windows 7

Please provide any additional information below.

Hi,

While using the leptonica library to process a bmp file (attached) I received 
the error 'invalid imagebytes' in 'pixReadStreamBmp' (in bmpio.c).

The associated bmp file had an 'imagebytes' value of 0 (which is possible when 
the compression type is 0 - see below)

Since you are already testing for compression == 0 earlier in the function, I 
would suggest changing:

    if (imagebytes != fileBpl * height)

to

    if (imagebytes != 0 && imagebytes != fileBpl * height)

Here are two references on the bmp file format which state the image size can 
be zero when compression is 0 (no compression):
http://en.wikipedia.org/wiki/BMP_file_format
http://www.fortunecity.com/skyscraper/windows/364/bmpffrmt.html

Original issue reported on code.google.com by [email protected] on 29 Oct 2010 at 2:11

Attachments:

pixRotate() leaves shear lines on 1 bpp images

What steps will reproduce the problem?
1. Try rotating an image using
pixd = pixRotate (pixs, radians, L_ROTATE_AREA_MAP, L_BRING_IN_WHITE, w, h);

What is the expected output? What do you see instead?
Image is rotated around lower left corner instead of center.
The comment for pixRotate states:
(1) Rotation is about the center of the image.

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
Attached are a sample 300 dpi image, and its deskewed version.

Also attached is a multipage tiff that shows the differences (this was
designed more for images with FEW differences so it's a bit pyschedelic).
The first page shows red for new pixels, green for removed pixels. The 2nd
page is the new image, the 3rd is the original image, the 4th is just the
added pixels, and the 5th is just the erased pixels. (The source for
binImageDiff() is in the LeptonicaVS2008Samples.zip I sent you for
inclusion in the next release).

You can see that the image is mostly unchanged near the lower left corner,
whereas big differences occur near the top right. If pixRotate() was
rotating about the center, I would expect to see the unchanged pixels near
the center instead.

Also note the artifacts introduced by doing L_ROTATE_AREA_MAP (which
implicitly converts the 1bpp image to gray), and then saving the result as
IFF_TIFF_G4.
Text lines that start with:

 causes; and accordingly
 right, it is their duty
 of repeated injuries
 to tyrants only.
 He has dissolved

have noticeable horizontal shifts in the middle of them.

Even using 600 dpi images doesn't eliminate the artifacts.

I've found that instead of directly rotating 1bpp images, its better to
convert explicitly to gray, block convolve, rotate using area mapping, and
then theshold back down to 1bpp.

Original issue reported on code.google.com by [email protected] on 1 Dec 2009 at 10:04

Attachments:

leptonlib-1.67. Program returns random data in a function.

I'm trying to build rpm-packages for openSUSE.

While testing compiler warnings I get errors, and packages can't be built.

I: Program returns random data in a function
E: liblept0 no-return-in-nonvoid-function adaptnorm_reg.c:148
E: liblept0 no-return-in-nonvoid-function graphicstest.c:83
E: liblept0 no-return-in-nonvoid-function lowaccess_reg.c:258
E: liblept0 no-return-in-nonvoid-function pixalloc_reg.c:139
E: liblept0 no-return-in-nonvoid-function rotatefastalt.c:72

Could you please make some changes in problem files?
Build log attached.

Original issue reported on code.google.com by [email protected] on 11 Nov 2010 at 9:36

Attachments:

gthumb won't work under Windows

What steps will reproduce the problem?
1. Try adaptmaptest.c.

What is the expected output? What do you see instead?
I expect to see all the junk_write_display* files I think.
Nothing.

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
Unfortunately, all prog programs that do something like:
    system("gthumb junk_write_display* &");

will have to be changed to something like this to work under Windows:    

    pixDisplayMultipleImages("junk_write_display*");

where pixDisplayMultipleImages() is something like:

/*!
 *  pixDisplayMultipleImages()
 *
 *      Input:  filepattern
 *      Return: 0 if OK; 1 on error
 */
l_int32
pixDisplayMultipleImages(const char  *filepattern)
{
char            buffer[L_BUF_SIZE];
#ifdef WIN32
char        pathname[MAX_PATH];
char        *dir;
char            *tail;
#endif

    PROCNAME("pixDisplayMultiple");

    if (!filepattern || strlen(filepattern) == 0)
        return ERROR_INT("filepattern not defined", procName, 1);

#ifndef COMPILER_MSVC
    snprintf(buffer, L_BUF_SIZE, "gthumb %s &", filepattern);
    system(buffer);
#else
    // irFanView wants absolute path for directory
    _fullpath(pathname, filepattern, sizeof(pathname));
    splitPathAtDirectory(pathname, &dir, &tail);

    snprintf(buffer, L_BUF_SIZE,
             "i_view32.exe \"%s\" /filepattern=\"%s\" /thumbs",
         dir, tail);
    system(buffer);
    FREE(dir);
    FREE(tail);
#endif

    return 0;
}

(As it turns out _fullpath will automatically change / to \ if necessary so
this should still work even if filepattern contains the wrong style pathsep
chars.)

Original issue reported on code.google.com by [email protected] on 4 Dec 2009 at 11:43

adaptnorm_reg.c fails because missing test file lighttext.jpg

What steps will reproduce the problem?
1. Run adaptnorm_reg.exe

What is the expected output? What do you see instead?
I expect to see normalized image.
Instead nothing is displayed for first case, because adaptnorm_reg can't
find lighttext.jpg.

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 24 Nov 2009 at 7:10

Tabs & spaces in source files

What steps will reproduce the problem?
1. View any source file.

What is the expected output? What do you see instead?
I expect source code to be consistently indented.
I see the correct indentation as long as the VS2008 tab settings are set as
described below.

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
I gather that you assume people have tabs set to 8 spaces, indent size is 4
spaces, and that indenting inserts spaces (not just tabs)?

In VS2008notes.htm I should add a section on setting the correct tab
settings for viewing Leptonica source files:

Tools > Options | Text Editor | C/C++ | Tabs

 Tab Size: 8
 Indent Size: 4
 [x] Insert Spaces
 [ ] Keep Tabs

rather than say:

 Tab Size: 4
 Indent Size: 4
 [ ] Insert Spaces
 [x] Keep Tabs

Original issue reported on code.google.com by [email protected] on 4 Dec 2009 at 8:16

dwamorph2_reg and dwamorph3_reg don't link?

What steps will reproduce the problem?
1. Try compile and link dwamorph2_reg and dwamorph3_reg.

What is the expected output? What do you see instead?
I expect to link dwamorph2_reg and dwamorph3_reg.
dwamorph2_reg and dwamorph3_reg fail to link because of an "unresolved
external symbol pixMorphDwa_3" error.

What version of the product are you using? On what operating system?
leptonlib-1.64
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
Maybe pixMorphDwa_3 is one of those auto-gen'ed functions that you have to
create by running another program? If so, then I think the comments at the
top of dwamorph2_reg and dwamorph3_reg should indicate the proper steps you
need to go thru to run these regression tests.

Original issue reported on code.google.com by [email protected] on 15 Jan 2010 at 7:13

getFilenamesInDirectory() in sarray.c doesn't correctly handle dirname with wrong directory sepchar under Windows

What steps will reproduce the problem?
1. Try running psioseg_reg using Windows. It calls
convertSegmentedPagesToPS("/tmp/junkimagedir", "/tmp/junkmaskdir", 2.0,
0.15, 190, 0, 0, "junkfile.ps") which will eventually fail.

What is the expected output? What do you see instead?
I expect to be get all the filenames in a directory.
Instead no filenames are returned (and this causes a crash later on).

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
Change the beginning of getFilenamesInDirectory() to:

getFilenamesInDirectory(const char  *dirname)
{
SARRAY           *safiles;
WIN32_FIND_DATAA  ffd;
size_t            length_of_path;
CHAR              szDir[MAX_PATH];  /* MAX_PATH is defined in stdlib.h */
HANDLE            hFind = INVALID_HANDLE_VALUE;
CHAR         *tmpDirname;

    PROCNAME("getFilenamesInDirectory");

    if (!dirname)
        return (SARRAY *)ERROR_PTR("dirname not defined", procName, NULL);

    length_of_path = strlen(dirname);
    if (length_of_path > (MAX_PATH - 2))
        return (SARRAY *)ERROR_PTR("dirname is to long", procName, NULL);

    if (stringFindSubstr(dirname, "/", NULL) > 0) {
        tmpDirname = stringReplaceEachSubstr(dirname, "/", "\\", NULL);
    strncpy(szDir, tmpDirname, MAX_PATH);
    FREE(tmpDirname);
    } else {
    strncpy(szDir, dirname, MAX_PATH);
    }
    szDir[MAX_PATH - 1] = '\0';

Original issue reported on code.google.com by [email protected] on 1 Dec 2009 at 8:19

Apps created with VS2010 crash when linked to the Leptonica VS2008 DLL

What steps will reproduce the problem?
1. Using Visual Studio 2010, link ioformats_reg to the distributed VS2008 
generated leptonlib.dll

What is the expected output? What do you see instead?
I expect ioformats_reg to run successfully.
Instead ioformats_reg crashes.

What version of the product are you using? On what operating system?
leptonlib-1.67
Microsoft Visual Studio 2010
Windows XP Pro SP3.

Please provide any additional information below.
This issue is really the tip of the iceberg. See 
http://stackoverflow.com/q/4171403/506524 for more details.

ioformats_reg.c calls testcomp() which does:

    fp = fopen(filename, "rb");
    findFileFormat(fp, &format);

findFileFormat() is in readfile.c (linked into leptonlib.dll). The
very first thing it does (after some argument checks) is:

    rewind(fp);

and that's where the crash occurs.

"How to link with the correct C Run-Time (CRT) library" 
http://support.microsoft.com/kb/140584 says:

   A reusable library and all of its users should use the same CRT library types and therefore the same compiler switch...

   If you do choose to mix CRT libraries, remember that you have two separate copies of the CRT, with separate and distinct states, so you must be careful about what you try to do across a CRT-boundary. There are many ways to get into trouble with two CRTs. Here are just a few:

   * There are two separate heaps. You cannot allocate (explicitly with new, malloc, or so on -- or implicitly with strdup, strstreambuf::str, or so on), and then pass the pointer across a CRT-boundary to be freed.
   * You cannot pass a FILE* or file handle across a CRT-boundary and expect the "stdio low-level IO" to work.
   * You cannot set the locale in one and expect the other's locale to be set. 

The distributed leptonlib.dll is built with Visual Studio 2008 and thus uses 
the msvcr90.dll C-Runtime Library. Any application created by VS2010 on the 
other hand will use msvcr100.dll.

We are thus "mixing CRT libraries" and have to follow the restrictions just 
mentioned. The leptonica API has to be changed so any FILE handles or allocated 
memory it creates can only be manipulated/freed using the API.

For example, in ioformats_reg.c you can't have do fp = fopen(filename) and 
expect rewind(fp) to work in leptonlib.dll.

Also, there will be a problem with things like getLeptonlibVersion() and 
getImagelibVersions() wherein you allocate memory in leptonlib but give no way 
to free that memory (that I know of).

Original issue reported on code.google.com by [email protected] on 14 Nov 2010 at 6:19

splitPathAtDirectory() in utils.c doesn't work under windows

What steps will reproduce the problem?
1. Try running psioseg_reg using Windows. It calls
convertSegmentedPagesToPS("/tmp/junkimagedir", "/tmp/junkmaskdir", 2.0,
0.15, 190, 0, 0, "junkfile.ps") which will eventually fail.

What is the expected output? What do you see instead?
I expect to be able to split paths.
Instead the entire path is returned (or nothing).

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
Change

    if ((lastslash = strrchr(cpathname, '/'))) {

to:

    if ((lastslash = strrchr(cpathname, sepchar))) {

Original issue reported on code.google.com by [email protected] on 1 Dec 2009 at 8:15

xtractprotos.c doesn't compile on Windows

What steps will reproduce the problem?
1. Try to compile xtractprotos.c.

What is the expected output? What do you see instead?
I expect to compile xtractprotos.c.

What version of the product are you using? On what operating system?
leptonlib-1.64
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
VC++ doesn't like the following:

  char buf[L_BUF_SIZE];

You'll have to change L_BUF_SIZE to the following like other places in
leptonica:

 #define L_BUF_SIZE 512

In VC++'s defense, it claims that C is more restrictive than C++. It
purposely disallows this in c files. It CAN handle array initialization
with static consts in C++ files. See
http://msdn.microsoft.com/en-us/library/eff825eh.aspx for details.

Original issue reported on code.google.com by [email protected] on 15 Jan 2010 at 7:43

trctest.c doesn't link.

What steps will reproduce the problem?
1. Build trctest.exe

What is the expected output? What do you see instead?
I expect to build trctest.exe.
Instead the build fails because neither pixLinearTRC() or
pixLinearTRCGray() are valid functions?

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 5 Dec 2009 at 11:47

MORPH_BC not thread-safe

The MORPH_BC variable is a global variable in morph.c which is not constant, 
rendering any 
functions using this variable not thread-safe.

Original issue reported on code.google.com by [email protected] on 23 Jun 2009 at 10:57

gplot.c doesn't work under Windows

What steps will reproduce the problem?
1. Run histotest

What is the expected output? What do you see instead?
I expect to see a histogram displayed.
Instead nothing is displayed.

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
The gnuplot for windows executable is called wgnuplot.exe. Also, the
standard gp426win32.zip distribution does not have an X11 terminal. I
presume that the gp426win32x11.zip distribution does but I didn't try that
because it assumes you have a X11 server running.

gplot.c needs the following changes:

gplotMakeOutput() changes:

#ifndef COMPILER_MSVC
    if (gplot->outformat != GPLOT_X11)
        snprintf(buf, L_BUF_SIZE, "gnuplot %s &", gplot->cmdname);
    else
        snprintf(buf, L_BUF_SIZE,
                 "gnuplot -persist -geometry +10+10 %s &", gplot->cmdname);
#else
    if (gplot->outformat != GPLOT_X11)
        snprintf(buf, L_BUF_SIZE, "wgnuplot %s", gplot->cmdname);
    else
        snprintf(buf, L_BUF_SIZE,
            "wgnuplot -persist %s", gplot->cmdname);
#endif

gplotGenCommandFile() changes:

    else  /* gplot->outformat == GPLOT_X11 */
#ifndef COMPILER_MSVC
        snprintf(buf, L_BUF_SIZE, "set terminal x11");
#else
        snprintf(buf, L_BUF_SIZE, "set terminal windows");
#endif

Original issue reported on code.google.com by [email protected] on 6 Dec 2009 at 5:46

Download URL on Project Home is outdated

What steps will reproduce the problem?
1. Go to Project Home (http://code.google.com/p/leptonica/)
2. Click on the Download link
(http://www.google.com/url?sa=D&q=http%3A%2F%2Fwww.leptonica.org%2Fsource%2Flept
onlib-1.37.tar.gz)
3. Get file not found

What is the expected output? What do you see instead?
Download of the latest version 1.38

What version of the product are you using? On what operating system?
n/a

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 23 Aug 2006 at 6:03

Warnings (and errors) on Visual Studio 2008 builds of 1.63

What steps will reproduce the problem?
1. Perform Debug build of leptonlib using Visual Studio 2008.

What is the expected output? What do you see instead?
I expected to build leptonlib.lib. Instead the build fails with multiple
errors.

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.

First of all the solution provided for Visual Studio 2008 couldn't find ANY
of the source files. I "fixed" the problem by directly editing
leptonlib.vcproj:

 Replace all occurences of:  RelativePath=".\
 With: RelativePath=".\src\

Alternatively, you can move the .sln and .vcproj file INTO the src
directory (where it used to be).

---

Since pstdint.h isn't in the src directory, remove it from the Header Files
folder. (As mentioned in README.html 9.d you have to get pstdint.h
elsewhere, I just rename it to stdint.h and copy it into the C:\Program
Files\Microsoft Visual Studio 9.0\VC\include directory.)

---

I added the following compiler flags to turn off more warning messages
(including those previously mentioned in Issue 9):

 /wd4244 /wd4305 /wd4018 /wd4267 /wd4996

This leaves this Warning (which I'm pretty sure is an error):

 warning C4553: '==' : operator has no effect; did you intend '='
leptonlib-1.63\src\grayquant.c  433

This line should be changed from:

        d == 8;

To:

        d = 8;

And these other warning (some of which might be bugs):

 Command line warning D9035 : option 'Wp64' has been deprecated and will be
removed in a future release cl

 warning C4101: 'bigbuf' : unreferenced local variable
leptonlib-1.63\src\psio2.c  291

 warning C4700: uninitialized local variable 'd' used
leptonlib-1.63\src\pixcomp.c    192

 warning C4715: 'pixcompGetDimensions' : not all control paths return
a value     leptonlib-1.63\src\pixcomp.c    332

 warning C4700: uninitialized local variable 'pixt' used 
leptonlib-1.63\src\scale.c  1512    leptonlib

 warning C4028: formal parameter 2 different from declaration
leptonlib-1.63\src\pix1.c   249

And the following Error:

 error C2668: 'sqrt' : ambiguous call to overloaded function
leptonlib-1.63\src\binarize.c   692

Which can be fixed by removing the /TP option (Change "leptonlib Properties
| Advanced | Compile as" from C++ Code to default).

----

To get rid of the various image library include errors add these to
"leptonlib Properties | C/C++ | General | Additional Include Directories"
(assuming you download the appropriate libraries and build them at the same
"level" as leptonlib):

..\zlib;..\libtiff\libtiff;..\libpng;..\libjpeg\include

----

In summary my C/C++ command line for a Debug build looks like:

 /Od /I "..\zlib" /I "..\libtiff\libtiff" /I "..\libpng" /I
"..\libjpeg\include" /D "WIN32" /D "_DEBUG" /D "_LIB" /D "L_LITTLE_ENDIAN"
/D "USE_PSTDINT" /D "snprintf=_snprintf" /D "COMPILER_MSVC=1" /D "XMD_H"
/Gm /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /nologo /c /Wp64
/ZI /showIncludes /errorReport:prompt

With these additional options to turn off warnings:

 /wd4244 /wd4305 /wd4018 /wd4267 /wd4996

For Debug builds I also change "Librarian | General | Output File" from: 

 $(OutDir)\$(ProjectName).lib

to:

 $(OutDir)\$(ProjectName)d.lib

thereby getting leptonlibd.lib as the name of library (so I can distinguish
between Debug and Release builds).

My C/C++ command line for a Release build looks like:

 /I "..\zlib" /I "..\libtiff\libtiff" /I "..\libpng" /I
"..\libjpeg\include" /D "WIN32" /D "NDEBUG" /D "_LIB" /D "L_LITTLE_ENDIAN"
/D "USE_PSTDINT" /D "snprintf=_snprintf" /D "COMPILER_MSVC=1" /D "XMD_H"
/FD /EHsc /MD /Fo"Release\\" /Fd"Release\vc90.pdb" /W3 /nologo /c /Wp64 /Zi
/errorReport:prompt

With these additional options to turn off warnings:

 /wd4244 /wd4305 /wd4018 /wd4267 /wd4996

Original issue reported on code.google.com by [email protected] on 19 Nov 2009 at 3:09

.so version number is 0.0.0

The version number of the .so library was not set in release 1.67, so it 
defaulted to 0.0.0.  This causes link problems with any application that 
requires a version number larger than 0.0.0.

Note also that the .so library version number is not supposed to correspond to 
the release number.  Guidelines for setting the .so version can be found here:

    http://sourceware.org/autobook/autobook/autobook_91.html#SEC91

The plan is for 1.68 to have version number 2.0.0.  It will then build
properly with any application that requires a version number less than or equal 
to 2.0.0.

The fix is to add this line to Makefile.am in the parent directory:

    liblept_la_LDFLAGS = -version-info 2:0:0


Original issue reported on code.google.com by [email protected] on 1 Dec 2010 at 10:06

fpix_reg.c doesn't compile under Windows

What steps will reproduce the problem?
1. Try to build fpix_reg using Visual Studio 2008

What is the expected output? What do you see instead?
I expect to build fpix_reg.
Instead I get:
Error   1   fatal error C1083: Cannot open include file: 'unistd.h': No such
file or directory   fpix_reg.c  26

What version of the product are you using? On what operating system?
leptonlib-1.63a.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
Commenting out the #include I see that it was providing sleep().

Windows has:

  VOID WINAPI Sleep( __in DWORD dwMilliseconds)

Header: Declared in Winbase.h; include Windows.h.

(I tried including Winbase.h, but that just gives lots of undefined errors,
so bite bullet and include Windows.h)

See attached fpix_reg.c for new version.

Original issue reported on code.google.com by [email protected] on 10 Dec 2009 at 9:21

Attachments:

No error message on Windows

Hi,
please find attached example file. When I compile and run it on Linux I got 
error message (example ;-) on console:

 Opening page 6...Warning in pixReadStreamTiff: tiff page 6 not found
Error in pixReadTiff: pix not read

But when I compile it and run it on Windows console, there is no error message:

 Opening page 6...

I would appreciate to have the same behavior on Linux and Windows.

Original issue reported on code.google.com by [email protected] on 1 Nov 2010 at 8:30

Attachments:

MingW32 compilation error: conflicting types for 'l_jpegSetNoChromaSampling'

Trying to build on a mingw32 environment, I get this error:

jpegiostub.c:1:0: warning: -fPIC ignored for target (all code is position 
independent)
jpegiostub.c:57:9: error: conflicting types for 'l_jpegSetNoChromaSampling'
leptprotos.h:660:22: note: previous declaration of 'l_jpegSetNoChromaSampling' 
was here
make[3]: *** [jpegiostub.o] Error 1
make[3]: Leaving directory `/c/Documents and Settings/kpoman/Mis 
documentos/Downloads/leptonlib-1.65/leptonlib-1.65/src'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/c/Documents and Settings/kpoman/Mis 
documentos/Downloads/leptonlib-1.65/leptonlib-1.65/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/c/Documents and Settings/kpoman/Mis 
documentos/Downloads/leptonlib-1.65/leptonlib-1.65'
make: *** [all] Error 2


$ gcc -v
Using built-in specs.
COLLECT_GCC=c:\MinGW\bin\gcc.exe
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.5.0/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.5.0/configure 
--enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions 
--with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry 
--enable-libstdcxx-debug --enable-version-specific-r
untime-libs --disable-werror --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.5.0 (GCC)



Here is the configure output:

$ ./configure
checking build system type... i686-pc-mingw32
checking host system type... i686-pc-mingw32
./configure: line 1964: test: too many arguments
./configure: line 1967: test: too many arguments
checking for cl.exe... no
checking for g++... g++
checking for C++ compiler default output file name... a.exe
checking whether the C++ compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... .exe
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for a BSD-compatible install... /bin/install -c
checking whether build environment is sane... yes
/bin/sh: /c/Documents: No such file or directory
configure: WARNING: `missing' script is too old or missing
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking dependency style of g++... gcc3
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... unsupported
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... no
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
checking for ranlib... ranlib
checking for deflate in -lz... yes
checking for png_read_png in -lpng... no
checking for jpeg_read_scanlines in -ljpeg... no
checking for DGifOpenFileHandle in -lgif... no
checking how to run the C++ preprocessor... g++ -E
checking for ANSI C header files... (cached) no
checking whether time.h and sys/time.h may both be included... yes
checking for sys/wait.h that is POSIX.1 compatible... no
checking sys/ipc.h usability... no
checking sys/ipc.h presence... no
checking for sys/ipc.h... no
checking sys/shm.h usability... no
checking sys/shm.h presence... no
checking for sys/shm.h... no
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking for stdbool.h that conforms to C99... yes
checking for _Bool... no
checking whether #! works in shell scripts... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... unknown
checking for _LARGE_FILES value needed for large files... unknown
checking for wchar_t... yes
checking for long long int... yes
checking for mbstate_t... yes
checking for size_t... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for getpagesize... yes
checking for working mmap... no
checking for pid_t... yes
checking vfork.h usability... no
checking vfork.h presence... no
checking for vfork.h... no
checking for fork... no
checking for vfork... no
checking for strerror... yes
checking for vsnprintf... yes
checking for gethostname... no
checking for strchr... yes
checking for memcpy... yes
checking for acos... yes
checking for asin... yes
checking for fmemopen... no
checking for Leffler libtiff library... checking linking with -ltiff... no
configure: WARNING: TIFF support is disabled
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating config_auto.h
config.status: executing depfiles commands

Configuration is done.
You can now build leptonlib by running:

% make


Original issue reported on code.google.com by [email protected] on 25 Jul 2010 at 5:46

MORPH_BC not thread-safe

The MORPH_BC variable is a global variable in morph.c which is not constant, 
rendering any 
functions using this variable not thread-safe.

Original issue reported on code.google.com by [email protected] on 23 Jun 2009 at 10:57

C++ wrapper

Is there any (lightweight) c++-wrapper for leptonica ("leptonicamm") available, 
or will there be one (maybe as contribution)?

Original issue reported on code.google.com by [email protected] on 8 Sep 2010 at 2:58

Endianness bug in expandBinaryPower2Low

What steps will reproduce the problem?
1. Generate a binary image 51 pixels wide by any amount of pixels high.
2. Perform expandBinaryPower2 with factor==2 on image.
3. Look at right side of resulting image.

What is the expected output? What do you see instead?

The right side of the resulting image is not doubled vertically.

What version of the product are you using? On what operating system?

1.61, on MacOSX 10.5.7

Please provide any additional information below.

Attached are my test files -- ScaleGrayToBinaryFast.png is in the input, and 
ExpandBinaryPower2.png is the resulting output.

I believe the problem is caused by a faulty assumption in the machine's 
endianness in 
expandBinaryPower2Low. Let us assume an 8-pixel wide image. Then the WPL of the 
image is 1.

After doubling, the image is 16 pixels wide, also with a WPL of 1. Suppose that 
we now perform 
GET_DATA_TWO_BYTES(data, 0) on this image, on a little-endian machine. This 
macro will 
correctly look at the last two bytes in the 32-bit word.

However, binExpandPower2Low performs the following operation after horizontally 
doubling a 
line:

            memcpy((char *)(lined + wpld), (char *)lined, 2 * sbytes);

The first (2*sbytes)/4 32-bit words will always be copied correctly, but the 
last (2*sbytes)%4 
bytes will not, because they are assumed to be ordered big-endian, when the 
machine is little-
endian.

There is no corresponding problem with factor=={4, 8, 16} because there the 
memcpy length is 
4*(some integer), which is always aligned on a 32-bit word boundary.

Original issue reported on code.google.com by [email protected] on 23 Jun 2009 at 10:11

Attachments:

Change pixWrite() to automatically add file extension if missing in filename

What steps will reproduce the problem?
1. Run adaptnorm_reg.c under Windows

What is the expected output? What do you see instead?
Output is as expected but not as convenient as it could be under Windows.

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
Under Windows, it's very difficult to view "junk" images created by prog
programs when they don't have an extension. You have to look thru the code
to determine the appropriate extension type, and then manually rename the
file before you can open it (Or you could unilaterally open all
extensionless files with IrfanView I suppose).

I propose changing pixWrite() in writefile.c so that it automatically adds
an extension to the filename by doing the following:

l_int32
pixWrite(const char  *filename, 
     PIX         *pix, 
     l_int32      format)
{
FILE  *fp;
char  *pextension;
char  *filebuf;

    PROCNAME("pixWrite");

    if (!pix)
        return ERROR_INT("pix not defined", procName, 1);
    if (!filename)
        return ERROR_INT("filename not defined", procName, 1);

    splitPathAtExtension(filename, NULL, &pextension);
    if (strlen(pextension) == 0) {
        if ((filebuf = (char *)CALLOC(strlen(filename) + 10, sizeof(char)))
             == NULL) {
            if (pextension)
                FREE (pextension);
            return ERROR_INT("filebuf not made", procName, 1);
        }

        if (format == IFF_DEFAULT)
            format = pixGetInputFormat(pix);
        if (format == IFF_UNKNOWN) {
            if (pixGetDepth(pix) == 1)
                format = IFF_TIFF_G4;
            else
                format = IFF_PNG;
        }

        strcpy(filebuf, filename);
        strcat(filebuf, ".");
        strcat(filebuf, ImageFileFormatExtensions[format]);
    } else {
        filebuf = (char *) filename;
    }
    if (pextension)
        FREE (pextension);

    fp = fopen(filebuf, "wb+");
    if (filebuf != filename)
        FREE(filebuf);
    if (fp == NULL)
        return ERROR_INT("stream not opened", procName, 1);

    if (pixWriteStream(fp, pix, format)) {
        fclose(fp);
        return ERROR_INT("pix not written to stream", procName, 1);
    }

    fclose(fp);
    return 0;
}

Original issue reported on code.google.com by [email protected] on 3 Dec 2009 at 6:05

adaptmaptest.c is hard to use since suggested example file wet-day.jpg is missing

What steps will reproduce the problem?
1. Run adaptmaptest.exe

What is the expected output? What do you see instead?
Certain #defines seem customized for wet-day.jpg, so I'm not sure what I'm
supposed to see.
In addition, adaptmaptest.exe (and many other prog programs) assumes the
presence of gthumb which won't work under Windows. I'll file a separate
issue for this since fix is somewhat complicated.

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 4 Dec 2009 at 10:18

Can't build shared library

What is the expected output? What do you see instead?
I need a dynamically linked library (.so) for Ocropus and I am only able to
get a statically linked library (.a).

What version of the product are you using? On what operating system?
leptonlib-1.62.tar.gz on Mandriva 2009.1 x64

Please provide any additional information below.
According to the README
make SHARED=yes shared
should build the shared library. Instead I get
make: *** No rule to make target `shared'.  Stop.



Original issue reported on code.google.com by [email protected] on 20 Aug 2009 at 8:37

stringFindSubstr() in utils.c doesn't properly handle NULL ploc argument

What steps will reproduce the problem?
1. pass NULL ploc argument to stringFindSubstr().

What is the expected output? What do you see instead?
I expect the ploc argument to be optional.
Instead program crashes.

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
utils.c line 948 should be changed from:

    if (*ploc)

to:

    if (ploc)

Original issue reported on code.google.com by [email protected] on 1 Dec 2009 at 11:45

problem using leptonica on mac OSX 10.4 for tesseract

What steps will reproduce the problem?
1. .Installed leptonlib-1.67
2.Compiled tesseract 3.00 and installed
3. Ran teserract

What is the expected output? What do you see instead?
Expected tesseract to produce the OCR result.  Got the following errors
Tesseract Open Source OCR Engine with Leptonica
Error in findTiffCompression: function not present
Error in tiffGetCount: function not present
Error reading file ./namefile

What version of the product are you using? On what operating system?
leptonica 1.67 on mac OSX 10.4; tesseract 3.00

Please provide any additional information below.

you can find additional information here:

http://code.google.com/p/tesseract-ocr/issues/detail?id=340#c0

Original issue reported on code.google.com by [email protected] on 4 Jan 2011 at 12:39

GIF file support is broken

What steps will reproduce the problem?
1. Try to run gifio_reg.

What is the expected output? What do you see instead?
I expect to see various gif files created.
Instead gifio_reg fails to compile under Windows, and when compilation
errors are fixed, leptonica aborts with "file not open" error.

What version of the product are you using? On what operating system?
leptonlib-1.64
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.

First of all, gifio.c isn't part of the current leptonlib.vcproj file, only
gifiostub.c is (I'll fix this).

Next, gifio.c has to be changed to:

#ifndef COMPILER_MSVC
#include <unistd.h>
#else
#include <io.h>
#endif

and near line 76:

#ifndef COMPILER_MSVC
    lseek(fd, 0, SEEK_SET);
#else
    _lseek(fd, 0, SEEK_SET);
#endif

----

Since EGifCloseFile() in egif_lib.c (called by
pixWriteStream/pixWriteStreamGif) at line 760 does:

    if (File && fclose(File) != 0) {
        _GifError = E_GIF_ERR_CLOSE_FAILED;
        return GIF_ERROR;
    }

writefile.c line 241, needs to be changed to:

    if (format != IFF_GIF)
        fclose(fp);

---

Similar issue with DGifCloseFile() in dgif_lib.c at line 610 (called
from pixReadStreamGif):

    if (File && (fclose(File) != 0)) {
        _GifError = D_GIF_ERR_CLOSE_FAILED;
        return GIF_ERROR;
    }

so pixRead() in readfile.c, needs to be changed to:

PIX *
pixRead(const char  *filename)
{
FILE  *fp;
PIX   *pix;
l_int32  format;

    PROCNAME("pixRead");

    if (!filename)
        return (PIX *)ERROR_PTR("filename not defined", procName, NULL);

    if ((fp = fopenReadStream(filename)) == NULL)
        return (PIX *)ERROR_PTR("image file not found", procName, NULL);
    pix = pixReadStream(fp, 0);
    format = getImpliedFileFormat(filename);
    if (format != IFF_GIF)
        fclose(fp);

    if (!pix)
        return (PIX *)ERROR_PTR("image not returned", procName, NULL);
    return pix;
}

Original issue reported on code.google.com by [email protected] on 8 Jan 2010 at 4:05

pixDisplay() doesn't work under Windows

What steps will reproduce the problem?
1. Run any program that uses pixDisplay() function.

What is the expected output? What do you see instead?
I expect to be able to view images for debugging.
Instead nothing is displayed.

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
Attached is a changed writefile.c that fixes the problem by assuming that
the user has installed the free imageviewer application IrfanView
(http://www.irfanview.com/) and added it's location to the system PATH. The
README I'm in the process of writing assumes these changes to writefile.c.

Original issue reported on code.google.com by [email protected] on 24 Nov 2009 at 8:23

Attachments:

Missing pixAdaptThresholdToBinary() function

What steps will reproduce the problem?
1. adaptthresh.c uses missing function pixAdaptThresholdToBinary();

What version of the product are you using? On what operating system?

1.62

Original issue reported on code.google.com by [email protected] on 25 Sep 2009 at 3:39

Warnings (and errors) on Visual Studio Compile of 1.62

What steps will reproduce the problem?
1. compiling without NO_CONSOLE_IO defined.
2. compiling the release configuration.

What is the expected output? What do you see instead?

Release configuration fails. Warnings worth fixing in both. Can mask the 
warnings that are cluttering the build.

There are a number of warnings as follow:

..\src\conncomp.c(1042) : warning C4098: 'pushFillsegBB'
 : 'void' function returning a value
..\src\conncomp.c(1051) : warning C4098: 'pushFillsegBB'
 : 'void' function returning a value
..\src\conncomp.c(1058) : warning C4098: 'pushFillsegBB'
 : 'void' function returning a value
..\src\conncomp.c(1101) : warning C4098: 'pushFillseg'
 : 'void' function returning a value
..\src\conncomp.c(1105) : warning C4098: 'pushFillseg'
 : 'void' function returning a value
..\src\conncomp.c(1112) : warning C4098: 'pushFillseg'
 : 'void' function returning a value
..\src\conncomp.c(1153) : warning C4098: 'popFillseg'
 : 'void' function returning a value
..\src\conncomp.c(1155) : warning C4098: 'popFillseg'
 : 'void' function returning a value
..\src\pix1.c(218) : warning C4098: 'pix_free'
 : 'void' function returning a value

..\src\pix1.c(247) : warning C4028:
 formal parameter 2 different from declaration

..\src\pixalloc.c(350) : warning C4098:
 'pmsCustomDealloc' : 'void' function returning a value
..\src\pixalloc.c(353) : warning C4098:
 'pmsCustomDealloc' : 'void' function returning a value

..\src\pixalloc.c(343) : warning C4101:
 'fp' : unreferenced local variable

..\src\watershed.c(555) : warning C4098: 'wshedSaveBasin' : 'void' 
function returning a value
..\src\watershed.c(814) : warning C4098: 'pushNewPixel' : 'void' function 
returning a value
..\src\watershed.c(857) : warning C4098: 'popNewPixel' : 'void' function 
returning a value
..\src\watershed.c(895) : warning C4098: 'pushWSPixel' : 'void' function 
returning a value
..\src\watershed.c(897) : warning C4098: 'pushWSPixel' : 'void' function 
returning a value
..\src\watershed.c(942) : warning C4098: 'popWSPixel' : 'void' function 
returning a value
..\src\watershed.c(944) : warning C4098: 'popWSPixel' : 'void' function 
returning a value
..\src\watershed.c(946) : warning C4098: 'popWSPixel' : 'void' function 
returning a value

While there are also a large number of casting to smaller size warnings, 
these seem as "works as intended" and it might be easier to simply remove 
the warnings than change the code.

Add the following to command line options: /wd4244 /wd4305 /wd4018

Finally, it looks like the release configuration of the Visual Studio 
solution does not define the correct pre-processor definitions to compile 
correctly.

What version of the product are you using? On what operating system?

Version 1.62 running under XP and building using Visual Studio solution 
file. After removing the huge number of warnings by the three options 
above, the remaining warnings looked like they were worth fixing.

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 3 Oct 2009 at 6:15

gif Problem (used version is giflib 4.1.6).

What steps will reproduce the problem?
1. it can read gif files but when exit the program halts itself.
2. just occurs this fault with gif files.

What is the expected output? What do you see instead?
gif files in other vision libraries like openCV can be read/write
correctly/ without any fault. giflib4.1.6 is used in openCV and there is no
problem.


What version of the product are you using? On what operating system?
Windows Vista Home Premium.

Please provide any additional information below.
Leptonica v1.65

Original issue reported on code.google.com by [email protected] on 9 May 2010 at 2:48

Problems with building Leptonica with only TIFF & ZLIB support turned on

What steps will reproduce the problem?
1. Build leptonlib with only TIFF and ZLIB support turned on in environ.h.

What is the expected output? What do you see instead?
Lots of warnings about "unreferenced local variables" in pixaReadStream() and 
pixaWriteStream().
Lots of error messages when running ioformats_reg.

What version of the product are you using? On what operating system?
leptonlib-1.67
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
A message I just read on the tesseract-dev list implies that they only need 
TIFF support in Leptonica so I decided I'd try to build it with only TIFF & 
ZLIB support turned on.

This gave a bunch of warning messages for the unreferenced local variables in 
pixaReadStream() and pixaWriteStream(). In looking at the code I see that those 
two functions are only useful if PNG support is enabled. Is that limitation 
documented anywhere?

Also I get the lots of error messages when running ioformats_reg.

Original issue reported on code.google.com by [email protected] on 13 Nov 2010 at 4:10

getLeptonlibVersion() is incorrect when using the VS2008 static libraries

What steps will reproduce the problem?
1. call getLeptonlibVersion() when linked to either leptonlib-static-mtdll.lib 
or leptonlib-static-mtdll-debug.lib.

What is the expected output? What do you see instead?
I expect to see:
leptonlib-1.67 (Nov 13 2010, 00:28:54) [MSC v.1500 LIB Debug 32 bit]
Instead I see:
leptonlib-1.67 (Nov 13 2010, 00:28:54) [MSC v.1500 DLL Debug 32 bit]

What version of the product are you using? On what operating system?
leptonlib-1.67
Microsoft Visual Studio 2008
Windows XP Pro SP3.

Please provide any additional information below.
The problem is that getLeptonlibVersion() in utils.c does the following to 
determine if the DLL version is being built:

  #ifdef _DLL
    char dllStr[] = "DLL";
  #else
    char dllStr[] = "LIB";
  #endif

Unfortunately, as "Predefined Macros" 
http://msdn.microsoft.com/en-us/library/b0084kay%28v=VS.90%29.aspx clearly 
states:

   _DLL  Defined when /MD or /MDd (Multithreaded DLL) is specified.

Since we always build with /MD or /MDd, "_DLL" is also always defined.

When I first made the DLL build configurations, I copied the LIB configuration 
and simply changed the "_LIB" define to "_DLL". What I should have done is 
define "_USRDLL" which is what the New Projects Wizard does.

So getLeptonlibVersion() should be changed to:

  #ifdef _USRDLL
    char dllStr[] = "DLL";
  #else
    char dllStr[] = "LIB";
  #endif

and I will change the VS2008 project files to correctly define "_USRDLL" when 
building DLL configurations.

Original issue reported on code.google.com by [email protected] on 14 Nov 2010 at 7:31

genPathname() in utils.c doesn't correctly handle dir with wrong directory sepchar under Windows

What steps will reproduce the problem?
1. Try running psioseg_reg using Windows. It calls
convertSegmentedPagesToPS("/tmp/junkimagedir", "/tmp/junkmaskdir", 2.0,
0.15, 190, 0, 0, "junkfile.ps") which will eventually fail.

What is the expected output? What do you see instead?
I expect to be able to build concatenated paths.
Instead paths with / and \ are created.

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
I'm not sure the following is the best solution but it works. Perhaps more
thought needs to be done on the whole annoying Windows pathsep issue rather
than piecemeal fixing issues after the fact?

genPathname() should be changed to:

genPathname(const char  *dir,
            const char  *fname)
{
char    *charbuf;
l_int32  dirlen, namelen;
char    *tmpDirname;

    PROCNAME("genPathname");

    if (!dir)
        return (char *)ERROR_PTR("dir not defined", procName, NULL);
    if (!fname)
        return (char *)ERROR_PTR("fname not defined", procName, NULL);

    dirlen = strlen(dir);
    namelen = strlen(fname);
    if ((charbuf = (char *)CALLOC(dirlen + namelen + 10, sizeof(char)))
         == NULL)
        return (char *)ERROR_PTR("charbuf not made", procName, NULL);

#if COMPILER_MSVC
    if (stringFindSubstr(dir, "/", NULL) > 0) {
        tmpDirname = stringReplaceEachSubstr(dir, "/", "\\", NULL);
        strcpy(charbuf, tmpDirname);
        FREE(tmpDirname);
    } else {
        strcpy(charbuf, dir);
    }
#else
    strcpy(charbuf, dir);
#endif

    if (charbuf[dirlen - 1] != sepchar) {
        charbuf[dirlen] = sepchar;
        charbuf[dirlen+1] = '\0';
    }
    strcat(charbuf, fname);

    return charbuf;
}

Original issue reported on code.google.com by [email protected] on 1 Dec 2009 at 8:13

pixWriteMem fails on win32

What steps will reproduce the problem?

1. use pixReadMem or pixWriteMem on win32
2. fails with "Error in pixWriteMemPng: png write to memory not implemented on 
this platform"

Is there a workaround instead of having to use the filesystem to read/write the 
files ?

Thank you,

Original issue reported on code.google.com by [email protected] on 23 Jul 2010 at 4:33

/prog programs can't link with Windows DLL version of leptonica.

What steps will reproduce the problem?
1. Try to build a DLL version of leptonica and then have ioformats_reg link
to the DLL.

What is the expected output? What do you see instead?
I expect to be able to link ioformats_reg with the DLL version of leptonica.
Instead I see:
error LNK2001: unresolved external symbol _ImageFileFormatExtensions
ioformats_reg.obj   ioformats_reg

What version of the product are you using? On what operating system?
leptonlib-1.64
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
This turns out to be an insidious problem that's probably strewn throughout
leptonica.

To fix this SPECIFIC problem I had to change writefile.c from:

  l_int32  NumImageFileFormatExtensions = 16;  /* array size */
  const char *ImageFileFormatExtensions[] = {"unknown",

to:

  LEPT_DLL l_int32  NumImageFileFormatExtensions = 16;  /* array size */
  LEPT_DLL const char *ImageFileFormatExtensions[] = {"unknown",

in order to tell the MSVC compiler to export those two data items to the DLL.

Additionally, ioformats_reg.c had to be changed from:

  extern const char *ImageFileFormatExtensions[];

to:

  LEPT_DLL extern const char *ImageFileFormatExtensions[];

I also had to change the project settings for ioformats_reg so that
LEPTONLIB_IMPORTS is defined, then the following is done:

  #define LEPT_DLL __declspec(dllimport)

But that seems a bit confusing to me since the same LEPT_DLL is used for
both specifying DLL exports and imports (depending on whether you are
building leptonica or a program that links with leptonica).

In any case, any data that is supposed to be visible in leptonlib will have
to be prefaced with LEPT_DLL. Additionally, any extern data in the prog
programs will also have to be prefaced with LEPT_DLL.

Original issue reported on code.google.com by [email protected] on 16 Feb 2010 at 7:29

Wrong JPEG library version

What steps will reproduce the problem?
1. compile leptonlib-1.65 according README.html
2. compile prog
3. run ./threshnorm_reg: 
Wrong JPEG library version: library is 80, caller expects 62
Error in pixReadStreamJpeg: internal jpeg error
Error in pixReadStream: jpeg: no pix returned
Error in pixGetInputFormat: pix not defined
Error in pixRead: image not returned
Error in ./threshnorm_reg: pixs not made

What version of the product are you using? On what operating system?
Mandrivalinux 2010, libjpeg8 (most of the sw is build against libjpeg8 or
libjpeg7 so I can not downgrade to libjpeg6)


Original issue reported on code.google.com by [email protected] on 16 Apr 2010 at 2:19

File& patch included: spec file to build rpm package

I wanted to create rpm package from the latest leptonica library for rpm base 
linux distribution. I changed older spec file from PLD Linux Distribution. 
Result is in attachment.

Also I find out that some files (Makefile.am, configure.am ...) need to be 
changed to compile static and shared version. Patch with changes is attached. 

Final srpm is on 
http://www.sk-spell.sk.cx/file_download/88/leptonlib-1.66-0.src.rpm 

Original issue reported on code.google.com by [email protected] on 23 Aug 2010 at 11:32

Attachments:

Better memory leak detection on Windows

What steps will reproduce the problem?
1. Create any leptonlib based program.

What is the expected output? What do you see instead?
It would be nice if Visual Studio 2008/2010 displayed memory leak warnings.

What version of the product are you using? On what operating system?
leptonlib-1.65
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
I have not yet done any testing for memory leaks under Windows XP.

Looks like we might want to add the vld.h file from Visual Leak Detector
(http://vld.codeplex.com/documentation) to one of the main leptonlib .h
files. Visual Leak Detector would then have to be added as a prerequisite
for building leptonlib on Windows and my VS2008 Notes would have to be updated.

Once this is done memory leaks will be automatically reported whenever an
application is built with LIB Debug or DLL Debug leptonlib and then run
under the VC++ debugger.

I suggest I investigate this further for the 1.66 leptonlib release.

(Apparently running programs under the VC++ debugger already has minimal
memory leak detection and I can't say I've ever noticed it complaining
about such. But then I was mainly just making sure the programs built and
ran without crashing.)

Original issue reported on code.google.com by [email protected] on 11 May 2010 at 6:11

psioseg_reg.c doesn't work under Windows

What steps will reproduce the problem?
1. Try running psioseg_reg using Windows.

What is the expected output? What do you see instead?
Program fails because it can't write to non-existent directory.

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
mkdir doesn't like paths with / in them under Windows.
Later call to ps2pdf also fails. You have to add both Ghostscript lib and
bin directories to system path (but that's not really psioseg_reg's fault).

Change

    system("mkdir /tmp/junkimagedir");
    system("mkdir /tmp/junkmaskdir");

to:

#ifdef WIN32    
    system("mkdir \\tmp\\junkimagedir");
    system("mkdir \\tmp\\junkmaskdir");
#else
    system("mkdir /tmp/junkimagedir");
    system("mkdir /tmp/junkmaskdir");
#endif

Original issue reported on code.google.com by [email protected] on 1 Dec 2009 at 8:44

A few 'do what I mean not what I say' bugs

What steps will reproduce the problem?

I am studying the code base so I can start using it. I ran a static 
analyisis program on the code. It pointed out what appear to be some typo 
bugs.

There is more that I hope to filter through later but these looked fairly 
straight forward.

-----------

arithlow.c, line 284

'lined' is unsigned so the result of the subtraction will be unsigned.
Unsigned can never be less than 0.

 if (*(lined + j) - threshval >= 0)

-----------

arithlow.c, line 304

'lined' is unsigned so the result of the subtraction will be unsigned.
Unsigned can never be less than 0.

 if (*(lined + j) - threshval <= 0)

-----------

blend.c, line 1508

need test of 'box' for NULL. pixs already tested right above.

is        --> if (!pixs) 
should be --> if (!box) with changed error message.

-----------

colorseg.c, line 1264

need equality test to variable 'type'

is        --> if (L_HS_HISTO || L_HV_HISTO) { 
should be --> if (type == L_HS_HISTO || type == L_HV_HISTO) {

-----------

pix4.c, line 2415

 if (boxs) {

'boxs' can not be NULL (see NULL test above this line). Could simplify 
code by removing if / else statement.

----------

pixabasic.c, line 1068

need equality test to variable 'type'

is        --> if (L_CHOOSE_CONSECUTIVE)
should be --> if (type == L_CHOOSE_CONSECUTIVE)

----------
ptra.c, line 369

need equality test to variable 'shiftflag'

is        --> else if (L_AUTO_DOWNSHIFT) {
should be --> else if (shiftflag == L_AUTO_DOWNSHIFT) {

----------
ptra.c, line 1056

need equality test to variable 'sortorder'

is        --> if (L_SORT_INCREASING) {
should be --> if (sortorder == L_SORT_INCREASING) {

----------
scale.c, line 2660

Use of assigment instead of equality test

is        --> if (type = L_CHOOSE_MIN)
should be --> if (type == L_CHOOSE_MIN)

---------
scale.c, line 2662

Use of assigment instead of equality test

is        --> else if (type = L_CHOOSE_MAX)
should be --> else if (type == L_CHOOSE_MAX)


What is the expected output? What do you see instead?

I did not run the code to verify these are defects.

What version of the product are you using? On what operating system?

Line numbers came from version 1.62

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 7 Oct 2009 at 2:54

rotateorthtest2 doesn't link

What steps will reproduce the problem?
1. Try compile and link rotateorthtest2.

What is the expected output? What do you see instead?
I expect to link rotateorthtest2.
rotateorthtest2 fails to link because of an "unresolved external symbol
returnErrorVoid referenced in function rotateOrthTest" error.

What version of the product are you using? On what operating system?
leptonlib-1.64
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
It looks like returnErrorVoid() should be defined in utils.c but isn't?

Original issue reported on code.google.com by [email protected] on 15 Jan 2010 at 7:07

Many fopen() calls with mode argument "r"/"w" should probably be "rb"/"wb" for Windows builds

What steps will reproduce the problem?
1. Create a Debug build of leptonica 1.63
2. Create a Debug build of ioformats_reg.exe

What is the expected output? What do you see instead?
I expect ioformats_reg to run without any failures reported.
Instead multiples failures occur.

What version of the product are you using? On what operating system?
leptonlib-1.63.
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
First of all you have to make sure a \tmp directory exists on the drive
from which you are running ioformats_reg. Various parts of leptonica assume
they can write to /tmp and will fail mysteriously if that directory is not
present. (I added a note to that effect in the README I am in the process
of writing).

I was trying out version 7 of libjpeg and happened to stumble across this
error:

jpegio.c

line 227 add:

    cinfo.scale_num = 1;

otherwise cinfo.scale_num seems to default to 8 with the latest libjpeg
version 7.

Finally I suggest you check the mode argument of all calls to fopen(). Most
of them should specify binary mode explicitly by appending a "b".

Here's partial list of the changes that need to be done. This is certainly
incomplete since I was mainly looking for fopen calls related to image
files (I also haven't looked at the prog directory yet other than
ioformats_reg.c):

ioformats_reg.c

line 375

    fp = fopen(filename, "r");

should be changed to:

    fp = fopen(filename, "rb");

-----------

tiffio.c

line 894

    if ((fp = fopen(filename, "r")) == NULL)

should be changed to:

    if ((fp = fopen(filename, "rb")) == NULL)

line 993

        if ((fp = fopen(fname, "r")) == NULL)

should be changed to:

        if ((fp = fopen(fname, "rb")) == NULL)

line 1506:

    if ((fpin = fopen(filein, "r")) == NULL)

should be changed to:

    if ((fpin = fopen(filein, "rb")) == NULL)

----

ccbord.c

should line 2287

    if ((fp = fopen(filename, "r")) == NULL)

really be:

    if ((fp = fopen(filename, "rb")) == NULL)

given that line 2140 is:

    if ((fp = fopen(filename, "wb+")) == NULL)

-----

jbclass.c

should line 1837

    if ((fp = fopen(buf, "w")) == NULL)

really be

    if ((fp = fopen(buf, "wb")) == NULL)

?

----

jpegio.c

line 635

    if ((fp = fopen(filein, "r")) == NULL)

should be changed to:

    if ((fpin = fopen(filein, "rb")) == NULL)

----

psio1,c

line 939

     if ((fp = fopen(filein, "r")) == NULL)

should be changed to:

    if ((fpin = fopen(filein, "rb")) == NULL)

----

psio2.c

line 1465

    if ((fp = fopen(filein, "r")) == NULL)

should be changed to:

    if ((fp = fopen(filein, "rb")) == NULL)

----

utils.c

line 1236

    if ((fp = fopen(fname, "r")) == NULL)

should be changed to:

    if ((fp = fopen(fname, "rb")) == NULL)

line 1297

    fp = fopen(filename, "r");

should be changed to:

    fp = fopen(filename, "rb");

I presume since the function is called nbytesInFile(), you don't want crlf
translation to occur.

not sure but line 1360

     if ((fp = fopen(filename, operation)) == NULL)

should probably be changed to something like:

    strcpy(actualOperation, operation);
    strcat(actualOperation, "b");
    if ((fp = fopen(filename, actualOperation)) == NULL)

where

    char actualOperation[20] = "";

is defined at the top of the function.

Original issue reported on code.google.com by [email protected] on 23 Nov 2009 at 6:15

plotfile doesn't link

What steps will reproduce the problem?
1. Try to link plotfile

What is the expected output? What do you see instead?
I expect to link plotfile.
I get an "unresolved external symbol gplotFromFile referenced in function
main plotfile.obj" error.

What version of the product are you using? On what operating system?
leptonlib-1.64
Microsoft Visual Studio 2008 SP1 with latest updates also applied.
Windows XP Pro SP3.

Please provide any additional information below.
I see that plotfile is no longer in prog/Makefile. It should be removed
from the prog directory.

Original issue reported on code.google.com by [email protected] on 15 Jan 2010 at 7:54

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.