File: regress_3.c

package info (click to toggle)
libpuzzle 0.11-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 2,092 kB
  • sloc: sh: 9,723; ansic: 1,811; makefile: 977; php: 269; sql: 148
file content (35 lines) | stat: -rw-r--r-- 1,065 bytes parent folder | download | duplicates (7)
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
#include "puzzle_common.h"
#include "puzzle.h"

#define PUZZLE_VECTOR_SLICE 0.6

int main(void)
{
    PuzzleContext context;
    PuzzleCvec cvec1, cvec2;
    double d1, d2;
    
    puzzle_init_context(&context);
    puzzle_init_cvec(&context, &cvec1);
    puzzle_init_cvec(&context, &cvec2);
    if (puzzle_fill_cvec_from_file(&context, &cvec1,
                                   "pics/pic-a-0.jpg") != 0) {
        fprintf(stderr, "File 1 not found\n");
        exit(0);
    }    
    if (puzzle_fill_cvec_from_file(&context, &cvec2,
                                   "pics/pic-a-1.jpg") != 0) {
        fprintf(stderr, "File 2 not found\n");
        exit(0);
    }
    d1 = puzzle_vector_normalized_distance(&context, &cvec1, &cvec2, 1);
    d2 = puzzle_vector_normalized_distance(&context, &cvec1, &cvec2, 0);
    printf("%g %g\n", d1, d2);
    puzzle_free_cvec(&context, &cvec1);
    puzzle_free_cvec(&context, &cvec2);
    puzzle_free_context(&context);
    if (d1 > PUZZLE_VECTOR_SLICE || d2 > PUZZLE_VECTOR_SLICE) {
        return 2;
    }
    return 0;
}