new function to fill out missing mesh squares before caclulating delta
[sparrow.git] / edges.h
blob7bc422d189611418e39bc310e3b07b726879cfea
1 #ifndef __SPARROW_EDGES_H__
2 #define __SPARROW_EDGES_H__
4 #define SAFETY_LAG 3;
5 #define SIG_WEIGHT 2
7 /* for discarding outliers */
8 #define OUTLIER_RADIUS 7
9 #define OUTLIER_THRESHOLD (OUTLIER_RADIUS * OUTLIER_RADIUS)
11 #define BAD_PIXEL 0xffff
13 #define FL_DUMPFILE "/tmp/edges.dump"
15 #define COLOUR_QUANT 1
16 #define COLOUR_MASK (0xff >> COLOUR_QUANT)
18 /*XXX should dither */
19 #define QUANTISE_DELTA(d)(((d) + LINE_PERIOD / 2) / LINE_PERIOD)
21 typedef enum corner_status {
22 CORNER_UNUSED,
23 CORNER_PROJECTED,
24 CORNER_EXACT,
25 CORNER_SETTLED,
26 } corner_status_t;
28 typedef enum edges_state {
29 EDGES_FIND_NOISE,
30 EDGES_FIND_LINES,
31 EDGES_FIND_CORNERS,
32 EDGES_WAIT_FOR_PLAY,
34 EDGES_NEXT_STATE,
35 } edges_state_t;
37 typedef struct sparrow_estimator_s {
38 int x1;
39 int y1;
40 int x2;
41 int y2;
42 int x3;
43 int y3;
44 //int mul; /* estimate: x1,y1 + mul * diff */
45 } sparrow_estimator_t;
47 typedef struct sparrow_corner_s {
48 int x;
49 int y;
50 /*dyr -> dy to next point right
51 dxd ->dx to next point down */
52 int dxr;
53 int dyr;
54 int dxd;
55 int dyd;
56 corner_status_t status;
57 } sparrow_corner_t;
59 typedef struct sparrow_voter_s {
60 int x;
61 int y;
62 guint32 signal;
63 } sparrow_voter_t;
65 typedef struct sparrow_cluster_s {
66 int n;
67 sparrow_voter_t voters[8];
68 } sparrow_cluster_t;
71 typedef union sparrow_signal_s {
72 guint16 v_signal;
73 guint16 h_signal;
74 } sparrow_signal_t;
77 typedef struct sparrow_intersect_s {
78 guint16 lines[2];
79 guint16 signal[2];
80 } sparrow_intersect_t;
82 typedef struct sparrow_line_s {
83 gint offset;
84 sparrow_axis_t dir;
85 gint index;
86 } sparrow_line_t;
88 /*condensed version of <struct sparrow_find_lines_s> for saving: contains no
89 pointers or other unnecessary things that might vary in size across
90 architectures. */
91 typedef struct sparrow_fl_condensed {
92 gint32 n_vlines;
93 gint32 n_hlines;
94 } sparrow_fl_condensed_t;
96 typedef struct sparrow_find_lines_s {
97 sparrow_line_t *h_lines;
98 sparrow_line_t *v_lines;
99 sparrow_line_t **shuffled_lines;
100 int current;
101 int n_lines;
102 int n_vlines;
103 int n_hlines;
104 gint shift1;
105 gint shift2;
106 sparrow_intersect_t *map;
107 sparrow_corner_t *mesh;
108 sparrow_cluster_t *clusters;
109 IplImage *debug;
110 IplImage *threshold;
111 IplImage *working;
112 IplImage *input;
113 edges_state_t state;
114 } sparrow_find_lines_t;
117 #define DEBUG_FIND_LINES(fl)GST_DEBUG( \
118 "fl:\n" \
119 " sparrow_line_t *h_lines: %p\n" \
120 " sparrow_line_t *v_lines: %p\n" \
121 " sparrow_line_t **shuffled_lines: %p\n" \
122 " int current: %d\n" \
123 " int n_lines: %d\n" \
124 " int n_vlines: %d\n" \
125 " int n_hlines: %d\n" \
126 " gint shift1: %d\n" \
127 " gint shift2: %d\n" \
128 " sparrow_intersect_t *map: %p\n" \
129 " sparrow_corner_t *mesh: %p\n" \
130 " sparrow_cluster_t *clusters: %p\n" \
131 " IplImage *debug: %p\n" \
132 " IplImage *threshold: %p\n" \
133 " IplImage *working: %p\n" \
134 " IplImage *input: %p\n" \
135 " edges_state_t state: %d\n" \
137 (fl)->h_lines, \
138 (fl)->v_lines, \
139 (fl)->shuffled_lines, \
140 (fl)->current, \
141 (fl)->n_lines, \
142 (fl)->n_vlines, \
143 (fl)->n_hlines, \
144 (fl)->shift1, \
145 (fl)->shift2, \
146 (fl)->map, \
147 (fl)->mesh, \
148 (fl)->clusters, \
149 (fl)->debug, \
150 (fl)->threshold, \
151 (fl)->working, \
152 (fl)->input, \
153 (fl)->state \
155 //#undef debug_find_lines
156 //#define debug_find_lines(x) /* */
159 #endif /*have this .h*/