blacken margins in loop, and not in memset
[sparrow.git] / edges.h
blob078108e57f53c37edc3915582c023661a0ece4ba
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 typedef enum corner_status {
19 CORNER_UNUSED,
20 CORNER_PROJECTED,
21 CORNER_EXACT,
22 CORNER_SETTLED,
23 } corner_status_t;
25 typedef enum edges_state {
26 EDGES_FIND_NOISE,
27 EDGES_FIND_LINES,
28 EDGES_FIND_CORNERS,
29 EDGES_WAIT_FOR_PLAY,
31 EDGES_NEXT_STATE,
32 } edges_state_t;
34 #define USE_FLOAT_COORDS 1
36 #if USE_FLOAT_COORDS
37 typedef float coord_t;
38 typedef float coord_sum_t;
39 #define QUANTISE_DELTA(d)((d) / LINE_PERIOD)
41 #else
42 /* the mesh is stored in a fixed point notation.*/
43 #define SPARROW_FIXED_POINT 9
45 typedef int coord_t;
46 typedef gint64 coord_sum_t;
47 #define QUANTISE_DELTA(d)(((d) + LINE_PERIOD / 2) / LINE_PERIOD)
49 #endif
51 typedef struct sparrow_estimator_s {
52 int x1;
53 int y1;
54 int x2;
55 int y2;
56 int x3;
57 int y3;
58 //int mul; /* estimate: x1,y1 + mul * diff */
59 } sparrow_estimator_t;
61 typedef struct sparrow_corner_s {
62 coord_t x;
63 coord_t y;
64 /*dyr -> dy to next point right
65 dxd ->dx to next point down */
66 coord_t dxr;
67 coord_t dyr;
68 coord_t dxd;
69 coord_t dyd;
70 corner_status_t status;
71 } sparrow_corner_t;
73 typedef struct sparrow_voter_s {
74 coord_t x;
75 coord_t y;
76 guint32 signal;
77 } sparrow_voter_t;
79 typedef struct sparrow_point_s {
80 coord_t x;
81 coord_t y;
82 } sparrow_point_t;
84 typedef struct sparrow_cluster_s {
85 int n;
86 sparrow_voter_t voters[8];
87 } sparrow_cluster_t;
90 typedef union sparrow_signal_s {
91 guint16 v_signal;
92 guint16 h_signal;
93 } sparrow_signal_t;
96 typedef struct sparrow_intersect_s {
97 guint16 lines[2];
98 guint16 signal[2];
99 } sparrow_intersect_t;
101 typedef struct sparrow_line_s {
102 gint offset;
103 sparrow_axis_t dir;
104 gint index;
105 } sparrow_line_t;
107 /*condensed version of <struct sparrow_find_lines_s> for saving: contains no
108 pointers or other unnecessary things that might vary in size across
109 architectures. */
110 typedef struct sparrow_fl_condensed {
111 gint32 n_vlines;
112 gint32 n_hlines;
113 } sparrow_fl_condensed_t;
115 typedef struct sparrow_find_lines_s {
116 sparrow_line_t *h_lines;
117 sparrow_line_t *v_lines;
118 sparrow_line_t **shuffled_lines;
119 int current;
120 int n_lines;
121 int n_vlines;
122 int n_hlines;
123 gint shift1;
124 gint shift2;
125 sparrow_intersect_t *map;
126 sparrow_corner_t *mesh_mem;
127 sparrow_corner_t *mesh;
128 sparrow_corner_t *mesh_next;
129 sparrow_cluster_t *clusters;
130 double *dither;
131 IplImage *debug;
132 IplImage *threshold;
133 IplImage *working;
134 IplImage *input;
135 edges_state_t state;
136 } sparrow_find_lines_t;
139 #define DEBUG_FIND_LINES(fl)GST_DEBUG( \
140 "fl:\n" \
141 " sparrow_line_t *h_lines: %p\n" \
142 " sparrow_line_t *v_lines: %p\n" \
143 " sparrow_line_t **shuffled_lines: %p\n" \
144 " int current: %d\n" \
145 " int n_lines: %d\n" \
146 " int n_vlines: %d\n" \
147 " int n_hlines: %d\n" \
148 " gint shift1: %d\n" \
149 " gint shift2: %d\n" \
150 " sparrow_intersect_t *map: %p\n" \
151 " sparrow_corner_t *mesh: %p\n" \
152 " sparrow_cluster_t *clusters: %p\n" \
153 " double *dither: %p \n" \
154 " IplImage *debug: %p\n" \
155 " IplImage *threshold: %p\n" \
156 " IplImage *working: %p\n" \
157 " IplImage *input: %p\n" \
158 " edges_state_t state: %d\n" \
160 (fl)->h_lines, \
161 (fl)->v_lines, \
162 (fl)->shuffled_lines, \
163 (fl)->current, \
164 (fl)->n_lines, \
165 (fl)->n_vlines, \
166 (fl)->n_hlines, \
167 (fl)->shift1, \
168 (fl)->shift2, \
169 (fl)->map, \
170 (fl)->mesh, \
171 (fl)->clusters, \
172 (fl)->dither, \
173 (fl)->debug, \
174 (fl)->threshold, \
175 (fl)->working, \
176 (fl)->input, \
177 (fl)->state \
179 //#undef debug_find_lines
180 //#define debug_find_lines(x) /* */
183 #endif /*have this .h*/