-
Notifications
You must be signed in to change notification settings - Fork 19
/
ctc_scene_text_recognizer.h
50 lines (38 loc) · 1.4 KB
/
ctc_scene_text_recognizer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef CTC_Scene_Text_Recognizer_H
#define CTC_Scene_Text_Recognizer_H
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <unordered_map>
#include "tensorflow/core/framework/tensor_shape.pb.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/graph/graph.h"
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/platform.h"
#include "tensorflow/core/platform/types.h"
//opencv
#include <opencv2/core.hpp>
#include "opencv2/opencv.hpp"
#include "utils.h"
#include "recognizer.h"
using namespace tensorflow;
class CTCSceneTextRecognizer: public Recognizer{
public:
CTCSceneTextRecognizer();
CTCSceneTextRecognizer(const std::string frozen_graph_filename, const std::string dictionary_filename,
int _im_height=32, int _im_width=128);
bool init(const std::string frozen_graph_filename, const std::string);
void preprocess_image(cv::Mat& input_image, cv::Mat& output_image);
std::vector<cv::Mat> preprocess_images(std::vector<cv::Mat>& input_images);
std::string run_graph(const cv::Mat& image);
std::vector<std::string> run_graph(const std::vector<cv::Mat> input_images);
private:
void init_constant_vars(int _im_height=32, int _im_width=128);
float width_scale_ratio;
int seq_len;
int image_width;
int image_height;
};
#endif