24 #include <fvutils/statistical/imagediff.h> 25 #include <fvutils/color/yuv.h> 45 this->scanline_model = scanline_model;
54 scanline_model = NULL;
71 unsigned int width,
unsigned int height)
73 buffer_a = yuv422planar_buffer;
86 unsigned int width,
unsigned int height)
88 buffer_b = yuv422planar_buffer;
104 if ( (buffer_a == NULL) && (buffer_b == NULL) )
return false;
105 if ( (buffer_a == NULL) && (buffer_b != NULL) )
return true;
106 if ( (buffer_a != NULL) && (buffer_b == NULL) )
return true;
107 if ( (width_a != width_b) || (height_a != height_b) )
return true;
109 if ( scanline_model != NULL ) {
113 unsigned char y_a, u_a, v_a, y_b, u_b, v_b;
115 scanline_model->reset();
116 while (! scanline_model->finished() ) {
117 x = (*scanline_model)->
x;
118 y = (*scanline_model)->y;
120 YUV422_PLANAR_YUV(buffer_a, width_a, height_a, x, y, y_a, u_a, v_a);
121 YUV422_PLANAR_YUV(buffer_b, width_b, height_b, x, y, y_b, u_b, v_b);
123 if ( (y_a != y_b) || (u_a != u_b) || (v_a != v_b) ) {
130 unsigned char *ypa = buffer_a;
131 unsigned char *ypb = buffer_b;
133 for (
unsigned int i = 0; i < (width_a * height_a); ++i) {
134 if ( *ypa != *ypb ) {
154 if ( (buffer_a == NULL) && (buffer_b == NULL) )
return 0;
155 if ( (buffer_a == NULL) && (buffer_b != NULL) )
return (width_b * height_b);
156 if ( (buffer_a != NULL) && (buffer_b == NULL) )
return (width_a * height_a);
157 if ( (width_a != width_b) || (height_a != height_b) ) {
158 return std::abs((
long)width_a - (
long)width_b) * std::abs((
long)height_a - (
long)height_b);
161 unsigned int num = 0;
162 if ( scanline_model != NULL ) {
166 unsigned char y_a, u_a, v_a, y_b, u_b, v_b;
168 scanline_model->reset();
169 while (! scanline_model->finished() ) {
170 x = (*scanline_model)->
x;
171 y = (*scanline_model)->y;
173 YUV422_PLANAR_YUV(buffer_a, width_a, height_a, x, y, y_a, u_a, v_a);
174 YUV422_PLANAR_YUV(buffer_b, width_b, height_b, x, y, y_b, u_b, v_b);
176 if ( (y_a != y_b) || (u_a != u_b) || (v_a != v_b) ) {
183 unsigned char *ypa = buffer_a;
184 unsigned char *ypb = buffer_b;
186 for (
unsigned int i = 0; i < (width_a * height_a); ++i) {
187 if ( *ypa++ != *ypb++ ) ++num;
unsigned int numDifferingPixels()
Number of differing pixels.
void setBufferA(unsigned char *yuv422planar_buffer, unsigned int width, unsigned int height)
Set first buffer.
Scanline model interface.
bool different()
Check if images are different.
unsigned int x
x coordinate
void setBufferB(unsigned char *yuv422planar_buffer, unsigned int width, unsigned int height)
Set second buffer.