1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
10 // Intel License Agreement
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
22 // * Redistribution's in binary form must reproduce the above copyright notice,
23 // this list of conditions and the following disclaimer in the documentation
24 // and/or other materials provided with the distribution.
26 // * The name of Intel Corporation may not be used to endorse or promote products
27 // derived from this software without specific prior written permission.
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
46 #include "aeigenobjects.inc"
51 #define RELDIFF 1.0e-4
53 typedef struct _UserData /* User data structure for callback mode */
55 void* addr1; /* Array of objects ROI start addresses */
57 int step1; /* Step in bytes */
59 CvSize size1; /* ROI or full size */
63 /* Testing parameters */
64 static char FuncName[] =
65 "cvCalcCovarMatrixEx, cvCalcEigenObjects, cvCalcDecompCoeff, cvEigenDecomposite, cvEigenProjection";
66 static char TestName[] = "Eigen objects functions group test";
67 static char TestClass[] = "Algorithm";
68 static int obj_number, obj_width, obj_height;
69 static double rel_bufSize;
71 /*-----------------------------=--=-=== Callback functions ===-=--=---------------------*/
73 int read_callback_8u( int ind, void* buf, void* userData)
76 UserData* data = (UserData*)userData;
77 uchar* start = ((uchar**)(data->addr1))[ind];
78 uchar* buff = (uchar*)buf;
80 if( ind<0 ) return CV_BADFACTOR_ERR;
81 if( buf==NULL || userData==NULL ) return CV_NULLPTR_ERR;
83 for( i=0; i<data->size1.height; i++, start+=data->step1 )
84 for( j=0; j<data->size1.width; j++, k++ )
88 /*----------------------*/
89 int read_callback_32f( int ind, void* buf, void* userData)
92 UserData* data = (UserData*)userData;
93 float* start = ((float**)(data->addr2))[ind];
94 float* buff = (float*)buf;
96 if( ind<0 ) return CV_BADFACTOR_ERR;
97 if( buf==NULL || userData==NULL ) return CV_NULLPTR_ERR;
99 for( i=0; i<data->size2.height; i++, start+=data->step2/4 )
100 for( j=0; j<data->size2.width; j++, k++ )
104 /*========================*/
105 int write_callback_8u( int ind, void* buf, void* userData)
108 UserData* data = (UserData*)userData;
109 uchar* start = ((uchar**)(data->addr1))[ind];
110 uchar* buff = (uchar*)buf;
112 if( ind<0 ) return CV_BADFACTOR_ERR;
113 if( buf==NULL || userData==NULL ) return CV_NULLPTR_ERR;
115 for( i=0; i<data->size1.height; i++, start+=data->step1 )
116 for( j=0; j<data->size1.width; j++, k++ )
120 /*----------------------*/
121 int write_callback_32f( int ind, void* buf, void* userData)
124 UserData* data = (UserData*)userData;
125 float* start = ((float**)(data->addr2))[ind];
126 float* buff = (float*)buf;
128 if( ind<0 ) return CV_BADFACTOR_ERR;
129 if( buf==NULL || userData==NULL ) return CV_NULLPTR_ERR;
131 for( i=0; i<data->size2.height; i++, start+=data->step2/4 )
132 for( j=0; j<data->size2.width; j++, k++ )
137 /*##########################################=-- Test body --=###########################*/
138 static int fmaEigenObjects( void )
140 int n, n4, i, j, ie, m1, rep = 0, roi, roi4, bufSize;
141 int roix=0, roiy=0, sizex, sizey, step, step4, step44;
142 int err0, err1, err2, err3, err4, err5, err6, err7, err=0;
143 uchar *pro, *pro0, *object;
145 float *covMatr, *covMatr0, *avg, *avg0, *eigVal, *eigVal0, *coeffs, *coeffs0,
146 covMatrMax, coeffm, singleCoeff0;
147 float **eigObjs, **eigObjs0;
148 IplImage **Objs, **EigObjs, **EigObjs0, *Pro, *Pro0, *Object, *Avg, *Avg0;
149 double eps0, amax=0, singleCoeff, p;
153 CvTermCriteria limit;
155 int (*read_callback)( int ind, void* buf, void* userData)=
157 int (*read2_callback)( int ind, void* buf, void* userData)=
159 int (*write_callback)( int ind, void* buf, void* userData)=
161 CvInput* u_r = (CvInput*)&read_callback;
162 CvInput* u_r2= (CvInput*)&read2_callback;
163 CvInput* u_w = (CvInput*)&write_callback;
164 void* read_ = (u_r)->data;
165 void* read_2 = (u_r2)->data;
166 void* write_ = (u_w)->data;
168 /* Reading test parameters */
169 trsiRead( &obj_width, "100", "width of objects" );
170 trsiRead( &obj_height, "100", "height of objects" );
171 trsiRead( &obj_number, "11", "number of objects" );
172 trsdRead( &rel_bufSize, "0.09", "relative i/o buffer size" );
174 if( rel_bufSize < 0.0 ) rel_bufSize = 0.0;
177 n = obj_width * obj_height;
178 sizex = obj_width, sizey = obj_height;
180 Objs = (IplImage**)cvAlloc(sizeof(IplImage*) * obj_number );
181 EigObjs = (IplImage**)cvAlloc(sizeof(IplImage*) * m1 );
182 EigObjs0 = (IplImage**)cvAlloc(sizeof(IplImage*) * m1 );
184 objs = (uchar**)cvAlloc(sizeof(uchar*) * obj_number );
185 eigObjs = (float**)cvAlloc(sizeof(float*) * m1 );
186 eigObjs0 = (float**)cvAlloc(sizeof(float*) * m1 );
187 covMatr = (float*) cvAlloc(sizeof(float) * obj_number * obj_number );
188 covMatr0 = (float*) cvAlloc(sizeof(float) * obj_number * obj_number );
189 coeffs = (float*) cvAlloc(sizeof(float*) * m1 );
190 coeffs0 = (float*) cvAlloc(sizeof(float*) * m1 );
191 eigVal = (float*) cvAlloc(sizeof(float) * obj_number );
192 eigVal0 = (float*) cvAlloc(sizeof(float) * obj_number );
194 size.width = obj_width; size.height = obj_height;
195 atsRandInit( &state, 0, 255, 13 );
197 Avg = cvCreateImage( size, IPL_DEPTH_32F, 1 );
198 cvSetImageROI( Avg, cvRect(0, 0, Avg->width, Avg->height) );
199 Avg0 = cvCreateImage( size, IPL_DEPTH_32F, 1 );
200 cvSetImageROI( Avg0, cvRect(0, 0, Avg0->width, Avg0->height) );
201 avg = (float*)Avg->imageData;
202 avg0 = (float*)Avg0->imageData;
203 Pro = cvCreateImage( size, IPL_DEPTH_8U, 1 );
204 cvSetImageROI( Pro, cvRect(0, 0, Pro->width, Pro->height) );
205 Pro0 = cvCreateImage( size, IPL_DEPTH_8U, 1 );
206 cvSetImageROI( Pro0, cvRect(0, 0, Pro0->width, Pro0->height) );
207 pro = (uchar*)Pro->imageData;
208 pro0 = (uchar*)Pro0->imageData;
209 Object = cvCreateImage( size, IPL_DEPTH_8U, 1 );
210 cvSetImageROI( Object, cvRect(0, 0, Object->width, Object->height) );
211 object = (uchar*)Object->imageData;
213 step = Pro->widthStep; step4 = Avg->widthStep; step44 = step4/4;
214 n = step*obj_height; n4= step44*obj_height;
215 atsbRand8u ( &state, object, n );
217 for( i=0; i<obj_number; i++ )
219 Objs[i] = cvCreateImage( size, IPL_DEPTH_8U, 1 );
220 cvSetImageROI( Objs[i], cvRect(0, 0, Objs[i]->width, Objs[i]->height) );
221 objs[i] = (uchar*)Objs[i]->imageData;
222 atsbRand8u ( &state, objs[i], n );
225 EigObjs[i] = cvCreateImage( size, IPL_DEPTH_32F, 1 );
226 cvSetImageROI( EigObjs[i], cvRect(0, 0, EigObjs[i]->width, EigObjs[i]->height) );
227 EigObjs0[i] = cvCreateImage( size, IPL_DEPTH_32F, 1 );
228 cvSetImageROI( EigObjs0[i], cvRect(0, 0, EigObjs0[i]->width, EigObjs0[i]->height) );
232 limit.type = CV_TERMCRIT_ITER; limit.max_iter = m1; limit.epsilon = 1;//(float)eps0;
234 bufSize = (int)(4*n*obj_number*rel_bufSize);
235 trsWrite(TW_RUN|TW_CON, "\n i/o buffer size : %10d bytes\n", bufSize );
237 trsWrite(TW_RUN|TW_CON, "\n ROI unsupported\n" );
240 userData.addr1 = (void*)objs;
241 userData.addr2 = (void*)eigObjs;
242 userData.step1 = step;
243 userData.step2 = step4;
247 roi = roiy*step + roix;
248 roi4 = roiy*step44 + roix;
250 Avg->roi->xOffset = roix; Avg->roi->yOffset = roiy;
251 Avg->roi->height = size.height; Avg->roi->width = size.width;
252 Avg0->roi->xOffset = roix; Avg0->roi->yOffset = roiy;
253 Avg0->roi->height = size.height; Avg0->roi->width = size.width;
254 Pro->roi->xOffset = roix; Pro->roi->yOffset = roiy;
255 Pro->roi->height = size.height; Pro->roi->width = size.width;
256 Pro0->roi->xOffset = roix; Pro0->roi->yOffset = roiy;
257 Pro0->roi->height = size.height; Pro0->roi->width = size.width;
258 Object->roi->xOffset = roix; Object->roi->yOffset = roiy;
259 Object->roi->height = size.height; Object->roi->width = size.width;
261 for( i=0; i<obj_number; i++ )
263 Objs[i]->roi->xOffset = roix; Objs[i]->roi->yOffset = roiy;
264 Objs[i]->roi->height = size.height; Objs[i]->roi->width = size.width;
265 objs[i] = (uchar*)Objs[i]->imageData + roi;
268 EigObjs[i]->roi->xOffset = roix; EigObjs[i]->roi->yOffset = roiy;
269 EigObjs[i]->roi->height = size.height; EigObjs[i]->roi->width = size.width;
270 EigObjs0[i]->roi->xOffset = roix; EigObjs0[i]->roi->yOffset = roiy;
271 EigObjs0[i]->roi->height = size.height; EigObjs0[i]->roi->width = size.width;
272 eigObjs[i] = (float*)EigObjs[i]->imageData + roi4;
273 eigObjs0[i] = (float*)EigObjs0[i]->imageData + roi4;
277 userData.size1 = userData.size2 = size;
279 /* =================================== Test functions run ============================= */
281 r = _cvCalcEigenObjects_8u32fR_q( obj_number, objs, step, eigObjs0, step4,
282 size, eigVal0, avg0+roi4, step4, &m1, &eps0 );
284 r = _cvEigenDecomposite_8u32fR_q( object+roi, step, m1, eigObjs0, step4,
285 avg0+roi4, step4, size, coeffs0 );
287 r = _cvEigenProjection_8u32fR_q( m1, eigObjs0, step4, coeffs0, avg0+roi4, step4,
288 pro0+roi, step, size );
290 r = _cvCalcCovarMatrix_8u32fR_q( obj_number, objs, step, avg0+roi4, step4,
293 singleCoeff0 = _cvCalcDecompCoeff_8u32fR_q( object+roi, step, eigObjs0[0], step4,
294 avg0+roi4, step4, size );
297 for( i=0; i<obj_number*obj_number; i++ )
298 if( covMatrMax < (float)fabs( covMatr[i] ) )
299 covMatrMax = (float)fabs( covMatr[i] );
302 for( ie=0; ie<m1; ie++ )
303 for( i=0; i<size.height; i++ )
304 for( j=0; j<size.width; j++ )
306 int ij = i*obj_width + j;
307 float e = eigObjs0[ie][ij];
308 if( amax < fabs(e) ) amax = fabs(e);
312 for( i=0; i<m1; i++ )
313 if( coeffm < (float)fabs(coeffs0[i]) ) coeffm = (float)fabs(coeffs0[i]);
315 /*- - - - - - - - - - - - - - - - - - - - - without callbacks - - - - - - - - - - - - - */
316 for( i=0; i<obj_number*obj_number; i++ ) covMatr[i] = covMatr0[i];
317 for( i=0; i<size.height; i++ )
318 for( j=0; j<size.width; j++ ) pro[i*step + j] = pro0[i*step + j];
319 for( i=0; i<size.height; i++ )
320 for( j=0; j<size.width; j++ ) avg[i*step44 + j] = avg0[i*step44 + j];
321 for( i=0; i<m1; i++ ) { coeffs[i] = coeffs0[i]; eigVal[i] = eigVal0[i]; }
322 for( ie=0; ie<m1; ie++ )
323 for( i=0; i<size.height; i++ )
324 for( j=0; j<size.width; j++ )
325 eigObjs[ie][i*step44+j] = eigObjs0[ie][i*step44+j];
327 err1 = err2 = err3 = err4 = err5 = err6 = err7 = 0;
329 cvCalcCovarMatrixEx( obj_number,
331 CV_EIGOBJ_NO_CALLBACK,
338 cvCalcEigenObjects ( obj_number,
341 CV_EIGOBJ_NO_CALLBACK,
348 singleCoeff = cvCalcDecompCoeff( Object, EigObjs[0], Avg );
349 if( fabs( (singleCoeff - singleCoeff0)/singleCoeff0 ) > RELDIFF ) err7++;
351 cvEigenDecomposite( Object,
354 CV_EIGOBJ_NO_CALLBACK,
358 cvEigenProjection ( (void*)EigObjs,
360 CV_EIGOBJ_NO_CALLBACK,
366 /* Covariance matrix comparision */
367 for( i=0; i<obj_number*obj_number; i++ )
368 if( fabs(covMatr[i] - covMatr0[i]) > RELDIFF*fabs(covMatrMax) ) err6++;
370 /* Averaged object comparision */
371 for( i=0; i<size.height; i++ )
372 for( j=0; j<size.width; j++ )
374 int ij = i*step44 + j;
375 if( fabs( (avg+roi)[ij] - (avg0+roi)[ij] ) > MAXDIFF ) err1++;
378 /* Eigen objects comparision */
379 for( ie=0; ie<m1; ie++ )
380 for( i=0; i<size.height; i++ )
381 for( j=0; j<size.width; j++ )
383 int ij = i*step44 + j;
384 float e0 = (eigObjs0[ie])[ij], e = (eigObjs[ie])[ij];
385 if( fabs( (e-e0)/amax ) > RELDIFF ) err2++;
388 /* Eigen values comparision */
389 for( i=0; i<m1; i++ )
391 double e0 = eigVal0[i], e = eigVal[i];
393 if( fabs( (e-e0)/e0 ) > RELDIFF ) err3++;
396 /* Decomposition coefficients comparision */
397 for( i=0; i<m1; i++ )
399 if( fabs( (coeffs[i] - coeffs0[i])/coeffm ) > RELDIFF ) err4++;
401 /* Projection comparision */
402 for( i=0; i<size.height; i++ )
403 for( j=0; j<size.width; j++ )
406 if( fabs( (double)((pro+roi)[ij] - (pro0+roi)[ij]) ) > MAXDIFF ) err5++;
410 p = 100.f*err6/(float)(obj_number*obj_number);
413 trsWrite(TW_RUN|TW_CON, " Covar. matrix - %d errors (%7.3f %% );\n", err6, p );
416 p = 100.f*err1/(float)(size.height*size.width);
419 trsWrite(TW_RUN|TW_CON, " Averaged obj. - %d errors (%7.3f %% );\n", err1, p );
422 p = 100.f*err3/(float)(m1);
425 trsWrite(TW_RUN|TW_CON, " Eigen values - %d errors (%7.3f %% );\n", err3, p );
428 p = 100.f*err2/(float)(size.height*size.width*m1);
431 trsWrite(TW_RUN|TW_CON, " Eigen objects - %d errors (%7.3f %% );\n", err2, p );
434 p = 100.f*err4/(float)(m1);
437 trsWrite(TW_RUN|TW_CON, " Decomp.coeffs - %d errors (%7.3f %% );\n", err4, p );
440 if( ((float)err7)/m1 > 0.1 )
442 trsWrite(TW_RUN|TW_CON, " Single dec.c. - %d errors ;\n", err7);
445 p = 100.f*err5/(float)(size.height*size.width);
448 trsWrite(TW_RUN|TW_CON, " Projection - %d errors (%7.3f %% );\n", err5, p );
451 trsWrite(TW_RUN|TW_CON, " without callbacks : %8d errors;\n", err0 );
455 /*- - - - - - - - - - - - - - - - - - - - - input callback - - - - - - - - - - - - - */
456 for( i=0; i<size.height; i++ )
457 for( j=0; j<size.width; j++ ) pro[i*step + j] = pro0[i*step + j];
458 for( i=0; i<size.height; i++ )
459 for( j=0; j<size.width; j++ ) avg[i*step44 + j] = avg0[i*step44 + j];
460 for( i=0; i<m1; i++ ) { coeffs[i] = coeffs0[i]; eigVal[i] = eigVal0[i]; }
461 for( ie=0; ie<m1; ie++ )
462 for( i=0; i<size.height; i++ )
463 for( j=0; j<size.width; j++ )
464 eigObjs[ie][i*step44+j] = eigObjs0[ie][i*step44+j];
466 err1 = err2 = err3 = err4 = err5 = err6 = err7 = 0;
468 cvCalcEigenObjects ( obj_number,
471 CV_EIGOBJ_INPUT_CALLBACK,
478 cvEigenDecomposite( Object,
481 CV_EIGOBJ_INPUT_CALLBACK,
486 cvEigenProjection ( read_2,
488 CV_EIGOBJ_INPUT_CALLBACK,
494 /* Averaged object comparision */
495 for( i=0; i<size.height; i++ )
496 for( j=0; j<size.width; j++ )
498 int ij = i*step44 + j;
499 if( fabs( (avg+roi)[ij] - (avg0+roi)[ij] ) > MAXDIFF ) err1++;
502 /* Eigen objects comparision */
503 for( ie=0; ie<m1; ie++ )
504 for( i=0; i<size.height; i++ )
505 for( j=0; j<size.width; j++ )
507 int ij = i*step44 + j;
508 float e0 = (eigObjs0[ie])[ij], e = (eigObjs[ie])[ij];
509 if( fabs( (e-e0)/amax ) > RELDIFF ) err2++;
512 /* Eigen values comparision */
513 for( i=0; i<m1; i++ )
515 double e0 = eigVal0[i], e = eigVal[i];
517 if( fabs( (e-e0)/e0 ) > RELDIFF ) err3++;
520 /* Projection comparision */
521 for( i=0; i<size.height; i++ )
522 for( j=0; j<size.width; j++ )
525 if( fabs( (double)((pro+roi)[ij] - (pro0+roi)[ij]) ) > MAXDIFF ) err5++;
528 /* Decomposition coefficients comparision */
529 for( i=0; i<m1; i++ )
531 if( fabs( (coeffs[i] - coeffs0[i])/coeffm ) > RELDIFF ) err4++;
534 p = 100.f*err1/(float)(size.height*size.width);
537 trsWrite(TW_RUN|TW_CON, " Averaged obj. - %d errors (%7.3f %% );\n", err1, p );
540 p = 100.f*err3/(float)(m1);
543 trsWrite(TW_RUN|TW_CON, " Eigen values - %d errors (%7.3f %% );\n", err3, p );
546 p = 100.f*err2/(float)(size.height*size.width*m1);
549 trsWrite(TW_RUN|TW_CON, " Eigen objects - %d errors (%7.3f %% );\n", err2, p );
552 p = 100.f*err4/(float)(m1);
555 trsWrite(TW_RUN|TW_CON, " Decomp.coeffs - %d errors (%7.3f %% );\n", err4, p );
558 p = 100.f*err5/(float)(size.height*size.width);
561 trsWrite(TW_RUN|TW_CON, " Projection - %d errors (%7.3f %% );\n", err5, p );
564 trsWrite(TW_RUN|TW_CON, " input callback : %8d errors;\n", err0 );
568 /*- - - - - - - - - - - - - - - - - - - - - output callback - - - - - - - - - - - - - */
569 for( i=0; i<size.height; i++ )
570 for( j=0; j<size.width; j++ ) avg[i*step44 + j] = avg0[i*step44 + j];
571 for( i=0; i<m1; i++ ) eigVal[i] = eigVal0[i];
572 for( ie=0; ie<m1; ie++ )
573 for( i=0; i<size.height; i++ )
574 for( j=0; j<size.width; j++ )
575 eigObjs[ie][i*step44+j] = eigObjs0[ie][i*step44+j];
577 err1 = err2 = err3 = err4 = err5 = 0;
579 cvCalcEigenObjects ( obj_number,
582 CV_EIGOBJ_OUTPUT_CALLBACK,
589 /* Averaged object comparision */
590 for( i=0; i<size.height; i++ )
591 for( j=0; j<size.width; j++ )
593 int ij = i*step44 + j;
594 if( fabs( (avg+roi)[ij] - (avg0+roi)[ij] ) > MAXDIFF ) err1++;
597 /* Eigen objects comparision */
598 for( ie=0; ie<m1; ie++ )
599 for( i=0; i<size.height; i++ )
600 for( j=0; j<size.width; j++ )
602 int ij = i*step44 + j;
603 float e0 = (eigObjs0[ie])[ij], e = (eigObjs[ie])[ij];
604 if( fabs( (e-e0)/amax ) > RELDIFF ) err2++;
607 /* Eigen values comparision */
608 for( i=0; i<m1; i++ )
610 double e0 = eigVal0[i], e = eigVal[i];
612 if( fabs( (e-e0)/e0 ) > RELDIFF ) err3++;
616 p = 100.f*err1/(float)(size.height*size.width);
619 trsWrite(TW_RUN|TW_CON, " Averaged obj. - %d errors (%7.3f %% );\n", err1, p );
622 p = 100.f*err3/(float)(m1);
625 trsWrite(TW_RUN|TW_CON, " Eigen values - %d errors (%7.3f %% );\n", err3, p );
628 p = 100.f*err2/(float)(size.height*size.width*m1);
631 trsWrite(TW_RUN|TW_CON, " Eigen objects - %d errors (%7.3f %% );\n", err2, p );
634 trsWrite(TW_RUN|TW_CON, " output callback : %8d errors;\n", err0 );
638 /*- - - - - - - - - - - - - - - - - - - - - both callbacks - - - - - - - - - - - - - */
639 for( i=0; i<size.height; i++ )
640 for( j=0; j<size.width; j++ ) avg[i*step44 + j] = avg0[i*step44 + j];
641 for( i=0; i<m1; i++ ) eigVal[i] = eigVal0[i];
642 for( ie=0; ie<m1; ie++ )
643 for( i=0; i<size.height; i++ )
644 for( j=0; j<size.width; j++ )
645 eigObjs[ie][i*step44+j] = eigObjs0[ie][i*step44+j];
647 err1 = err2 = err3 = err4 = err5 = 0;
649 cvCalcEigenObjects ( obj_number,
652 CV_EIGOBJ_INPUT_CALLBACK | CV_EIGOBJ_OUTPUT_CALLBACK,
659 /* Averaged object comparision */
660 for( i=0; i<size.height; i++ )
661 for( j=0; j<size.width; j++ )
663 int ij = i*step44 + j;
664 if( fabs( (avg+roi)[ij] - (avg0+roi)[ij] ) > MAXDIFF ) err1++;
667 /* Eigen objects comparision */
668 for( ie=0; ie<m1; ie++ )
669 for( i=0; i<size.height; i++ )
670 for( j=0; j<size.width; j++ )
672 int ij = i*step44 + j;
673 float e0 = (eigObjs0[ie])[ij], e = (eigObjs[ie])[ij];
674 if( fabs( (e-e0)/amax ) > RELDIFF ) err2++;
677 /* Eigen values comparision */
678 for( i=0; i<m1; i++ )
680 double e0 = eigVal0[i], e = eigVal[i];
682 if( fabs( (e-e0)/e0 ) > RELDIFF ) err3++;
686 p = 100.f*err1/(float)(size.height*size.width);
689 trsWrite(TW_RUN|TW_CON, " Averaged obj. - %d errors (%7.3f %% );\n", err1, p );
692 p = 100.f*err3/(float)(m1);
695 trsWrite(TW_RUN|TW_CON, " Eigen values - %d errors (%7.3f %% );\n", err3, p );
698 p = 100.f*err2/(float)(size.height*size.width*m1);
701 trsWrite(TW_RUN|TW_CON, " Eigen objects - %d errors (%7.3f %% );\n", err2, p );
704 trsWrite(TW_RUN|TW_CON, " both callbacks : %8d errors;\n", err0 );
709 /*================================-- test with ROI --===================================*/
713 roix = (int)(0.157f*obj_width);
714 roiy = (int)(0.131f*obj_height);
715 sizex = (int)(0.611f*obj_width);
716 sizey = (int)(0.737f*obj_height);
717 roi = roiy*obj_width + roix;
719 trsWrite(TW_RUN|TW_CON, "\n ROI supported\n" );
721 size.width = sizex; size.height = sizey;
726 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ free memory ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
727 cvReleaseImage( &Avg );
728 cvReleaseImage( &Avg0 );
729 cvReleaseImage( &Pro );
730 cvReleaseImage( &Pro0 );
731 cvReleaseImage( &Object );
732 for( i=0; i<obj_number; i++ )
734 cvReleaseImage( &Objs[i] );
737 cvReleaseImage( &EigObjs[i] );
738 cvReleaseImage( &EigObjs0[i] );
755 trsWrite(TW_RUN|TW_CON, "\n Errors number: %d\n", err );
757 if(err) return trsResult( TRS_FAIL, "Algorithm test has passed. %d errors.", err );
758 else return trsResult( TRS_OK, "Algorithm test has passed successfully" );
762 /*------------------------------------------- Initialize function ------------------------ */
763 void InitAEigenObjects( void )
765 /* Registering test function */
766 trsReg( FuncName, TestName, TestClass, fmaEigenObjects );
767 } /* InitAEigenObjects */