image_manipulation.h
Go to the documentation of this file.
1 /*
2  * This file is part of Laustracker.
3  *
4  * Copyright (C) 2013 Christian Jann <christian.jann@ymail.com>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef HEADER_LAUSTRACKER_IMAGE_MANIPULATION_H_INCLUDED
21 #define HEADER_LAUSTRACKER_IMAGE_MANIPULATION_H_INCLUDED
22 
28 #include <opencv2/core/core.hpp>
29 #include <opencv2/imgproc/imgproc.hpp>
30 #include <opencv2/highgui/highgui.hpp>
31 
32 using namespace cv;
33 using namespace std;
34 
40 {
41 private:
43  FileStorage fs;
44  Mat intrinsic_matrix_loaded, distortion_coeffs_loaded;
46  Mat map1, map2;
48  Size size;
49 
50 public:
59 
64  ~ImageUndistort();
65 
74  void remap(const Mat& image, Mat &dst);
75 
81  bool set_intrinsics_xml(string filename);
82 };
83 
91 void white_regions(const Mat& image, Mat& white_regions, int thres = 100);
92 
106 void edm(const Mat& src, Mat& dst, int erode_size = 3, int dilation_size = 4,
107  int morph_size = 10, bool debug = false);
116 void get_thresholded_image(const Mat& image, Scalar min, Scalar max, Mat& dst,
117  bool debug = false);
118 
131 void get_thresholded_image2(const Mat& image, Scalar min1, Scalar max1,
132  Scalar min2, Scalar max2, Mat& dst, bool debug = false);
133 
140 void wrap_perspective(const Mat& src, Mat& dst, const vector <Point>& rect);
141 
147 {
148 private:
150  int width, height;
152  Point2f objPts[4], imgPts[4];
154  Mat H;
156  bool ready;
157 public:
164  void init(const vector <Point>& rect);
170  void wrap(const Mat& src, Mat& dst);
171 
176  vector <Point> get_rect();
177 };
178 #endif
A class to do a perspective transformation.
Mat H
THE HOMOGRAPHY.
int width
Width and height of the rect.
void get_thresholded_image2(const Mat &image, Scalar min1, Scalar max1, Scalar min2, Scalar max2, Mat &dst, bool debug=false)
Create a thresholded image with white regions from two color ranges.
FileStorage fs
To read the intrinsics_xml file.
void get_thresholded_image(const Mat &image, Scalar min, Scalar max, Mat &dst, bool debug=false)
Create a thresholded image with white regions.
Class to undistort images.
void white_regions(const Mat &image, Mat &white_regions, int thres=100)
Calculate a binary black-white image.
bool ready
Was the init() function already called?
void wrap_perspective(const Mat &src, Mat &dst, const vector< Point > &rect)
Wrap the perspective.
void edm(const Mat &src, Mat &dst, int erode_size=3, int dilation_size=4, int morph_size=10, bool debug=false)
Erode, Dilate, Morph.
Size size
Image size.
Mat map1
The undistort map.