various clean-ups around new coord_t
[sparrow.git] / edges.h
blob302ad78a4dbe6da25e675aeaac74f1ca35250727
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_cluster_s {
82 int n;
83 sparrow_voter_t voters[8];
84 } sparrow_cluster_t;
87 typedef union sparrow_signal_s {
88 guint16 v_signal;
89 guint16 h_signal;
90 } sparrow_signal_t;
93 typedef struct sparrow_intersect_s {
94 guint16 lines[2];
95 guint16 signal[2];
96 } sparrow_intersect_t;
98 typedef struct sparrow_line_s {
99 gint offset;
100 sparrow_axis_t dir;
101 gint index;
102 } sparrow_line_t;
104 /*condensed version of <struct sparrow_find_lines_s> for saving: contains no
105 pointers or other unnecessary things that might vary in size across
106 architectures. */
107 typedef struct sparrow_fl_condensed {
108 gint32 n_vlines;
109 gint32 n_hlines;
110 } sparrow_fl_condensed_t;
112 typedef struct sparrow_find_lines_s {
113 sparrow_line_t *h_lines;
114 sparrow_line_t *v_lines;
115 sparrow_line_t **shuffled_lines;
116 int current;
117 int n_lines;
118 int n_vlines;
119 int n_hlines;
120 gint shift1;
121 gint shift2;
122 sparrow_intersect_t *map;
123 sparrow_corner_t *mesh_mem;
124 sparrow_corner_t *mesh;
125 sparrow_corner_t *mesh_next;
126 sparrow_cluster_t *clusters;
127 IplImage *debug;
128 IplImage *threshold;
129 IplImage *working;
130 IplImage *input;
131 edges_state_t state;
132 } sparrow_find_lines_t;
135 #define DEBUG_FIND_LINES(fl)GST_DEBUG( \
136 "fl:\n" \
137 " sparrow_line_t *h_lines: %p\n" \
138 " sparrow_line_t *v_lines: %p\n" \
139 " sparrow_line_t **shuffled_lines: %p\n" \
140 " int current: %d\n" \
141 " int n_lines: %d\n" \
142 " int n_vlines: %d\n" \
143 " int n_hlines: %d\n" \
144 " gint shift1: %d\n" \
145 " gint shift2: %d\n" \
146 " sparrow_intersect_t *map: %p\n" \
147 " sparrow_corner_t *mesh: %p\n" \
148 " sparrow_cluster_t *clusters: %p\n" \
149 " IplImage *debug: %p\n" \
150 " IplImage *threshold: %p\n" \
151 " IplImage *working: %p\n" \
152 " IplImage *input: %p\n" \
153 " edges_state_t state: %d\n" \
155 (fl)->h_lines, \
156 (fl)->v_lines, \
157 (fl)->shuffled_lines, \
158 (fl)->current, \
159 (fl)->n_lines, \
160 (fl)->n_vlines, \
161 (fl)->n_hlines, \
162 (fl)->shift1, \
163 (fl)->shift2, \
164 (fl)->map, \
165 (fl)->mesh, \
166 (fl)->clusters, \
167 (fl)->debug, \
168 (fl)->threshold, \
169 (fl)->working, \
170 (fl)->input, \
171 (fl)->state \
173 //#undef debug_find_lines
174 //#define debug_find_lines(x) /* */
177 #endif /*have this .h*/