我正在尝试将配置参数传递给pytesseract的image_to_string函数。
我正在运行的代码如下。
TypeError: image_to_string() got an unexpected keyword argument 'config'
,错误消息是
conda install -c auto pytesseract
stackoverflow中还有另一个similar question,但我不认为它解决了我遇到的问题。
我通过带有config
如果删除/*
* ArrayList.java
*
*/
import java.util.*;
/*
* A class that implements our simple List interface using an array.
*/
public class ArrayList implements List {
private Object[] items; // the items in the list
private int length; // # of items in the list
/*
* Constructs an ArrayList object with the specified maximum size
* for a list that is initially empty.
*/
public ArrayList(int maxSize) {
items = new Object[maxSize];
length = 0;
}
/*
* Constructs an ArrayList object containing the items in the specified
* array, and with a max size that is twice the size of that array
* (to allow room for growth).
*/
public ArrayList(Object[] initItems) {
items = new Object[2 * initItems.length];
for (int i = 0; i < initItems.length; i++) {
items[i] = initItems[i];
}
length = initItems.length;
}
/*
* length - returns the number of items in the list
*/
public int length() {
return length;
}
/*
* isFull - returns true if the list is full, and false otherwise
*/
public boolean isFull() {
return (length == items.length);
}
/* getItem - returns the item at position i in the list */
public Object getItem(int i) {
if (i < 0 || i >= length) {
throw new IndexOutOfBoundsException();
}
return items[i];
}
/*
* addItem - adds the specified item at position i in the list,
* shifting the items that are currently in positions i, i+1, i+2,
* etc. to the right by one. Returns false if the list is full,
* and true otherwise.
*/
public boolean addItem(Object item, int i) {
if (i < 0 || i > length) {
throw new IndexOutOfBoundsException();
} else if (isFull()) {
return false;
}
// make room for the new item
for (int j = length - 1; j >= i; j--) {
items[j + 1] = items[j];
}
items[i] = item;
length++;
return true;
}
/*
* removeItem - removes the item at position i in the list,
* shifting the items that are currently in positions i+1, i+2,
* etc. to the left by one. Returns a reference to the removed
* object.
*/
public Object removeItem(int i) {
if (i < 0 || i >= length) {
throw new IndexOutOfBoundsException();
}
Object removed = items[i];
// fill in the "hole" left by the removed item
for (int j = i; j < length - 1; j++) {
items[j] = items[j + 1];
}
items[length - 1] = null;
length--;
return removed;
}
/*
* toString - converts the list into a String of the form
* {item0, item1, ...}
*/
public String toString() {
String str = "{";
for (int i = 0; i < length; i++) {
str = str + items[i];
if (i < length - 1) {
str = str + ", ";
}
}
str = str + "}";
return str;
}
/*
* iterator - returns an iterator for this list
*/
public ListIterator iterator() {
// still needs to be implemented
return null;
}
参数
P.S。:这是我发布的第一个问题,如果我做得不好,请给我反馈。谢谢=)
答案 0 :(得分:0)
这是我第一次使用tesseract,也许您应该尝试使用这种符号。
image_url = 'test2.png'
custom_config = r'-l por --psm 7'
print(pytesseract.image_to_string(image_url, config=custom_config))
重要的是要知道在我使用ubuntu并以这种方式安装的情况下,环境(Windows,Linux等)应该安装了tesseract。
sudo apt install tesseract-ocr
sudo apt-get install tesseract-ocr-por -y
然后您可以检查安装的语言
tesseract --list-langs
https://github.com/NanoNets/ocr-with-tesseract/blob/master/tesseract-tutorial.ipynb