forked from cryptixcoder/neural-ocr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageData.h
38 lines (29 loc) · 1001 Bytes
/
ImageData.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
#include <cv.h>
#include <highgui.h>
class ImageData {
private:
// Indicates whether there was an error reading the file.
bool readError;
// The image object as stored by OpenCV.
IplImage *img;
// The width, height, and array of pixels of the image.
int width, height;
float* pixels;
public:
// Normalized width and height constants.
static const int NORMALIZED_WIDTH = 30;
static const int NORMALIZED_HEIGHT = 30;
// Read the image file and store its data, after converting the image to
// binary and normalizing it for size.
ImageData(std::string file, int target_size, bool boundingBox);
// Free the image object.
~ImageData();
// Get the pixel corresponding to position (x,y).
float pixel(int x, int y) const;
// Get the width and height and vector of pixels of the image.
int getWidth() const;
int getHeight() const;
void getPixels(std::vector<double> *v) const;
// Report whether an error occurred reading the image.
bool error() const;
};