File: regress_2.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 (72 lines) | stat: -rw-r--r-- 2,634 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "puzzle_common.h"
#include "puzzle.h"

int main(void)
{
    PuzzleContext context;
    PuzzleCvec cvec1, cvec2, cvec3, cvec4, cvec5, cvec6;
    double d1, d2, d3, d4, d5, d6;
    
    puzzle_init_context(&context);
    puzzle_init_cvec(&context, &cvec1);
    puzzle_init_cvec(&context, &cvec2);
    puzzle_init_cvec(&context, &cvec3);
    puzzle_init_cvec(&context, &cvec4);
    puzzle_init_cvec(&context, &cvec5);
    puzzle_init_cvec(&context, &cvec6);
    if (puzzle_fill_cvec_from_file
        (&context, &cvec1, "pics/luxmarket_tshirt01.jpg") != 0) {
        fprintf(stderr, "File 1 not found\n");
        exit(0);
    }    
    if (puzzle_fill_cvec_from_file
        (&context, &cvec2, "pics/luxmarket_tshirt01_black.jpg") != 0) {
        fprintf(stderr, "File 2 not found\n");
        exit(0);
    }
    if (puzzle_fill_cvec_from_file
        (&context, &cvec3, "pics/luxmarket_tshirt01_sal.jpg") != 0) {
        fprintf(stderr, "File 3 not found\n");
        exit(0);
    }
    if (puzzle_fill_cvec_from_file
        (&context, &cvec4, "pics/luxmarket_tshirt01_sheum.jpg") != 0) {
        fprintf(stderr, "File 4 not found\n");
        exit(0);
    }
    if (puzzle_fill_cvec_from_file
        (&context, &cvec5, "pics/duck.gif") != 0) {
        fprintf(stderr, "File 5 not found\n");
        exit(0);
    }
    if (puzzle_fill_cvec_from_file
        (&context, &cvec6, "pics/pic-a-0.jpg") != 0) {
        fprintf(stderr, "File 6 not found\n");
        exit(0);
    }
    d1 = puzzle_vector_normalized_distance(&context, &cvec2, &cvec1, 1);
    d2 = puzzle_vector_normalized_distance(&context, &cvec1, &cvec2, 1);
    d3 = puzzle_vector_normalized_distance(&context, &cvec1, &cvec3, 1);
    d4 = puzzle_vector_normalized_distance(&context, &cvec1, &cvec4, 1);
    d5 = puzzle_vector_normalized_distance(&context, &cvec1, &cvec5, 1);
    d6 = puzzle_vector_normalized_distance(&context, &cvec1, &cvec6, 1);
    printf("%g %g %g %g %g %g\n", d1, d2, d3, d4, d5, d6);
    puzzle_free_cvec(&context, &cvec1);
    puzzle_free_cvec(&context, &cvec2);    
    puzzle_free_cvec(&context, &cvec3);    
    puzzle_free_cvec(&context, &cvec4);    
    puzzle_free_cvec(&context, &cvec5);    
    puzzle_free_cvec(&context, &cvec6);
    puzzle_free_context(&context);
    if ((int) (d1 * 100.0) != (int) (d2 * 100.0)) {
        return 1;
    }
    if (d1 > PUZZLE_CVEC_SIMILARITY_THRESHOLD ||
        d3 > PUZZLE_CVEC_SIMILARITY_THRESHOLD ||
        d4 > PUZZLE_CVEC_SIMILARITY_THRESHOLD ||
        d5 < PUZZLE_CVEC_SIMILARITY_THRESHOLD ||
        d6 < PUZZLE_CVEC_SIMILARITY_THRESHOLD) {
        return 2;
    }
    return 0;
}