英文:
Gosseract not run
问题
以下是我翻译好的内容:
// github.com/otiai10/gosseract/v2
tessbridge.cpp:5:10: 致命错误: leptonica/allheaders.h: 没有那个文件或目录
5 | #include <leptonica/allheaders.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~
编译终止。
下面是我编写的代码
它出现了一个错误。我重新安装了Tesseract-i,但仍然出现相同的错误。
```go
package main
import (
"fmt"
"github.com/otiai10/gosseract/v2"
)
func main() {
client := gosseract.NewClient()
defer client.Close()
client.SetImage("C:\\Users\\labusers\\Downloads\\khan.png")
text, _ := client.Text()
fmt.Println(text)
}
英文:
# github.com/otiai10/gosseract/v2
tessbridge.cpp:5:10: fatal error: leptonica/allheaders.h: No such file or directory
5 | #include <leptonica/allheaders.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
below is the code i wrote
it gives an error. I reinstalled Tesseract-i, it still gives the same error
package main
import (
"fmt"
"github.com/otiai10/gosseract/v2"
)
func main() {
client := gosseract.NewClient()
defer client.Close()
client.SetImage("C:\\Users\\labusers\\Downloads\\khan.png")
text, _ := client.Text()
fmt.Println(text)
}
答案1
得分: 2
安装Tesseract可能会有些棘手。以下是一个可行的Dockerfile:
FROM golang:1.14.9
RUN cat /etc/os-release
# 输出:Debian GNU/Linux 10 (buster)
RUN apt-get -qy update
RUN apt-get install -qy libleptonica-dev libtesseract-dev
RUN apt-get install -qy libtool m4 automake cmake pkg-config
RUN apt-get install -qy libicu-dev libpango1.0-dev libcairo-dev
RUN cd /opt && git clone https://github.com/tesseract-ocr/tesseract
WORKDIR /opt/tesseract
RUN git reset --hard 4.1.1
RUN ./autogen.sh &&\
./configure --enable-debug LDFLAGS="-L/usr/local/lib" CFLAGS="-I/usr/local/include"
RUN make -j 8
RUN make install && ldconfig
RUN tesseract --version
ENV TESSDATA_PREFIX=/usr/local/share/tessdata
ENV TESSDATA_REPO=https://github.com/tesseract-ocr/tessdata_best
WORKDIR ${TESSDATA_PREFIX}
RUN wget -q ${TESSDATA_REPO}/raw/4.1.0/eng.traineddata
这个Dockerfile从源代码构建Tesseract,所以你可以选择Tesseract的版本。我是在两年前使用gosseract
库时编写的这个Dockerfile。
英文:
Installing Tesseract can be tricky. The following Dockerfile works:
FROM golang:1.14.9
RUN cat /etc/os-release
# Output: Debian GNU/Linux 10 (buster)
RUN apt-get -qy update
RUN apt-get install -qy libleptonica-dev libtesseract-dev
RUN apt-get install -qy libtool m4 automake cmake pkg-config
RUN apt-get install -qy libicu-dev libpango1.0-dev libcairo-dev
RUN cd /opt && git clone https://github.com/tesseract-ocr/tesseract
WORKDIR /opt/tesseract
RUN git reset --hard 4.1.1
RUN ./autogen.sh &&\
./configure --enable-debug LDFLAGS="-L/usr/local/lib" CFLAGS="-I/usr/local/include"
RUN make -j 8
RUN make install && ldconfig
RUN tesseract --version
ENV TESSDATA_PREFIX=/usr/local/share/tessdata
ENV TESSDATA_REPO=https://github.com/tesseract-ocr/tessdata_best
WORKDIR ${TESSDATA_PREFIX}
RUN wget -q ${TESSDATA_REPO}/raw/4.1.0/eng.traineddata
The Dockerfile build Tesseract from source so you can choose Tesseract version. I wrote this Dockerfile when I used gosseract
library 2 years ago.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论