forked from ryanpeach/openscan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfocus.hpp
60 lines (45 loc) · 1.32 KB
/
focus.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
50
51
52
53
54
55
56
57
58
59
60
/**
* focus.hpp
*
* @date Nov 4, 2015
* @author Ryan Peach
* @version v0.1
*/
#ifndef FOCUS
#define FOCUS
#include <typeinfo>
#include "geometry.hpp"
struct Fp {
vector<cnt> contours;
cnt contour;
Point center;
int depth, shape;
int findInnerBorder(vector<cnt> cnts, double angleTol, double distRatio);
Fp (vector<cnt> conts, cnt cont, Point cent, int d, int s);
Fp (vector<cnt> conts, double angleTol, double distRatio);
Fp (vector<cnt> conts);
Fp ();
bool operator== (Fp newFp);
bool operator!= (Fp newFp);
bool isValid ();
Fp copy ();
};
typedef vector<Fp> Fps;
Point centroid(vector<Fp> fps);
Point centroid(Fp f);
cnt centroids(vector<Fp> fps);
string tostr(Fp fp);
/**
* Test that the center of all focus points are inside the poly.
* @param cnt poly: Any cnt you wish to test as the boundary.
* @param vector<Fp> fps: A list of Fp's to test locations of.
* @return True / False
* @complexity O(?)
*/
bool allInside(cnt poly, vector<Fp> fps);
// Extended from geometry.cpp for easy Fp processing
vector<vector<Fp>> hasRectangles(vector<Fp> fps, double angleTol, double distRatio, int n = 1);
vector<Fp> hasRectangle(vector<Fp> fps, double angleTol, double distRatio);
vector<double> angs(Point x, vector<Fp> fours);
vector<Fp> toFps(cnt,vector<Fp>);
#endif