Comments (6)
BMP writing in leptonica has been tested on many different kinds of images.
For example, the following when run with valgrind has no memory issues, where the
images being tested are all in the prog directory:
const char *infile[15] = {"test1.bmp", "speckle2.png", "weasel2.4g.png",
"speckle4.png", "dreyfus8.png", "weasel8.240c.png",
"test8.jpg", "test16.tif", "marge.jpg",
"test32-alpha.png", "test-1bit-alpha.png",
"test-cmap-alpha.png", "test-fulltrans-alpha.png",
"test-gray-alpha.png", "gray-alpha.tif"};
pixa1 = pixaCreate(16);
for (i = 0; i < 15; i++) {
pix1 = pixRead(infile[i]);
cmap = pixGetColormap(pix1);
snprintf(outfile, sizeof(outfile), "/tmp/outfile.%d", i);
pixWrite(outfile, pix1, IFF_BMP);
pix2 = pixRead(outfile);
if (!cmap)
pix3 = pixRemoveColormap(pix2, REMOVE_CMAP_BASED_ON_SRC);
else
pix3 = pixClone(pix2);
pixaAddPix(pixa1, pix3, L_INSERT);
pixEqual(pix1, pix3, &equal);
if (!equal)
lept_stderr("failure for i = %d\n", i);
pixDestroy(&pix1);
pixDestroy(&pix2);
}
pix1 = pixaDisplayTiledInColumns(pixa1, 1, 1.0, 30, 2);
pixWrite("/tmp/results.png", pix1, IFF_PNG);
pixaDestroy(&pixa1);
pixDestroy(&pix1);
Questions:
- How do you know the failure is due to not checking for a colormap'?
- What is the input image that is failing in tesseract?
It would help to write the pix out in png format.
from leptonica.
I'm using a raw image from memory.
I use this method from Tesseract to initialize the image:
void TessBaseAPI::SetImage(const unsigned char *imagedata, int width, int height,
int bytes_per_pixel, int bytes_per_line) {
if (InternalSetImage()) {
thresholder_->SetImage(imagedata, width, height, bytes_per_pixel, bytes_per_line);
SetInputImage(thresholder_->GetPixRect());
}
}
I found the crash location while debugging. I'm using tesseract 1.83.1
As you can see in the screenshot I have to add an small patch to use the library. (just a check for the presence of colormap)
I will try to write the pix in png format and let you know about it.
from leptonica.
Thank you. You have prevented the crash by adding the check for the colormap, right?
That code in bmpio.c says that bmp files with d <=8 have colormaps.
This pix has d = 32 bpp, with 3 spp. So it does not have a colormap.
Without the check that you added, it crashes in l. 548 when referencing into NULL.
I don't need the png file and will fix the code.
from leptonica.
Right, that’s exactly the situation.
Thanks
from leptonica.
Resolved in commit 76c635c
from leptonica.
Thanks again, Carlos !
from leptonica.
Related Issues (20)
- 1.84.0 fails to build in FreeBSD 14.0 due missing reference to libm using CMake HOT 24
- CMake build in 1.84.0 adds include to non-existant path
- 1.84.1: compile time warnings HOT 3
- pixWriteJp2k: unexpected strong color artifacts on featureless image HOT 7
- pixOrientDetect with .bmp file HOT 6
- Logic error in pixcmapIsValid() HOT 5
- Regression: file not found on MacOS when opening /tmp file HOT 2
- Identifying and removing asterisks HOT 8
- pixDeskewGeneral(...) failing to detect a 45 degree skew? HOT 2
- Application crashing while disposing Pix.Create object HOT 5
- get minarea-rotated box of a skew area HOT 2
- pixRead() can't read png images HOT 5
- Installing leptonica on Windows failed with reason prompt 'SW' not found HOT 2
- Errors building Leptonica for use with Tesseract HOT 2
- getImpliedFileFormat / pixWriteImpliedFormat and PNM issues HOT 2
- pixOrientCorrect/pixOrientDetect issue with PBM HOT 4
- Cross-Compiling Leptonica for Windows on Arch Linux HOT 9
- Avoid taking address of packed member HOT 1
- Ghostscript build fails on Solaris due Tesseract and/or Leptonica HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leptonica.