Tag: leptonica

OCR:图像到文本?

在标记为复制或重复问题之前,请先阅读整个问题。 我能够做的事情如下: 获取图像并剪裁OCR所需的部分。 使用tesseract和leptonica处理图像。 当应用的文档以大块(即,每个图像1个字符)裁剪时,它提供了96%的准确度。 如果我不这样做,文档背景是白色,文字是黑色的,它的准确度几乎相同。 例如,如果input是这张照片: 照片开始 照片结束 我想要的是能够为这张照片获得相同的准确性 没有生成块。 我用来初始化和提取图像文本的代码如下: 对于tesseract的初始化 在.h文件中 tesseract::TessBaseAPI *tesseract; uint32_t *pixels; 在.m文件中 tesseract = new tesseract::TessBaseAPI(); tesseract->Init([dataPath cStringUsingEncoding:NSUTF8StringEncoding], "eng"); tesseract->SetPageSegMode(tesseract::PSM_SINGLE_LINE); tesseract->SetVariable("tessedit_char_whitelist", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"); tesseract->SetVariable("language_model_penalty_non_freq_dict_word", "1"); tesseract->SetVariable("language_model_penalty_non_dict_word ", "1"); tesseract->SetVariable("tessedit_flip_0O", "1"); tesseract->SetVariable("tessedit_single_match", "0"); tesseract->SetVariable("textord_noise_normratio", "5"); tesseract->SetVariable("matcher_avg_noise_size", "22"); tesseract->SetVariable("image_default_resolution", "450"); tesseract->SetVariable("editor_image_text_color", "40"); tesseract->SetVariable("textord_projection_scale", "0.25"); tesseract->SetVariable("tessedit_minimal_rejection", "1"); tesseract->SetVariable("tessedit_zero_kelvin_rejection", "1"); 从图像获取文本 – (void)processOcrAt:(UIImage […]