remove ignored pt.2
This commit is contained in:
23
image/checkimage.cpp
Normal file
23
image/checkimage.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <string>
|
||||
#include <tesseract/baseapi.h>
|
||||
#include <leptonica/allheaders.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include "checkimage.h"
|
||||
|
||||
CheckImage::CheckImage(std::string path) {
|
||||
this->path = path;
|
||||
}
|
||||
|
||||
std::string CheckImage::parse_text() {
|
||||
std::string result;
|
||||
|
||||
tesseract::TessBaseAPI *ocr = new tesseract::TessBaseAPI();
|
||||
ocr->Init(NULL, "rus", tesseract::OEM_LSTM_ONLY);
|
||||
ocr->SetPageSegMode(tesseract::PSM_AUTO);
|
||||
|
||||
cv::Mat im = cv::imread(this->path, cv::IMREAD_COLOR);
|
||||
ocr->SetImage(im.data, im.cols, im.rows, 3, im.step);
|
||||
result = std::string(ocr->GetUTF8Text());
|
||||
|
||||
return result;
|
||||
}
|
||||
15
image/checkimage.h
Normal file
15
image/checkimage.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef CHECKIMAGE_H
|
||||
#define CHECKIMAGE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class CheckImage {
|
||||
std::string path;
|
||||
public:
|
||||
CheckImage(std::string path);
|
||||
|
||||
std::string parse_text();
|
||||
|
||||
};
|
||||
|
||||
#endif // CHECKIMAGE_H
|
||||
Reference in New Issue
Block a user