25 #include <fvfilters/morphology/segenerator.h> 26 #include <fvutils/color/colorspaces.h> 27 #include <fvutils/draw/drawer.h> 28 #include <fvutils/writers/fvraw.h> 29 #include <fvutils/writers/png.h> 30 #include <utils/math/angle.h> 35 namespace firevision {
56 unsigned int *proposed_center_x,
57 unsigned int *proposed_center_y,
58 float slope_angle_rad)
72 (
unsigned char *)malloc(colorspace_buffer_size(YUV422_PLANAR, width, height));
73 memset(tmp, 0, colorspace_buffer_size(YUV422_PLANAR, width, height));
80 if ((a == M_PI / 2) || (a == -M_PI / 2)) {
91 int y = (int)roundf(((
float)width - 1.f) * tan(a));
104 unsigned char *se = (
unsigned char *)malloc((
size_t)width * (size_t)height);
105 memcpy(se, tmp, (
size_t)width * (
size_t)height);
120 if ((proposed_center_x != NULL) && (proposed_center_y != NULL)) {
121 unsigned int min_x = width;
122 unsigned int max_x = 0;
123 unsigned int min_y = height;
124 unsigned int max_y = 0;
125 for (
unsigned int h = 0; h < height; ++h) {
126 for (
unsigned int w = 0; w < width; ++w) {
127 if (se[h * width + w] != 0) {
140 *proposed_center_x = min_x + (max_x - min_x) / 2;
141 *proposed_center_y = min_y + (max_y - min_y) / 2;
156 unsigned char *se = (
unsigned char *)malloc((
size_t)width * (size_t)height);
157 memset(se, 1, (
size_t)width * (
size_t)height);
174 memset(yuv422planar_buffer, 128, colorspace_buffer_size(YUV422_PLANAR, width, height));
175 for (
unsigned int h = 0; h < height; ++h) {
176 for (
unsigned int w = 0; w < width; ++w) {
177 if (mask[h * width + w] != 0) {
178 yuv422planar_buffer[h * width + w] = 255;
197 memset(yuv422planar_buffer, 128, colorspace_buffer_size(YUV422_PLANAR, width, height));
198 memset(yuv422planar_buffer, 255, (
size_t)width * (
size_t)height);
199 for (
unsigned int h = 0; h < height; ++h) {
200 for (
unsigned int w = 0; w < width; ++w) {
201 if (mask[h * width + w] != 0) {
202 yuv422planar_buffer[h * width + w] = 0;
static void drawSE(unsigned char *yuv422planar_buffer, unsigned char *mask, unsigned int width, unsigned int height)
Draw structuring element.
virtual void write()
Write to file.
void draw_line(unsigned int x_start, unsigned int y_start, unsigned int x_end, unsigned int y_end)
Draw line.
static void drawSEbw(unsigned char *yuv422planar_buffer, unsigned char *mask, unsigned int width, unsigned int height)
Draw structuring element.
static unsigned char * square(unsigned int width, unsigned int height)
Generate square structuring element.
float normalize_mirror_rad(float angle_rad)
Normalize angle in radian between -PI (inclusive) and PI (exclusive).
FvRaw Writer implementation.
void set_buffer(unsigned char *buffer, unsigned int width, unsigned int height)
Set the buffer to draw to.
static unsigned char * linear(unsigned int width, unsigned int height, unsigned int *proposed_center_x, unsigned int *proposed_center_y, float slope_angle_rad)
Generate linear structuring element.
virtual void write()
Write to file.
virtual void set_filename(const char *filename)
Set filename.
virtual void set_buffer(colorspace_t cspace, unsigned char *buffer)
Set image buffer.
virtual void set_dimensions(unsigned int width, unsigned int height)
Set dimensions of image in pixels.
void set_color(unsigned char y, unsigned char u, unsigned char v)
Set drawing color.