24 #include <fvutils/statistical/imagediff.h>
25 #include <fvutils/color/yuv.h>
45 this->scanline_model = scanline_model;
52 ImageDiff::ImageDiff()
54 scanline_model = NULL;
59 ImageDiff::~ImageDiff()
70 ImageDiff::setBufferA(
unsigned char *yuv422planar_buffer,
71 unsigned int width,
unsigned int height)
73 buffer_a = yuv422planar_buffer;
85 ImageDiff::setBufferB(
unsigned char *yuv422planar_buffer,
86 unsigned int width,
unsigned int height)
88 buffer_b = yuv422planar_buffer;
102 ImageDiff::different()
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 ) {
152 ImageDiff::numDifferingPixels()
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 abs(width_a - width_b) * abs(height_a - 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;
Scanline model interface.
unsigned int x
x coordinate