24 #include <fvutils/color/yuv.h> 25 #include <fvutils/draw/drawer.h> 31 namespace firevision {
60 this->buffer_ = buffer;
62 this->height_ = height;
99 unsigned int x = 0, y = radius, r2 = radius * radius;
101 unsigned char *up = YUV422_PLANAR_U_PLANE(buffer_, width_, height_);
102 unsigned char *vp = YUV422_PLANAR_V_PLANE(buffer_, width_, height_);
104 unsigned int x_tmp, y_tmp, ind_tmp;
107 x_tmp = center_x + x;
108 y_tmp = center_y + y;
109 if ((x_tmp < width_) && (y_tmp < height_)) {
110 ind_tmp = y_tmp * width_ + x_tmp;
111 buffer_[ind_tmp] = color_.
Y;
113 up[ind_tmp] = color_.
U;
114 vp[ind_tmp] = color_.
V;
117 x_tmp = center_x - x;
118 y_tmp = center_y + y;
119 if ((x_tmp < width_) && (y_tmp < height_)) {
120 ind_tmp = y_tmp * width_ + x_tmp;
121 buffer_[ind_tmp] = color_.
Y;
123 up[ind_tmp] = color_.
U;
124 vp[ind_tmp] = color_.
V;
127 x_tmp = center_x + y;
128 y_tmp = center_y + x;
129 if ((x_tmp < width_) && (y_tmp < height_)) {
130 ind_tmp = y_tmp * width_ + x_tmp;
131 buffer_[ind_tmp] = color_.
Y;
133 up[ind_tmp] = color_.
U;
134 vp[ind_tmp] = color_.
V;
137 x_tmp = center_x - y;
138 y_tmp = center_y + x;
139 if ((x_tmp < width_) && (y_tmp < height_)) {
140 ind_tmp = y_tmp * width_ + x_tmp;
141 buffer_[ind_tmp] = color_.
Y;
143 up[ind_tmp] = color_.
U;
144 vp[ind_tmp] = color_.
V;
147 x_tmp = center_x + x;
148 y_tmp = center_y - y;
149 if ((x_tmp < width_) && (y_tmp < height_)) {
150 ind_tmp = y_tmp * width_ + x_tmp;
151 buffer_[ind_tmp] = color_.
Y;
153 up[ind_tmp] = color_.
U;
154 vp[ind_tmp] = color_.
V;
157 x_tmp = center_x - x;
158 y_tmp = center_y - y;
159 if ((x_tmp < width_) && (y_tmp < height_)) {
160 ind_tmp = y_tmp * width_ + x_tmp;
161 buffer_[ind_tmp] = color_.
Y;
163 up[ind_tmp] = color_.
U;
164 vp[ind_tmp] = color_.
V;
167 x_tmp = center_x + y;
168 y_tmp = center_y - x;
169 if ((x_tmp < width_) && (y_tmp < height_)) {
170 ind_tmp = y_tmp * width_ + x_tmp;
171 buffer_[ind_tmp] = color_.
Y;
173 up[ind_tmp] = color_.
U;
174 vp[ind_tmp] = color_.
V;
177 x_tmp = center_x - y;
178 y_tmp = center_y - x;
179 if ((x_tmp < width_) && (y_tmp < height_)) {
180 ind_tmp = y_tmp * width_ + x_tmp;
181 buffer_[ind_tmp] = color_.
Y;
183 up[ind_tmp] = color_.
U;
184 vp[ind_tmp] = color_.
V;
188 y = (int)(sqrt((
float)(r2 - x * x)) + 0.5);
201 unsigned char *up = YUV422_PLANAR_U_PLANE(buffer_, width_, height_);
202 unsigned char *vp = YUV422_PLANAR_V_PLANE(buffer_, width_, height_);
205 for (
unsigned int i = x; i < x + w; ++i) {
207 buffer_[y * width_ + i] = color_.
Y;
208 up[(y * width_ + i) / 2] = color_.
U;
209 vp[(y * width_ + i) / 2] = color_.
V;
216 for (
unsigned int i = y; i < y + h; ++i) {
218 buffer_[i * width_ + x] = color_.
Y;
219 up[(i * width_ + x) / 2] = color_.
U;
220 vp[(i * width_ + x) / 2] = color_.
V;
222 if ((x + w) < width_) {
224 buffer_[i * width_ + x + w] = color_.
Y;
225 up[(i * width_ + x + w) / 2] = color_.
U;
226 vp[(i * width_ + x + w) / 2] = color_.
V;
231 for (
unsigned int i = x; i < x + w; ++i) {
233 buffer_[(y + h) * width_ + i] = color_.
Y;
234 up[((y + h) * width_ + i) / 2] = color_.
U;
235 vp[((y + h) * width_ + i) / 2] = color_.
V;
253 unsigned int ind = 0;
256 for (
unsigned int i = x; i < x + w; ++i) {
258 ind = y * width_ + i;
259 buffer_[ind] = 255 - buffer_[ind];
266 for (
unsigned int i = y; i < y + h; ++i) {
268 ind = i * width_ + x;
269 buffer_[ind] = 255 - buffer_[ind];
271 if ((x + w) < width_) {
274 buffer_[ind] = 255 - buffer_[ind];
279 for (
unsigned int i = x; i < x + w; ++i) {
281 buffer_[ind] = 255 - buffer_[ind];
300 unsigned char *up = YUV422_PLANAR_U_PLANE(buffer_, width_, height_);
301 unsigned char *vp = YUV422_PLANAR_V_PLANE(buffer_, width_, height_);
303 buffer_[y * width_ + x] = color_.
Y;
304 up[(y * width_ + x) / 2] = color_.
U;
305 vp[(y * width_ + x) / 2] = color_.
V;
323 unsigned char *up = YUV422_PLANAR_U_PLANE(buffer_, width_, height_);
324 unsigned char *vp = YUV422_PLANAR_V_PLANE(buffer_, width_, height_);
326 buffer_[y * width_ + x] = color_.
Y;
327 up[(y * width_ + x) / 2] = color_.
U;
328 vp[(y * width_ + x) / 2] = color_.
V;
346 unsigned char *up = YUV422_PLANAR_U_PLANE(buffer_, width_, height_);
347 unsigned char *vp = YUV422_PLANAR_V_PLANE(buffer_, width_, height_);
349 buffer_[y * width_ + x] = color.
Y;
350 up[(y * width_ + x) / 2] = color.
U;
351 vp[(y * width_ + x) / 2] = color.
V;
364 unsigned int y_start,
373 int x, y, dist, xerr, yerr, dx, dy, incx, incy;
374 bool was_inside_image =
false;
376 unsigned char *up = YUV422_PLANAR_U_PLANE(buffer_, width_, height_);
377 unsigned char *vp = YUV422_PLANAR_V_PLANE(buffer_, width_, height_);
380 dx = x_end - x_start;
381 dy = y_end - y_start;
399 dist = (dx > dy) ? dx : dy;
408 for (
int t = 0; t < dist; ++t) {
409 if (((
unsigned int)x < width_) && ((
unsigned int)y < height_)) {
410 if ((x >= 0) && (y >= 0)) {
411 was_inside_image =
true;
412 buffer_[y * width_ + x] = color_.
Y;
413 up[(y * width_ + x) / 2] = color_.
U;
414 vp[(y * width_ + x) / 2] = color_.
V;
417 if (was_inside_image) {
436 if ((x_end < width_) && (y_end < height_)) {
437 buffer_[y_end * width_ + x_end] = color_.
Y;
438 up[(y_end * width_ + x_end) / 2] = color_.
U;
439 vp[(y_end * width_ + x_end) / 2] = color_.
V;
451 x_center = std::min(x_center, width_);
452 y_center = std::min(y_center, height_);
455 unsigned int a = std::max(0, (
int)x_center - r);
456 unsigned int b = std::min(x_center + r, width_);
459 a = std::max(0, (
int)y_center - r);
460 b = std::min(y_center + r, height_);
unsigned char V
V component.
void draw_point(unsigned int x, unsigned int y)
Draw point.
void draw_cross(unsigned int x_center, unsigned int y_center, unsigned int width)
Draws a cross.
unsigned char Y
Y component.
void draw_rectangle_inverted(unsigned int x, unsigned int y, unsigned int w, unsigned int h)
Draw inverted rectangle.
void draw_line(unsigned int x_start, unsigned int y_start, unsigned int x_end, unsigned int y_end)
Draw line.
void set_buffer(unsigned char *buffer, unsigned int width, unsigned int height)
Set the buffer to draw to.
void draw_rectangle(unsigned int x, unsigned int y, unsigned int w, unsigned int h)
Draw rectangle.
unsigned char U
U component.
void draw_circle(int center_x, int center_y, unsigned int radius)
Draw circle.
void color_point(unsigned int x, unsigned int y)
Color the given point.
static YUV_t_struct white()
void set_color(unsigned char y, unsigned char u, unsigned char v)
Set drawing color.