#magickのインストールinstall.packages("magick")library(magick)#image.libfacedetectionのインストール: CNN for Face Detectioninstall.packages("image.libfacedetection", repos ="https://bnosac.github.io/drat")library(image.libfacedetection)
#言語設定: 英語(eng)
eng <-tesseract("eng")#テスト画像の読み込み
Img <- EBImage::readImage(files="http://jeroen.github.io/images/testocr.png")#テスト画像の表示options(EBImage.display ="raster")
EBImage::display(Img)
この英字を含むテスト画像をインプットとして、次に、tesseractのOCRを実行してみます。
#OCR実行
text <- tesseract::ocr("http://jeroen.github.io/images/testocr.png",
engine = eng)#結果表示cat(text)#This is a lot of 12 point text to test the#ocr code and see if it works on all types#of file format.##The quick brown dog jumped over the#lazy fox. The quick brown dog jumped#over the lazy fox. The quick brown dog#jumped over the lazy fox. The quick#brown dog jumped over the lazy fox.
text
#[1] "This is a lot of 12 point text to test the\nocr code and see if it works on all types\nof#file format.\n\nThe quick brown dog jumped over the\nlazy fox. The quick brown dog jumped\nover#the lazy fox. The quick brown dog\njumped over the lazy fox. The quick\nbrown dog jumped over the#lazy fox.\n"