remove multiple RGB to grey conversion while OCR

This commit is contained in:
Anshul Maheshwari 2018-11-05 14:51:15 +05:30
parent b8a15f6f9d
commit d22ab6f9a1
2 changed files with 6 additions and 4 deletions

View File

@ -1,5 +1,6 @@
0.88(2018-10-24) (unreleased) 0.88(2018-10-24) (unreleased)
----------------- -----------------
- Optimize: Remove multiple RGB to grey conversion in OCR.
- Fix: Update UTF8Proc to 2.2.0 - Fix: Update UTF8Proc to 2.2.0
- Fix: Warn instead of fatal when a 0xFF marker is missing - Fix: Warn instead of fatal when a 0xFF marker is missing

View File

@ -244,20 +244,21 @@ char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* i
ppixel++; ppixel++;
} }
} }
BOX *crop_points = ignore_alpha_at_edge(copy->alpha, copy->data, w, h, color_pix, &color_pix_out); BOX *crop_points = ignore_alpha_at_edge(copy->alpha, copy->data, w, h, color_pix, &color_pix_out);
//Converting image to grayscale for OCR to avoid issues with transparency
cpix_gs = pixConvertRGBToGray(cpix, 0.0, 0.0, 0.0);
#ifdef OCR_DEBUG #ifdef OCR_DEBUG
{ {
char str[128] = ""; char str[128] = "";
static int i = 0; static int i = 0;
sprintf(str,"temp/file_c_%d.jpg",i); sprintf(str,"temp/file_c_%d.jpg",i);
printf("Writing file_c_%d.jpg\n", i); printf("Writing file_c_%d.jpg\n", i);
pixWrite(str, pixConvertRGBToGray(cpix, 0.0, 0.0, 0.0), IFF_JFIF_JPEG); pixWrite(str, cpix_gs, IFF_JFIF_JPEG);
i++; i++;
} }
#endif #endif
cpix_gs = pixConvertRGBToGray(cpix, 0.0, 0.0, 0.0); // Abhinav95: Converting image to grayscale for OCR to avoid issues with transparency
if (cpix_gs==NULL) if (cpix_gs==NULL)
tess_ret=-1; tess_ret=-1;
else else
@ -273,7 +274,7 @@ char* ocr_bitmap(void* arg, png_color *palette,png_byte *alpha, unsigned char* i
pixDestroy(&cpix_gs); pixDestroy(&cpix_gs);
pixDestroy(&color_pix); pixDestroy(&color_pix);
pixDestroy(&color_pix_out); pixDestroy(&color_pix_out);
return NULL; return NULL;
} }
} }