Skip to content

Commit 5129c43

Browse files
committed
Stopped error messages from pixaGetCount
1 parent 13e46ae commit 5129c43

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

textord/devanagari_processing.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ bool ShiroRekhaSplitter::Split(bool split_for_pageseg) {
130130
// out the image regions corresponding to these boxes from the original image.
131131
// Conditionally run splitting on each of them.
132132
Boxa* regions_to_clear = boxaCreate(0);
133-
for (int i = 0; i < pixaGetCount(ccs); ++i) {
133+
int num_ccs = 0;
134+
if (ccs != nullptr) num_ccs = pixaGetCount(ccs);
135+
for (int i = 0; i < num_ccs; ++i) {
134136
Box* box = ccs->boxa->box[i];
135137
Pix* word_pix = pixClipRectangle(orig_pix_, box, NULL);
136138
ASSERT_HOST(word_pix);

textord/imagefind.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ void ImageFind::ConnCompAndRectangularize(Pix* pix, Boxa** boxa, Pixa** pixa) {
151151
// Rectangularize the individual images. If a sharp edge in vertical and/or
152152
// horizontal occupancy can be found, it indicates a probably rectangular
153153
// image with unwanted bits merged on, so clip to the approximate rectangle.
154-
int npixes = pixaGetCount(*pixa);
154+
int npixes = 0;
155+
if (*boxa != nullptr && *pixa != nullptr) npixes = pixaGetCount(*pixa);
155156
for (int i = 0; i < npixes; ++i) {
156157
int x_start, x_end, y_start, y_end;
157158
Pix* img_pix = pixaGetPix(*pixa, i, L_CLONE);
@@ -1293,7 +1294,8 @@ void ImageFind::FindImagePartitions(Pix* image_pix,
12931294
Pixa* pixa;
12941295
ConnCompAndRectangularize(image_pix, &boxa, &pixa);
12951296
// Iterate the connected components in the image regions mask.
1296-
int nboxes = boxaGetCount(boxa);
1297+
int nboxes = 0;
1298+
if (boxa != nullptr && pixa != nullptr) nboxes = boxaGetCount(boxa);
12971299
for (int i = 0; i < nboxes; ++i) {
12981300
l_int32 x, y, width, height;
12991301
boxaGetBoxGeometry(boxa, i, &x, &y, &width, &height);

0 commit comments

Comments
 (0)