Revision 466
fixed vision bug
vision.c | ||
---|---|---|
127 | 127 |
found=1; |
128 | 128 |
break; |
129 | 129 |
} |
130 |
}
|
|
130 |
}
|
|
131 | 131 |
|
132 | 132 |
if (!found){ |
133 | 133 |
struct CenterP c; |
... | ... | |
148 | 148 |
image04 = cvCloneImage(image03); |
149 | 149 |
|
150 | 150 |
int count = 0; |
151 |
|
|
152 | 151 |
int i; |
153 | 152 |
for (i = 0; i < index; i++) { |
154 | 153 |
if (bestc[i].count > 7){ |
... | ... | |
156 | 155 |
} |
157 | 156 |
} |
158 | 157 |
|
159 |
VisionPosition* pos = (VisionPosition*)malloc(sizeof(VisionPosition) * count); |
|
158 |
VisionPosition* pos_array = (VisionPosition*)malloc(sizeof(VisionPosition) * count); |
|
159 |
if (pos_array == NULL) { |
|
160 |
fprintf(stderr, "malloc failed\n"); |
|
161 |
return -1; |
|
162 |
} |
|
163 |
|
|
164 |
int c = 0; |
|
160 | 165 |
for (i = 0; i < index; i++) { |
161 | 166 |
if (bestc[i].count > 7){ |
162 |
pos[i].x = bestc[i].center.x; |
|
163 |
pos[i].y = bestc[i].center.y; |
|
167 |
pos_array[c].x = bestc[i].center.x; |
|
168 |
pos_array[c].y = bestc[i].center.y; |
|
169 |
c++; |
|
164 | 170 |
|
165 |
if (DEBUG) cvCircle(image04,bestc[i].center, 20, CV_RGB(0,0,0),5,8,0);
|
|
171 |
if (DEBUG) cvCircle(image04, bestc[i].center, 20, CV_RGB(0,0,0), 5, 8, 0);
|
|
166 | 172 |
} |
167 | 173 |
} |
168 | 174 |
|
169 | 175 |
// Show image. HighGUI use. |
170 | 176 |
if (DEBUG) cvShowImage( "Result", image04 ); |
171 | 177 |
|
172 |
*positions = pos; |
|
178 |
*positions = pos_array;
|
|
173 | 179 |
return count; |
174 | 180 |
} |
Also available in: Unified diff