File: test_localmotion2transform.c

package info (click to toggle)
libvidstab 1.1.0-2.1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 648 kB
  • sloc: ansic: 6,094; makefile: 19; sh: 14
file content (45 lines) | stat: -rw-r--r-- 1,587 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
void test_localmotion2transform(TestData* testdata){
  VSMotionDetectConfig mdconf = vsMotionDetectGetDefaultConfig("test_localmotion2transform");
  VSMotionDetect md;
  test_bool(vsMotionDetectInit(&md, &mdconf, &testdata->fi) == VS_OK);

  VSTransformConfig tdconf = vsTransformGetDefaultConfig("test_localmotion2transform-trans");
  VSTransformData td;

  test_bool(vsTransformDataInit(&td, &tdconf, &testdata->fi, &testdata->fi) == VS_OK);
  fprintf(stderr,"MotionDetect:\n");
  int numruns =5;
  int i;
  //int t;
  //        for(t = 1; t <= 4; t++){
  int start = timeOfDayinMS();
  //      omp_set_dynamic( 0 );
  //      omp_set_num_threads( t );

  for(i=0; i<numruns; i++){
    LocalMotions localmotions;
    VSTransform t;
    test_bool(vsMotionDetection(&md, &localmotions,&testdata->frames[i])== VS_OK);
    /* for(k=0; k < vs_vector_size(&localmotions); k++){ */
    /*   localmotion_print(LMGet(&localmotions,k),stderr); */
    /* } */
    t = vsMotionsToTransform(&td, &localmotions, 0);

    vs_vector_del(&localmotions);
    fprintf(stderr,"%i: ",i);
    storeVSTransform(stderr,&t);
    VSTransform orig = mult_transform_(getTestFrameTransform(i),-1.0);
    VSTransform diff = sub_transforms(&t,&orig);
    int tolerance = fabs(diff.x)<1 && fabs(diff.y)<1 && fabs(diff.alpha)<0.001;
    if(!tolerance){
      fprintf(stderr,"Difference: ");
      storeVSTransform(stderr,&diff);
    }
    test_bool(tolerance);
  }
  int end = timeOfDayinMS();

  fprintf(stderr,"\n*** elapsed time for %i runs: %i ms ****\n", numruns, end-start );

  vsMotionDetectionCleanup(&md);
}