mark bad pixels in debug images (blue)
[sparrow.git] / edges.h
blob25b24bc032def073b593b6c094b55cc7956450ff
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"
16 typedef enum corner_status {
17 CORNER_UNUSED,
18 CORNER_PROJECTED,
19 CORNER_EXACT,
20 } corner_status_t;
22 typedef enum edges_state {
23 EDGES_FIND_NOISE,
24 EDGES_FIND_LINES,
25 EDGES_FIND_CORNERS,
27 EDGES_NEXT_STATE,
28 } edges_state_t;
30 typedef struct sparrow_corner_s {
31 int in_x;
32 int in_y;
33 /*dyr -> dy to next point right
34 dxd ->dx to next point down */
35 int dxr;
36 int dyr;
37 int dxd;
38 int dyd;
39 corner_status_t status;
40 } sparrow_corner_t;
42 typedef struct sparrow_voter_s {
43 int x;
44 int y;
45 guint32 signal;
46 } sparrow_voter_t;
48 typedef struct sparrow_cluster_s {
49 int n;
50 sparrow_voter_t voters[8];
51 } sparrow_cluster_t;
54 typedef union sparrow_signal_s {
55 guint16 v_signal;
56 guint16 h_signal;
57 } sparrow_signal_t;
60 typedef struct sparrow_intersect_s {
61 guint16 lines[2];
62 guint16 signal[2];
63 } sparrow_intersect_t;
65 typedef struct sparrow_line_s {
66 gint offset;
67 sparrow_axis_t dir;
68 gint index;
69 } sparrow_line_t;
71 /*condensed version of <struct sparrow_find_lines_s> for saving: contains no
72 pointers or other unnecessary things that might vary in size across
73 architectures. */
74 typedef struct sparrow_fl_condensed {
75 gint32 n_vlines;
76 gint32 n_hlines;
77 } sparrow_fl_condensed_t;
79 typedef struct sparrow_find_lines_s {
80 sparrow_line_t *h_lines;
81 sparrow_line_t *v_lines;
82 sparrow_line_t **shuffled_lines;
83 int current;
84 int n_lines;
85 int n_vlines;
86 int n_hlines;
87 gint shift1;
88 gint shift2;
89 sparrow_intersect_t *map;
90 sparrow_corner_t *mesh;
91 sparrow_cluster_t *clusters;
92 IplImage *debug;
93 IplImage *threshold;
94 IplImage *working;
95 IplImage *input;
96 edges_state_t state;
97 } sparrow_find_lines_t;
100 #define DEBUG_FIND_LINES(fl)GST_DEBUG( \
101 "fl:\n" \
102 " sparrow_line_t *h_lines: %p\n" \
103 " sparrow_line_t *v_lines: %p\n" \
104 " sparrow_line_t **shuffled_lines: %p\n" \
105 " int current: %d\n" \
106 " int n_lines: %d\n" \
107 " int n_vlines: %d\n" \
108 " int n_hlines: %d\n" \
109 " gint shift1: %d\n" \
110 " gint shift2: %d\n" \
111 " sparrow_intersect_t *map: %p\n" \
112 " sparrow_corner_t *mesh: %p\n" \
113 " sparrow_cluster_t *clusters: %p\n" \
114 " IplImage *debug: %p\n" \
115 " IplImage *threshold: %p\n" \
116 " IplImage *working: %p\n" \
117 " IplImage *input: %p\n" \
118 " edges_state_t state: %d\n" \
120 (fl)->h_lines, \
121 (fl)->v_lines, \
122 (fl)->shuffled_lines, \
123 (fl)->current, \
124 (fl)->n_lines, \
125 (fl)->n_vlines, \
126 (fl)->n_hlines, \
127 (fl)->shift1, \
128 (fl)->shift2, \
129 (fl)->map, \
130 (fl)->mesh, \
131 (fl)->clusters, \
132 (fl)->debug, \
133 (fl)->threshold, \
134 (fl)->working, \
135 (fl)->input, \
136 (fl)->state \
138 //#undef debug_find_lines
139 //#define debug_find_lines(x) /* */
142 #endif /*have this .h*/