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