/normxcorr/trunk

To get this branch, use:
bzr branch http://suren.me/webbzr/normxcorr/trunk

« back to all changes in this revision

Viewing changes to dict_hw/src/dict_hw_cli.cpp

  • Committer: Suren A. Chilingaryan
  • Date: 2010-04-27 09:35:57 UTC
  • Revision ID: csa@dside.dyndns.org-20100427093557-gxvt9b1n68tpig03
Enchanced error checking and timings measurements, Windows-related fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
153
153
    }
154
154
    
155
155
    fclose(f);
 
156
 
 
157
    return 0;
156
158
}
157
159
 
158
160
int compare(const void *a, const void*b) {
174
176
    char **images;
175
177
 
176
178
#ifdef DICT_HW_MEASURE_TIMINGS
177
 
    int time[8];
 
179
    int time[16];
178
180
    struct timeval tv1, tv2, tv3;
179
181
 
180
182
    memset(time, 0, sizeof(time));
379
381
        time[0] = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
380
382
#endif /* DICT_HW_MEASURE_TIMINGS */
381
383
 
382
 
    int icp;
383
 
    int real_ncp = ncp;
 
384
    size_t icp;
 
385
    size_t real_ncp = ncp;
384
386
    
385
387
    for (icp = 0, ncp = multipass?ncp_block:ncp; icp < real_ncp; icp += ncp, ncp = min2(ncp_block, real_ncp - icp)) {
386
 
#ifdef DICT_HW_VERBOSE_OUTPUT
387
 
        printf("%i + %i (of %i)\n", icp, ncp, real_ncp);
388
 
#endif /* DICT_HW_VERBOSE_OUTPUT */
 
388
#ifndef DICT_HW_MEASURE_TIMINGS
 
389
        if (multipass) {
 
390
            printf("Processing control points %i + %i (of %i)\n", icp, ncp, real_ncp);
 
391
        }
 
392
#endif /* ! DICT_HW_MEASURE_TIMINGS */
 
393
 
389
394
        if (icp) {
 
395
#ifdef DICT_HW_MEASURE_TIMINGS
 
396
            gettimeofday(&tv3, NULL);
 
397
#endif /* DICT_HW_MEASURE_TIMINGS */
390
398
            dictSetActualNumberOfPoints(ps, ncp);
391
399
            dictClean(ps);
392
400
            //dictSetup(ps, ncp, corrsize, precision, flags);
 
401
 
 
402
#ifdef DICT_HW_MEASURE_TIMINGS
 
403
            gettimeofday(&tv2, NULL);
 
404
            time[6] += (tv2.tv_sec - tv3.tv_sec) * 1000000 + (tv2.tv_usec - tv3.tv_usec);
 
405
#endif /* DICT_HW_MEASURE_TIMINGS */
393
406
        }
394
407
 
395
 
 
 
408
#ifdef DICT_HW_MEASURE_TIMINGS
 
409
        gettimeofday(&tv3, NULL);
 
410
#endif /* DICT_HW_MEASURE_TIMINGS */
396
411
        dictSetTemplatePoints(ps, x + icp, y + icp);
 
412
        dictSetCurrentPoints(ps, x + icp, y + icp);
 
413
#ifdef DICT_HW_MEASURE_TIMINGS
 
414
        gettimeofday(&tv2, NULL);
 
415
        time[7] += (tv2.tv_sec - tv3.tv_sec) * 1000000 + (tv2.tv_usec - tv3.tv_usec);
 
416
#endif /* DICT_HW_MEASURE_TIMINGS */
397
417
 
 
418
#ifdef DICT_HW_MEASURE_TIMINGS
 
419
        gettimeofday(&tv3, NULL);
 
420
#endif /* DICT_HW_MEASURE_TIMINGS */
398
421
        name = g_strdup_printf("%s/images/%s", argv[optind], images[0]);
399
422
        if (!g_file_test(name, G_FILE_TEST_IS_REGULAR)) {
400
423
            g_free(name);
410
433
            DATA_CLEANUP
411
434
            exit(-1);
412
435
        }
 
436
#ifdef DICT_HW_MEASURE_TIMINGS
 
437
        gettimeofday(&tv2, NULL);
 
438
        time[8] += (tv2.tv_sec - tv3.tv_sec) * 1000000 + (tv2.tv_usec - tv3.tv_usec);
 
439
#endif /* DICT_HW_MEASURE_TIMINGS */
413
440
    
414
 
        dictSetCurrentPoints(ps, x + icp, y + icp);
415
 
 
416
 
 
 
441
 
 
442
#ifdef DICT_HW_MEASURE_TIMINGS
 
443
        gettimeofday(&tv3, NULL);
 
444
#endif /* DICT_HW_MEASURE_TIMINGS */
417
445
        gchar *next = NULL;
418
446
 
419
447
        name = g_strdup_printf("%s/images/%s", argv[optind], images[1]);
423
451
            DATA_CLEANUP
424
452
            exit(-1);
425
453
        }
 
454
 
 
455
#ifdef DICT_HW_MEASURE_TIMINGS
 
456
        gettimeofday(&tv2, NULL);
 
457
        time[5] += (tv2.tv_sec - tv3.tv_sec) * 1000000 + (tv2.tv_usec - tv3.tv_usec);
 
458
#endif /* DICT_HW_MEASURE_TIMINGS */
426
459
    
427
460
        for (i = 1; i < maximg; i++, name = next) {
428
 
#ifdef DICT_HW_VERBOSE_OUTPUT
429
 
# ifndef DICT_HW_MEASURE_TIMINGS
 
461
#ifndef DICT_HW_MEASURE_TIMINGS
430
462
            printf("%s\n", images[i]);
431
 
# endif /* !DICT_HW_MEASURE_TIMINGS */
432
 
#endif /* DICT_HW_VERBOSE_OUTPUT */
 
463
#endif /* !DICT_HW_MEASURE_TIMINGS */
433
464
 
 
465
#ifdef DICT_HW_MEASURE_TIMINGS
 
466
            gettimeofday(&tv3, NULL);
 
467
#endif /* DICT_HW_MEASURE_TIMINGS */
434
468
            if ((i + 1) < maximg) {
435
469
                next = g_strdup_printf("%s/images/%s", argv[optind], images[i + 1]);
436
470
                if (!g_file_test(next, G_FILE_TEST_IS_REGULAR)) {
446
480
                }
447
481
            }
448
482
        
449
 
#ifdef DICT_HW_MEASURE_TIMINGS
450
 
            gettimeofday(&tv3, NULL);
451
 
#endif /* DICT_HW_MEASURE_TIMINGS */
452
483
            err = dictLoadImageFile(ps, name);
453
484
#ifdef DICT_HW_MEASURE_TIMINGS
454
485
            gettimeofday(&tv2, NULL);
529
560
    gettimeofday(&tv3, NULL);
530
561
    time[3] = (tv3.tv_sec - tv1.tv_sec) * 1000000 + (tv3.tv_usec - tv1.tv_usec);
531
562
    time[4] = (tv3.tv_sec - tv2.tv_sec) * 1000000 + (tv3.tv_usec - tv2.tv_usec);
 
563
    
 
564
    time[9] = time[6] + time[7] + time[8];
 
565
    
532
566
    reportMessage("");
533
567
    reportMessage("Global timings");
534
568
    reportMessage("--------------");
535
569
    print_timing("Overall", time[3]);
536
 
    print_timing("Initialization", time[0]);
 
570
    print_timing("Initialization", time[0] + time[9]);
 
571
    print_timing("Processing/Full", time[2] - time[9], maximg - 1);
537
572
    print_timing("Cleanup", time[4]);
538
 
    print_timing("Processing/Full", time[2], maximg - 1);
539
 
    print_timing("Processing/Computations", time[2] - time[1], maximg - 1);
540
 
    print_timing("Processing/Pushing Data", time[5], maximg - 1);
541
 
    print_timing("Processing/Waiting Result", time[2] - time[1] - time[5], maximg - 1);
 
573
    print_timing("Initialization/Reinit", time[6]);
 
574
    print_timing("Initialization/SetPoints", time[7]);
 
575
    print_timing("Initialization/LoadTemplate", time[8]);
 
576
    print_timing("Processing/Computations", time[2] - time[9] - time[1], maximg - 1);
542
577
    print_timing("Processing/Writeout", time[1], maximg - 1);
 
578
    print_timing("Computations/Load Image", time[5], maximg - 1);
 
579
    print_timing("Computations/Waiting Result", time[2] - time[9] - time[1] - time[5], maximg - 1);
543
580
    reportMessage("");
544
581
#endif /* DICT_HW_MEASURE_TIMINGS */
545
582