39 #define PRINT(string,...) fprintf(stderr, "[object_detector->%s()] " string,__FUNCTION__ , ##__VA_ARGS__)
40 #if OBJECT_DETECTOR_VERBOSE
41 #define VERBOSE_PRINT PRINT
43 #define VERBOSE_PRINT(...)
48 #ifndef COLOR_OBJECT_DETECTOR_FPS1
49 #define COLOR_OBJECT_DETECTOR_FPS1 0
51 #ifndef COLOR_OBJECT_DETECTOR_FPS2
52 #define COLOR_OBJECT_DETECTOR_FPS2 0
128 VERBOSE_PRINT(
"Color count %d: %u, threshold %u, x_c %d, y_c %d\n", camera, object_count, count_threshold, x_c, y_c);
129 VERBOSE_PRINT(
"centroid %d: (%d, %d) r: %4.2f a: %4.2f\n", camera, x_c, y_c,
130 hypotf(x_c, y_c) / hypotf(img->
w * 0.5, img->
h * 0.5), RadOfDeg(atan2f(y_c, x_c)));
132 pthread_mutex_lock(&
mutex);
137 pthread_mutex_unlock(&
mutex);
157 pthread_mutex_init(&
mutex, NULL);
158 #ifdef COLOR_OBJECT_DETECTOR_CAMERA1
159 #ifdef COLOR_OBJECT_DETECTOR_LUM_MIN1
167 #ifdef COLOR_OBJECT_DETECTOR_DRAW1
174 #ifdef COLOR_OBJECT_DETECTOR_CAMERA2
175 #ifdef COLOR_OBJECT_DETECTOR_LUM_MIN2
183 #ifdef COLOR_OBJECT_DETECTOR_DRAW2
226 up = &buffer[y * 2 * img->
w + 2 * x];
227 yp = &buffer[y * 2 * img->
w + 2 * x + 1];
228 vp = &buffer[y * 2 * img->
w + 2 * x + 2];
232 up = &buffer[y * 2 * img->
w + 2 * x - 2];
234 vp = &buffer[y * 2 * img->
w + 2 * x];
235 yp = &buffer[y * 2 * img->
w + 2 * x + 1];
237 if ( (*yp >= lum_min) && (*yp <= lum_max) &&
238 (*
up >= cb_min ) && (*
up <= cb_max ) &&
239 (*vp >= cr_min ) && (*vp <= cr_max )) {
250 *p_xc = (
int32_t)roundf(tot_x / ((
float) cnt) - img->
w * 0.5f);
251 *p_yc = (
int32_t)roundf(img->
h * 0.5f - tot_y / ((
float) cnt));
262 pthread_mutex_lock(&
mutex);
264 pthread_mutex_unlock(&
mutex);
269 local_filters[0].
updated =
false;
274 local_filters[1].
updated =
false;
Main include for ABI (AirBorneInterface).
#define COLOR_OBJECT_DETECTION1_ID
#define COLOR_OBJECT_DETECTION2_ID
struct video_listener * cv_add_to_device(struct video_config_t *device, cv_function func, uint16_t fps, uint8_t id)
Computer vision framework for onboard processing.
#define VERBOSE_PRINT(...)
static struct image_t * object_detector(struct image_t *img, uint8_t filter)
#define COLOR_OBJECT_DETECTOR_FPS1
Default FPS (zero means run at camera fps)
static pthread_mutex_t mutex
#define COLOR_OBJECT_DETECTOR_FPS2
Default FPS (zero means run at camera fps)
struct image_t * object_detector2(struct image_t *img, uint8_t camera_id)
void color_object_detector_periodic(void)
void color_object_detector_init(void)
struct color_object_t global_filters[2]
uint32_t find_object_centroid(struct image_t *img, int32_t *p_xc, int32_t *p_yc, bool draw, uint8_t lum_min, uint8_t lum_max, uint8_t cb_min, uint8_t cb_max, uint8_t cr_min, uint8_t cr_max)
struct image_t * object_detector1(struct image_t *img, uint8_t camera_id)
Assumes the color_object consists of a continuous color and checks if you are over the defined color_...
void * buf
Image buffer (depending on the image_type)
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.