use a simple point structure for median_centre to shut up warnings
[sparrow.git] / edges.h
blobf5c0c4c5394a8c7a9b4bf32372643e2d73c72cae
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 */
20 typedef enum corner_status {
21 CORNER_UNUSED,
22 CORNER_PROJECTED,
23 CORNER_EXACT,
24 CORNER_SETTLED,
25 } corner_status_t;
27 typedef enum edges_state {
28 EDGES_FIND_NOISE,
29 EDGES_FIND_LINES,
30 EDGES_FIND_CORNERS,
31 EDGES_WAIT_FOR_PLAY,
33 EDGES_NEXT_STATE,
34 } edges_state_t;
36 #define USE_FLOAT_COORDS 1
38 #if USE_FLOAT_COORDS
39 typedef float coord_t;
40 typedef float coord_sum_t;
41 #define QUANTISE_DELTA(d)((d) / LINE_PERIOD)
43 #else
44 /* the mesh is stored in a fixed point notation.*/
45 #define SPARROW_FIXED_POINT 9
47 typedef int coord_t;
48 typedef gint64 coord_sum_t;
49 #define QUANTISE_DELTA(d)(((d) + LINE_PERIOD / 2) / LINE_PERIOD)
51 #endif
53 typedef struct sparrow_estimator_s {
54 int x1;
55 int y1;
56 int x2;
57 int y2;
58 int x3;
59 int y3;
60 //int mul; /* estimate: x1,y1 + mul * diff */
61 } sparrow_estimator_t;
63 typedef struct sparrow_corner_s {
64 coord_t x;
65 coord_t y;
66 /*dyr -> dy to next point right
67 dxd ->dx to next point down */
68 coord_t dxr;
69 coord_t dyr;
70 coord_t dxd;
71 coord_t dyd;
72 corner_status_t status;
73 } sparrow_corner_t;
75 typedef struct sparrow_voter_s {
76 coord_t x;
77 coord_t y;
78 guint32 signal;
79 } sparrow_voter_t;
81 typedef struct sparrow_point_s {
82 coord_t x;
83 coord_t y;
84 } sparrow_point_t;
86 typedef struct sparrow_cluster_s {
87 int n;
88 sparrow_voter_t voters[8];
89 } sparrow_cluster_t;
92 typedef union sparrow_signal_s {
93 guint16 v_signal;
94 guint16 h_signal;
95 } sparrow_signal_t;
98 typedef struct sparrow_intersect_s {
99 guint16 lines[2];
100 guint16 signal[2];
101 } sparrow_intersect_t;
103 typedef struct sparrow_line_s {
104 gint offset;
105 sparrow_axis_t dir;
106 gint index;
107 } sparrow_line_t;
109 /*condensed version of <struct sparrow_find_lines_s> for saving: contains no
110 pointers or other unnecessary things that might vary in size across
111 architectures. */
112 typedef struct sparrow_fl_condensed {
113 gint32 n_vlines;
114 gint32 n_hlines;
115 } sparrow_fl_condensed_t;
117 typedef struct sparrow_find_lines_s {
118 sparrow_line_t *h_lines;
119 sparrow_line_t *v_lines;
120 sparrow_line_t **shuffled_lines;
121 int current;
122 int n_lines;
123 int n_vlines;
124 int n_hlines;
125 gint shift1;
126 gint shift2;
127 sparrow_intersect_t *map;
128 sparrow_corner_t *mesh_mem;
129 sparrow_corner_t *mesh;
130 sparrow_corner_t *mesh_next;
131 sparrow_cluster_t *clusters;
132 IplImage *debug;
133 IplImage *threshold;
134 IplImage *working;
135 IplImage *input;
136 edges_state_t state;
137 } sparrow_find_lines_t;
140 #define DEBUG_FIND_LINES(fl)GST_DEBUG( \
141 "fl:\n" \
142 " sparrow_line_t *h_lines: %p\n" \
143 " sparrow_line_t *v_lines: %p\n" \
144 " sparrow_line_t **shuffled_lines: %p\n" \
145 " int current: %d\n" \
146 " int n_lines: %d\n" \
147 " int n_vlines: %d\n" \
148 " int n_hlines: %d\n" \
149 " gint shift1: %d\n" \
150 " gint shift2: %d\n" \
151 " sparrow_intersect_t *map: %p\n" \
152 " sparrow_corner_t *mesh: %p\n" \
153 " sparrow_cluster_t *clusters: %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)->debug, \
173 (fl)->threshold, \
174 (fl)->working, \
175 (fl)->input, \
176 (fl)->state \
178 //#undef debug_find_lines
179 //#define debug_find_lines(x) /* */
182 #endif /*have this .h*/