use alternating buffers for mesh
[sparrow.git] / edges.h
blob9ad11069c8efde26c1563cfc5d82bbd5a4e5d85a
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 #else
41 typedef int coord_t;
42 #endif
44 typedef struct sparrow_estimator_s {
45 int x1;
46 int y1;
47 int x2;
48 int y2;
49 int x3;
50 int y3;
51 //int mul; /* estimate: x1,y1 + mul * diff */
52 } sparrow_estimator_t;
54 typedef struct sparrow_corner_s {
55 coord_t x;
56 coord_t y;
57 /*dyr -> dy to next point right
58 dxd ->dx to next point down */
59 coord_t dxr;
60 coord_t dyr;
61 coord_t dxd;
62 coord_t dyd;
63 corner_status_t status;
64 } sparrow_corner_t;
66 typedef struct sparrow_voter_s {
67 coord_t x;
68 coord_t y;
69 guint32 signal;
70 } sparrow_voter_t;
72 typedef struct sparrow_cluster_s {
73 int n;
74 sparrow_voter_t voters[8];
75 } sparrow_cluster_t;
78 typedef union sparrow_signal_s {
79 guint16 v_signal;
80 guint16 h_signal;
81 } sparrow_signal_t;
84 typedef struct sparrow_intersect_s {
85 guint16 lines[2];
86 guint16 signal[2];
87 } sparrow_intersect_t;
89 typedef struct sparrow_line_s {
90 gint offset;
91 sparrow_axis_t dir;
92 gint index;
93 } sparrow_line_t;
95 /*condensed version of <struct sparrow_find_lines_s> for saving: contains no
96 pointers or other unnecessary things that might vary in size across
97 architectures. */
98 typedef struct sparrow_fl_condensed {
99 gint32 n_vlines;
100 gint32 n_hlines;
101 } sparrow_fl_condensed_t;
103 typedef struct sparrow_find_lines_s {
104 sparrow_line_t *h_lines;
105 sparrow_line_t *v_lines;
106 sparrow_line_t **shuffled_lines;
107 int current;
108 int n_lines;
109 int n_vlines;
110 int n_hlines;
111 gint shift1;
112 gint shift2;
113 sparrow_intersect_t *map;
114 sparrow_corner_t *mesh_mem;
115 sparrow_corner_t *mesh;
116 sparrow_corner_t *mesh_next;
117 sparrow_cluster_t *clusters;
118 IplImage *debug;
119 IplImage *threshold;
120 IplImage *working;
121 IplImage *input;
122 edges_state_t state;
123 } sparrow_find_lines_t;
126 #define DEBUG_FIND_LINES(fl)GST_DEBUG( \
127 "fl:\n" \
128 " sparrow_line_t *h_lines: %p\n" \
129 " sparrow_line_t *v_lines: %p\n" \
130 " sparrow_line_t **shuffled_lines: %p\n" \
131 " int current: %d\n" \
132 " int n_lines: %d\n" \
133 " int n_vlines: %d\n" \
134 " int n_hlines: %d\n" \
135 " gint shift1: %d\n" \
136 " gint shift2: %d\n" \
137 " sparrow_intersect_t *map: %p\n" \
138 " sparrow_corner_t *mesh: %p\n" \
139 " sparrow_cluster_t *clusters: %p\n" \
140 " IplImage *debug: %p\n" \
141 " IplImage *threshold: %p\n" \
142 " IplImage *working: %p\n" \
143 " IplImage *input: %p\n" \
144 " edges_state_t state: %d\n" \
146 (fl)->h_lines, \
147 (fl)->v_lines, \
148 (fl)->shuffled_lines, \
149 (fl)->current, \
150 (fl)->n_lines, \
151 (fl)->n_vlines, \
152 (fl)->n_hlines, \
153 (fl)->shift1, \
154 (fl)->shift2, \
155 (fl)->map, \
156 (fl)->mesh, \
157 (fl)->clusters, \
158 (fl)->debug, \
159 (fl)->threshold, \
160 (fl)->working, \
161 (fl)->input, \
162 (fl)->state \
164 //#undef debug_find_lines
165 //#define debug_find_lines(x) /* */
168 #endif /*have this .h*/