Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
yq committed Dec 1, 2018
1 parent e092ede commit 4c82e8d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
9 changes: 8 additions & 1 deletion include/ocr_extractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <vector>
#include <algorithm>
#include <queue>
#include <opencv2/opencv.hpp>

using namespace std;
Expand All @@ -11,10 +12,16 @@ class OcrExtractor {

public:

enum class Mode {
DEFAULT,
CLEAN,
};

const Mode mode;
int roi_idx;
vector<cv::Mat> roi_arr;

OcrExtractor();
OcrExtractor(Mode _mode=Mode::DEFAULT);
void extract_img(const cv::Mat & piece);
bool has_next();
cv::Mat next_roi();
Expand Down
21 changes: 18 additions & 3 deletions src/ocr_extractor.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <ocr_extractor.h>

OcrExtractor::OcrExtractor() {

OcrExtractor::OcrExtractor(Mode _mode) :
mode(_mode) {
}

void OcrExtractor::extract_img(const cv::Mat & piece) {
Expand Down Expand Up @@ -83,15 +83,30 @@ void OcrExtractor::extract_img(const cv::Mat & piece) {

roi_arr.clear();
roi_idx = 0;
int width_half = piece.cols >> 1;

for (int i = 1; i < (int)symbol_y_arr.size(); i++) {

int y0 = symbol_block_y_arr[i - 1];
int y1 = symbol_block_y_arr[i];
int margin = int((y1 - y0) * 0.1);
y0 = max(0, y0 - margin);
y1 = min(piece.rows, y1 + margin);

int height = y1 - y0;

if (mode == Mode::CLEAN) {

queue< pair<int,int> > que;
vector< vector<int> > visited();

for (int y = y0; y < y1; y++) {
for (int x = width_half - 2; width_half + 2; width_half++) {
if ()
}
}
}


int width = min(height, piece.cols);
int x0 = (piece.cols - width) >> 1;

Expand Down

0 comments on commit 4c82e8d

Please sign in to comment.