Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
Takes an image and represents the texture and colors in the image with a texton histogram. More...
#include <stdlib.h>
#include <stdio.h>
#include "modules/computer_vision/cv.h"
#include "modules/computer_vision/textons.h"
#include "mcu_periph/sys_time.h"
#include "generated/airframe.h"
Go to the source code of this file.
Macros | |
#define | MAX_N_TEXTONS 255 |
#define | TEXTONS_RUN 1 |
#define | TEXTONS_FPS 30 |
#define | TEXTONS_LOAD_DICTIONARY 1 |
#define | TEXTONS_REINITIALIZE_DICTIONARY 0 |
#define | TEXTONS_ALPHA 0 |
#define | TEXTONS_N_TEXTONS 20 |
#define | TEXTONS_N_SAMPLES 250 |
#define | TEXTONS_PATCH_SIZE 6 |
#define | TEXTONS_N_LEARNING_SAMPLES 5000 |
#define | TEXTONS_FULL_SAMPLING 0 |
#define | TEXTONS_BORDER_WIDTH 0 |
#define | TEXTONS_BORDER_HEIGHT 0 |
#define | TEXTONS_DICTIONARY_NUMBER 0 |
#define | TEXTONS_DICTIONARY_PATH /data/ftp/internal_000 |
Functions | |
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 texton histogram. More... | |
void | DictionaryTrainingYUV (uint8_t *frame, uint16_t width, uint16_t height) |
Function that performs one pass for dictionary training. More... | |
void | DistributionExtraction (uint8_t *frame, uint16_t width, uint16_t height) |
Function that extracts a texton histogram from an image. More... | |
void | save_texton_dictionary (void) |
Save the texton dictionary. More... | |
void | load_texton_dictionary (void) |
Load a texton dictionary. More... | |
void | textons_init (void) |
Initialize. More... | |
void | textons_stop (void) |
float | get_entropy (float *p_dist, int D) |
Function that calculates a base-2 Shannon entropy for a probability distribution. More... | |
Variables | |
float **** | dictionary |
uint32_t | learned_samples = 0 |
uint8_t | dictionary_initialized = 0 |
float * | texton_distribution |
struct video_listener * | listener = NULL |
uint8_t | running = TEXTONS_RUN |
uint8_t | load_dictionary = TEXTONS_LOAD_DICTIONARY |
uint8_t | reinitialize_dictionary = TEXTONS_REINITIALIZE_DICTIONARY |
uint8_t | alpha_uint = TEXTONS_ALPHA |
uint8_t | n_textons = TEXTONS_N_TEXTONS |
uint8_t | patch_size = TEXTONS_PATCH_SIZE |
uint32_t | n_learning_samples = TEXTONS_N_LEARNING_SAMPLES |
uint32_t | n_samples_image = TEXTONS_N_SAMPLES |
uint8_t | FULL_SAMPLING = TEXTONS_FULL_SAMPLING |
uint32_t | border_width = TEXTONS_BORDER_WIDTH |
uint32_t | border_height = TEXTONS_BORDER_HEIGHT |
uint8_t | dictionary_number = TEXTONS_DICTIONARY_NUMBER |
uint8_t | dictionary_ready = 0 |
float | alpha = 0.0 |
static FILE * | dictionary_logger = NULL |
Takes an image and represents the texture and colors in the image with a texton histogram.
A texton is a cluster centroid in a space populated by image patches. First, this code learns or loads a texton dictionary. Then, for each incoming image, patches are sampled from the image, compared to textons in the dictionary, and the closest texton is identified, augmenting the corresponding bin in the texton histogram.
Definition in file textons.c.
Function that performs one pass for dictionary training.
It extracts samples from an image, finds the closest texton and moves it towards the sample.
[in] | frame* | The YUV image data |
[in] | width | The width of the image |
[in] | height | The height of the image |
Definition at line 227 of file textons.c.
References alpha, alpha_uint, image_t::buf, dictionary, dictionary_initialized, frame, learned_samples, n_samples_image, n_textons, patch_size, s, and image_t::w.
Referenced by texton_func().
Function that extracts a texton histogram from an image.
[in] | frame* | The YUV image data |
[in] | width | The width of the image |
[in] | height | The height of the image |
Definition at line 372 of file textons.c.
References border_height, border_width, image_t::buf, dictionary, frame, FULL_SAMPLING, n_samples_image, n_textons, patch_size, and texton_distribution.
Referenced by texton_func().
float get_entropy | ( | float * | p_dist, |
int | D | ||
) |
void load_texton_dictionary | ( | void | ) |
Load a texton dictionary.
Definition at line 532 of file textons.c.
References dictionary, dictionary_initialized, dictionary_logger, dictionary_number, dictionary_ready, learned_samples, load_dictionary, n_textons, patch_size, and TEXTONS_DICTIONARY_PATH.
Referenced by texton_func().
void save_texton_dictionary | ( | void | ) |
Save the texton dictionary.
Definition at line 501 of file textons.c.
References dictionary, dictionary_logger, dictionary_number, n_textons, patch_size, and TEXTONS_DICTIONARY_PATH.
Referenced by texton_func().
Main texton processing function that first either loads or learns a dictionary and then extracts the texton histogram.
[out] | *img | The output image |
[in] | *img | The input image (YUV422) |
Definition at line 144 of file textons.c.
References alpha, alpha_uint, image_t::buf, image_t::buf_size, dictionary_initialized, dictionary_ready, DictionaryTrainingYUV(), DistributionExtraction(), frame, image_t::h, if(), learned_samples, load_dictionary, load_texton_dictionary(), n_learning_samples, patch_size, reinitialize_dictionary, running, save_texton_dictionary(), and image_t::w.
Referenced by textons_init().
void textons_init | ( | void | ) |
Initialize.
Definition at line 562 of file textons.c.
References cv_add_to_device(), dictionary, dictionary_initialized, dictionary_ready, learned_samples, listener, MAX_N_TEXTONS, patch_size, texton_distribution, texton_func(), TEXTONS_FPS, and image_t::w.
void textons_stop | ( | void | ) |
Definition at line 583 of file textons.c.
References dictionary, and texton_distribution.
float alpha = 0.0 |
Definition at line 133 of file textons.c.
Referenced by ahrs_fc_propagate(), ahrs_mlkf_update_accel(), baro_cb(), compute_1e_filter_lp(), compute_ground_speed(), DictionaryTrainingYUV(), gvf_ellipse_info(), gvf_ellipse_wp(), gvf_ellipse_XY(), gvf_line_info(), gvf_parametric_2D_trefoil_wp(), gvf_parametric_2D_trefoil_XY(), gvf_segment_loop_XY1_XY2(), gvf_sin_info(), gvf_sin_wp1_wp2(), gvf_sin_wp_alpha(), gvf_sin_XY_alpha(), indi_apply_compensator_filters(), ins_float_invariant_update_baro(), mtostk_apply_polynomial_temp(), nav_cube_setup(), nav_hybrid_circle(), nps_fdm_run_step(), out_of_segment_area(), process_new_point_rosette(), propagate_ref(), snav_init(), texton_func(), update_target_point(), and wls_alloc().
uint8_t alpha_uint = TEXTONS_ALPHA |
Definition at line 121 of file textons.c.
Referenced by DictionaryTrainingYUV(), and texton_func().
uint32_t border_height = TEXTONS_BORDER_HEIGHT |
Definition at line 128 of file textons.c.
Referenced by DistributionExtraction().
uint32_t border_width = TEXTONS_BORDER_WIDTH |
Definition at line 127 of file textons.c.
Referenced by DistributionExtraction().
float** ** dictionary |
Definition at line 39 of file textons.c.
Referenced by DictionaryTrainingYUV(), DistributionExtraction(), load_texton_dictionary(), save_texton_dictionary(), textons_init(), and textons_stop().
uint8_t dictionary_initialized = 0 |
Definition at line 41 of file textons.c.
Referenced by DictionaryTrainingYUV(), load_texton_dictionary(), texton_func(), and textons_init().
|
static |
Definition at line 136 of file textons.c.
Referenced by load_texton_dictionary(), and save_texton_dictionary().
uint8_t dictionary_number = TEXTONS_DICTIONARY_NUMBER |
Definition at line 129 of file textons.c.
Referenced by load_texton_dictionary(), and save_texton_dictionary().
uint8_t dictionary_ready = 0 |
Definition at line 132 of file textons.c.
Referenced by load_texton_dictionary(), texton_func(), and textons_init().
uint8_t FULL_SAMPLING = TEXTONS_FULL_SAMPLING |
Definition at line 126 of file textons.c.
Referenced by DistributionExtraction().
uint32_t learned_samples = 0 |
Definition at line 40 of file textons.c.
Referenced by DictionaryTrainingYUV(), load_texton_dictionary(), texton_func(), and textons_init().
struct video_listener* listener = NULL |
Definition at line 116 of file textons.c.
Referenced by textons_init().
uint8_t load_dictionary = TEXTONS_LOAD_DICTIONARY |
Definition at line 119 of file textons.c.
Referenced by load_texton_dictionary(), and texton_func().
uint32_t n_learning_samples = TEXTONS_N_LEARNING_SAMPLES |
Definition at line 124 of file textons.c.
Referenced by texton_func().
uint32_t n_samples_image = TEXTONS_N_SAMPLES |
Definition at line 125 of file textons.c.
Referenced by DictionaryTrainingYUV(), and DistributionExtraction().
uint8_t n_textons = TEXTONS_N_TEXTONS |
Definition at line 122 of file textons.c.
Referenced by DictionaryTrainingYUV(), DistributionExtraction(), learn_from_file(), load_texton_dictionary(), load_texton_distribution(), load_weights(), optical_flow_landing_init(), predict_gain(), recursive_least_squares_batch(), save_texton_dictionary(), save_texton_distribution(), and save_weights().
uint8_t patch_size = TEXTONS_PATCH_SIZE |
Definition at line 123 of file textons.c.
Referenced by DictionaryTrainingYUV(), DistributionExtraction(), load_texton_dictionary(), opticFlowLK(), opticFlowLK_flat(), save_texton_dictionary(), texton_func(), and textons_init().
uint8_t reinitialize_dictionary = TEXTONS_REINITIALIZE_DICTIONARY |
Definition at line 120 of file textons.c.
Referenced by texton_func().
uint8_t running = TEXTONS_RUN |
Definition at line 118 of file textons.c.
Referenced by texton_func().
float* texton_distribution |
Definition at line 42 of file textons.c.
Referenced by DistributionExtraction(), save_texton_distribution(), textons_init(), textons_stop(), and vertical_ctrl_module_run().