cheat with wait_for_play by using shared variable
[sparrow.git] / edges.h
blob564c21ec31d6c5063a7e8cd7c5bcd60c5ab2d0a0
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,
26 EDGES_WAIT_FOR_PLAY,
28 EDGES_NEXT_STATE,
29 } edges_state_t;
31 typedef struct sparrow_corner_s {
32 int in_x;
33 int in_y;
34 /*dyr -> dy to next point right
35 dxd ->dx to next point down */
36 int dxr;
37 int dyr;
38 int dxd;
39 int dyd;
40 corner_status_t status;
41 } sparrow_corner_t;
43 typedef struct sparrow_voter_s {
44 int x;
45 int y;
46 guint32 signal;
47 } sparrow_voter_t;
49 typedef struct sparrow_cluster_s {
50 int n;
51 sparrow_voter_t voters[8];
52 } sparrow_cluster_t;
55 typedef union sparrow_signal_s {
56 guint16 v_signal;
57 guint16 h_signal;
58 } sparrow_signal_t;
61 typedef struct sparrow_intersect_s {
62 guint16 lines[2];
63 guint16 signal[2];
64 } sparrow_intersect_t;
66 typedef struct sparrow_line_s {
67 gint offset;
68 sparrow_axis_t dir;
69 gint index;
70 } sparrow_line_t;
72 /*condensed version of <struct sparrow_find_lines_s> for saving: contains no
73 pointers or other unnecessary things that might vary in size across
74 architectures. */
75 typedef struct sparrow_fl_condensed {
76 gint32 n_vlines;
77 gint32 n_hlines;
78 } sparrow_fl_condensed_t;
80 typedef struct sparrow_find_lines_s {
81 sparrow_line_t *h_lines;
82 sparrow_line_t *v_lines;
83 sparrow_line_t **shuffled_lines;
84 int current;
85 int n_lines;
86 int n_vlines;
87 int n_hlines;
88 gint shift1;
89 gint shift2;
90 sparrow_intersect_t *map;
91 sparrow_corner_t *mesh;
92 sparrow_cluster_t *clusters;
93 IplImage *debug;
94 IplImage *threshold;
95 IplImage *working;
96 IplImage *input;
97 edges_state_t state;
98 } sparrow_find_lines_t;
101 #define DEBUG_FIND_LINES(fl)GST_DEBUG( \
102 "fl:\n" \
103 " sparrow_line_t *h_lines: %p\n" \
104 " sparrow_line_t *v_lines: %p\n" \
105 " sparrow_line_t **shuffled_lines: %p\n" \
106 " int current: %d\n" \
107 " int n_lines: %d\n" \
108 " int n_vlines: %d\n" \
109 " int n_hlines: %d\n" \
110 " gint shift1: %d\n" \
111 " gint shift2: %d\n" \
112 " sparrow_intersect_t *map: %p\n" \
113 " sparrow_corner_t *mesh: %p\n" \
114 " sparrow_cluster_t *clusters: %p\n" \
115 " IplImage *debug: %p\n" \
116 " IplImage *threshold: %p\n" \
117 " IplImage *working: %p\n" \
118 " IplImage *input: %p\n" \
119 " edges_state_t state: %d\n" \
121 (fl)->h_lines, \
122 (fl)->v_lines, \
123 (fl)->shuffled_lines, \
124 (fl)->current, \
125 (fl)->n_lines, \
126 (fl)->n_vlines, \
127 (fl)->n_hlines, \
128 (fl)->shift1, \
129 (fl)->shift2, \
130 (fl)->map, \
131 (fl)->mesh, \
132 (fl)->clusters, \
133 (fl)->debug, \
134 (fl)->threshold, \
135 (fl)->working, \
136 (fl)->input, \
137 (fl)->state \
139 //#undef debug_find_lines
140 //#define debug_find_lines(x) /* */
143 #endif /*have this .h*/