Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid tesseract writing Pix out/reading them back. #2965

Merged
merged 1 commit into from
May 16, 2020

Commits on May 4, 2020

  1. Avoid tesseract writing Pix out/reading them back.

    By default, when we ImageData::SetPix, we write the data out as a
    PNG, just to read it back in to get a compressed buffer of data.
    We then use this to generate a new Pix.
    
    In builds of Tesseract on systems where we don't have temp files,
    writing files out is problematic.
    
    Not only that, but compressing/uncompressing is slow, and on minimal
    builds of leptonica, where we've disabled the format writers to reduce
    memory footprint, we get no compression anyway.
    
    In such cases, it'd be far nicer just to keep the original Pix as
    the internal data.
    
    Also, when recovering the pixmap from the ImageData, if we know we're
    only going to read from the data, we can avoid duplicating it and
    just use the original. This is exactly the case when GRAPHICS_DISABLED
    is set.
    
    So, introduce a TESSERACT_IMAGEDATA_AS_PIX predefine that we can use
    to cause the internal data to be a Pix rather than a compressed
    buffer.
    
    
    
    Given we don't do compression, and they were writing to memory,
    this was all just more effort than we needed.
    
    Also, if we're using GRAPHICS_DISABLED, we might as well just
    pixCopy rather than pixClone as only the scaler uses this.
    robinwatts committed May 4, 2020
    Configuration menu
    Copy the full SHA
    6bcb941 View commit details
    Browse the repository at this point in the history