forked from ryanpeach/openscan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cvmethods.hpp
49 lines (35 loc) · 1.23 KB
/
cvmethods.hpp
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
/**
* cvmethods.hpp
*
* @date Nov 4, 2015
* @author Ryan Peach
* @version v0.1
*/
#ifndef CVMETHODS
#define CVMETHODS
#include <cmath>
#include "focus.hpp"
// -------------- Feature Detection ----------------
// Filters the img, finds the contours, and returns the Cnts.
Cnts findPolys(Mat * img, double distRatio);
// Find all the focus points within an image.
Fps findFocusPoints(Cnts polys, double angleTol, double distRatio);
// Classifies squares and selects the four most likely to be corners
// Null-Condition: Returns null
Fps calcCorners(Fps focusPoints, double angleTol, double distRatio);
// Sort edges by distance.
// Corners must be a rectangle
// Null-Condition: Returns corners
cnt sortCorners(cnt corners, Point ref, double distRatio = 0);
cnt sortCorners(cnt corners);
// Null-Condition: Returns fps[0]
Fp calcRef(Fps fps);
// Null-Condition: Returns contour[0]
Point calcRef(cnt contour);
// ------------ Image Manipulation --------------
Mat cropImage(Mat * img, int R);
// Reference: Modified from http://www.pyimagesearch.com/2014/08/25/4-point-opencv-getperspective-transform-example/
Mat fixPerspective(Mat * img, cnt border, Point ref);
Mat fixPerspective(Mat * img, Fps border, Fp ref);
bool isColor(Mat * img);
#endif