Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm currently working on the same thing. I found that a PNG saved in photoshop worked fine, but an image which was originally sourced from the camera then imported into the app never worked. Don't ask me to explain it - but applying this function made these images work. Maybe it'll work for you too.</p> <pre><code>// this does the trick to have tesseract accept the UIImage. UIImage * gs_convert_image (UIImage * src_img) { CGColorSpaceRef d_colorSpace = CGColorSpaceCreateDeviceRGB(); /* * Note we specify 4 bytes per pixel here even though we ignore the * alpha value; you can't specify 3 bytes per-pixel. */ size_t d_bytesPerRow = src_img.size.width * 4; unsigned char * imgData = (unsigned char*)malloc(src_img.size.height*d_bytesPerRow); CGContextRef context = CGBitmapContextCreate(imgData, src_img.size.width, src_img.size.height, 8, d_bytesPerRow, d_colorSpace, kCGImageAlphaNoneSkipFirst); UIGraphicsPushContext(context); // These next two lines 'flip' the drawing so it doesn't appear upside-down. CGContextTranslateCTM(context, 0.0, src_img.size.height); CGContextScaleCTM(context, 1.0, -1.0); // Use UIImage's drawInRect: instead of the CGContextDrawImage function, otherwise you'll have issues when the source image is in portrait orientation. [src_img drawInRect:CGRectMake(0.0, 0.0, src_img.size.width, src_img.size.height)]; UIGraphicsPopContext(); /* * At this point, we have the raw ARGB pixel data in the imgData buffer, so * we can perform whatever image processing here. */ // After we've processed the raw data, turn it back into a UIImage instance. CGImageRef new_img = CGBitmapContextCreateImage(context); UIImage * convertedImage = [[UIImage alloc] initWithCGImage: new_img]; CGImageRelease(new_img); CGContextRelease(context); CGColorSpaceRelease(d_colorSpace); free(imgData); return convertedImage; } </code></pre> <p>I've also gone a lot of experimentation preparing the image for tesseract. Resizing, converting to grayscale, then adjusting brightness and contrast seems to work best.</p> <p>I've also tried this GPUImage library. <a href="https://github.com/BradLarson/GPUImage" rel="noreferrer">https://github.com/BradLarson/GPUImage</a> And the GPUImageAverageLuminanceThresholdFilter seems to give me a great adjusted image, but tesseract doesn't seem to work well with it.</p> <p>I've also put in opencv into my project and plan to try out it's image routines. Possibly even some box detection to find the text area (i'm hoping this will speed up tesseract).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload