| 1 | void test_motionDetect(TestData* testdata){ |
| 2 | VSMotionDetectConfig mdconf = vsMotionDetectGetDefaultConfig("test_motionDetect"); |
| 3 | VSMotionDetect md; |
| 4 | test_bool(vsMotionDetectInit(&md, &mdconf, &testdata->fi) == VS_OK); |
| 5 | |
| 6 | VSTransformConfig tdconf = vsTransformGetDefaultConfig("test_motionDetect-trans"); |
| 7 | VSTransformData td; |
| 8 | |
| 9 | test_bool(vsTransformDataInit(&td, &tdconf, &testdata->fi, &testdata->fi) == VS_OK); |
| 10 | fprintf(stderr,"MotionDetect:\n"); |
| 11 | int numruns =5; |
| 12 | int i; |
| 13 | //int t; |
| 14 | // for(t = 1; t <= 4; t++){ |
| 15 | int start = timeOfDayinMS(); |
| 16 | // omp_set_dynamic( 0 ); |
| 17 | // omp_set_num_threads( t ); |
| 18 | |
| 19 | for(i=0; i<numruns; i++){ |
| 20 | LocalMotions localmotions; |
| 21 | VSTransform t; |
| 22 | test_bool(vsMotionDetection(&md, &localmotions,&testdata->frames[i])== VS_OK); |
| 23 | /* for(k=0; k < vs_vector_size(&localmotions); k++){ */ |
| 24 | /* localmotion_print(LMGet(&localmotions,k),stderr); */ |
| 25 | /* } */ |
| 26 | t = vsSimpleMotionsToTransform(td.fiSrc, td.conf.modName, &localmotions); |
| 27 | |
| 28 | vs_vector_del(&localmotions); |
| 29 | fprintf(stderr,"%i: ",i); |
| 30 | storeVSTransform(stderr,&t); |
| 31 | VSTransform orig = mult_transform_(getTestFrameTransform(i),-1.0); |
| 32 | VSTransform diff = sub_transforms(&t,&orig); |
| 33 | int success = fabs(diff.x)<2 && fabs(diff.y)<2 && fabs(diff.alpha)<0.005; |
| 34 | if(!success){ |
| 35 | fprintf(stderr,"Difference: "); |
| 36 | storeVSTransform(stderr,&diff); |
| 37 | } |
| 38 | test_bool(success); |
| 39 | } |
| 40 | int end = timeOfDayinMS(); |
| 41 | |
| 42 | fprintf(stderr,"\n*** elapsed time for %i runs: %i ms ****\n", numruns, end-start ); |
| 43 | |
| 44 | vsMotionDetectionCleanup(&md); |
| 45 | } |