37#include "generated/airframe.h"
44#define MAX_N_TEXTONS 255
57#ifndef TEXTONS_LOAD_DICTIONARY
58#define TEXTONS_LOAD_DICTIONARY 1
62#ifndef TEXTONS_REINITIALIZE_DICTIONARY
63#define TEXTONS_REINITIALIZE_DICTIONARY 0
68#define TEXTONS_ALPHA 0
72#ifndef TEXTONS_N_TEXTONS
73#define TEXTONS_N_TEXTONS 20
77#ifndef TEXTONS_N_SAMPLES
78#define TEXTONS_N_SAMPLES 250
82#ifndef TEXTONS_PATCH_SIZE
83#define TEXTONS_PATCH_SIZE 6
87#ifndef TEXTONS_N_LEARNING_SAMPLES
88#define TEXTONS_N_LEARNING_SAMPLES 5000
92#ifndef TEXTONS_FULL_SAMPLING
93#define TEXTONS_FULL_SAMPLING 0
97#ifndef TEXTONS_BORDER_WIDTH
98#define TEXTONS_BORDER_WIDTH 0
102#ifndef TEXTONS_BORDER_HEIGHT
103#define TEXTONS_BORDER_HEIGHT 0
107#ifndef TEXTONS_DICTIONARY_NUMBER
108#define TEXTONS_DICTIONARY_NUMBER 0
112#ifndef TEXTONS_DICTIONARY_PATH
113#define TEXTONS_DICTIONARY_PATH /data/ftp/internal_000
149 if (
img->buf_size == 0) {
return img; }
186 printf(
"Enough learning!\n");
244 printf(
"Intializing dictionary!\n");
255 buf =
frame + (width * 2 * (i + y)) + 2 * x;
258 printf(
"Setting dictionary:\n");
302 buf =
frame + (width * 2 * (i + y)) + 2 * x;
316 for (c = 0; c < 2; c++) {
339 for (c = 0; c < 2; c++) {
411 buf =
frame + (width * 2 * (i + y)) + 2 * x;
425 for (c = 0; c < 2; c++) {
513 perror(
"Error while opening the file.\n");
598 for (i = 0; i <
D; i++) {
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.
void * buf
Image buffer (depending on the image_type)
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
Architecture independent timing functions.
void save_texton_dictionary(void)
Save the texton dictionary.
struct video_listener * listener
void load_texton_dictionary(void)
Load a texton dictionary.
float * texton_distribution
#define TEXTONS_PATCH_SIZE
uint32_t n_learning_samples
#define TEXTONS_DICTIONARY_NUMBER
#define TEXTONS_N_TEXTONS
void DictionaryTrainingYUV(uint8_t *frame, uint16_t width, uint16_t height)
Function that performs one pass for dictionary training.
static FILE * dictionary_logger
float get_entropy(float *p_dist, int D)
Function that calculates a base-2 Shannon entropy for a probability distribution.
#define TEXTONS_DICTIONARY_PATH
uint8_t dictionary_initialized
#define TEXTONS_LOAD_DICTIONARY
uint8_t reinitialize_dictionary
#define TEXTONS_BORDER_HEIGHT
void textons_init(void)
Initialize.
void DistributionExtraction(uint8_t *frame, uint16_t width, uint16_t height)
Function that extracts a texton histogram from an image.
#define TEXTONS_N_LEARNING_SAMPLES
#define TEXTONS_BORDER_WIDTH
uint8_t dictionary_number
#define TEXTONS_N_SAMPLES
#define TEXTONS_REINITIALIZE_DICTIONARY
struct image_t * texton_func(struct image_t *img, UNUSED uint8_t p)
Main texton processing function that first either loads or learns a dictionary and then extracts the ...
#define TEXTONS_FULL_SAMPLING
Takes an image and represents the texture and colors in the image with a texton histogram.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.