23 #include <fvutils/color/conversions.h>
24 #include <fvutils/color/yuv.h>
25 #include <fvwidgets/image_display.h>
32 using namespace firevision;
54 unsigned char *yp = buffer;
55 unsigned char *up = YUV422_PLANAR_U_PLANE(buffer, 512, 512);
56 unsigned char *vp = YUV422_PLANAR_V_PLANE(buffer, 512, 512);
58 for (
int v = 255; v >= 0; --v) {
59 for (
int u = 0; u < 256; ++u) {
66 memcpy(yp, (yp - 512), 512);
68 memcpy(up, (up - 256), 256);
69 memcpy(vp, (vp - 256), 256);
81 if (brightness != 255) {
82 if ((brightness + val) < 255) {
87 printf(
"New brightness: %i\n", brightness);
98 if (brightness != 0) {
99 if ((brightness - (
int)val) > 0) {
104 printf(
"New brightness: %i\n", brightness);
119 unsigned char *buffer;
124 main(
int argc,
char **argv)
126 unsigned int width = 512;
127 unsigned int height = 512;
129 unsigned char *yuv_buffer = malloc_buffer(YUV422_PLANAR, width, height);
133 cout << endl << endl <<
" V" << endl <<
" ^" << endl <<
" |" << endl <<
" +--> U" << endl << endl;
136 display->show(yuv_buffer);
138 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
143 if (SDL_WaitEvent(&event)) {
144 switch (event.type) {
145 case SDL_QUIT: quit =
true;
break;
147 if (event.key.keysym.sym == SDLK_UP) {
149 display->show(yuv_buffer);
150 }
else if (event.key.keysym.sym == SDLK_DOWN) {
152 display->show(yuv_buffer);
153 }
else if (event.key.keysym.sym == SDLK_PAGEUP) {
155 display->show(yuv_buffer);
156 }
else if (event.key.keysym.sym == SDLK_PAGEDOWN) {
158 display->show(yuv_buffer);
160 }
else if (event.key.keysym.sym == SDLK_ESCAPE) {
162 }
else if (event.key.keysym.sym == SDLK_q) {
167 case SDL_MOUSEBUTTONDOWN: {
168 int x =
event.button.x;
169 int y =
event.button.y;
171 printf(
"YUV: %i %i %i\n", yuvspace->
get_brightness(), x / 2, y / 2);