Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Tesseract OCR-指定模式_Python_Ocr_Tesseract_Python Tesseract - Fatal编程技术网

Python Tesseract OCR-指定模式

Python Tesseract OCR-指定模式,python,ocr,tesseract,python-tesseract,Python,Ocr,Tesseract,Python Tesseract,我正在尝试使用Tesseract(版本3.04.00)执行OCR。 我所有的图像都有相同的模式(数字,即精度为2位的十进制)。我尝试使用--user patterns选项,但无法使其工作 我所做的: 在第一行创建带有\d.\d的文件patterns.txt 使用选项--user patterns.txt 但我得到了以下错误: pytesseract.pytesseract.TesseractError: (1, "Tesseract Open Source OCR Engine v3.04.

我正在尝试使用Tesseract(版本3.04.00)执行OCR。 我所有的图像都有相同的模式(数字,即精度为2位的十进制)。我尝试使用
--user patterns
选项,但无法使其工作

我所做的:

  • 在第一行创建带有
    \d.\d
    的文件
    patterns.txt
  • 使用选项
    --user patterns.txt
但我得到了以下错误:

pytesseract.pytesseract.TesseractError: (1, "Tesseract Open Source OCR Engine v3.04.00 with Leptonica read_params_file: Can't open 1 read_params_file: Can't open user-patterns read_params_file: parameter not found: \\d.\\d\\d")
如何将图案指定给Tesseract?这是正确的方法吗? 提前感谢您的帮助或建议,我在Tesseract上找不到太多的文档

编辑:添加Python代码

img = cv2.imread("path/to/image", cv2.IMREAD_GRAYSCALE)
text = pytesseract.image_to_string(img, config="-psm 7 --user-patterns patterns.txt")
print(text)

没关系,我认为Tesseract对于我的用例来说是杀伤力过大了


我拍摄了一张从0到9的每个数字的图像,并用我想要预测的图像选取了最小均方误差。在我的测试数据集上获得了100%的准确率。

您能显示您尝试过的代码吗?错误消息与Pyteseract有关,因此我假设您编写了一些代码来获得此错误。编辑了问题。然而,我发现了一个更简单的方法,检查我的答案。我很好奇为什么这样做不起作用,那将是一个更普遍的解决方案。顺便说一下-
用户模式
不会让tesseract只返回文件中定义的模式。如果识别出的符号遵循这种模式,它只会稍微增加它们的可信度,用户单词也是如此。@DmitriiZ。是的,我在文档中读到了,但我希望它能带来改进,因为有时候它在所有方面都是错误的(例如1.13是读谎言…)。