1 | #include "cv.h"
|
2 | #include <assert.h>
|
3 | #include <unistd.h>
|
4 | #include <stdio.h>
|
5 | #include <stdlib.h>
|
6 |
|
7 | int main(int argc, char **argv) {
|
8 | void *mat1data;
|
9 | size_t mat1size;
|
10 | CvMat mat1;
|
11 | CvMat *mat2v, *mat2s;
|
12 |
|
13 | int algo = CV_INTER_LINEAR;
|
14 | int mat1width = 4, mat2width = 8;
|
15 | int mat1height = 4, mat2height = 8;
|
16 | int mat1format = CV_8UC1, mat2format = CV_8UC1;
|
17 | int do_random = 0;
|
18 | int diffs = 0;
|
19 |
|
20 | mat2v = cvCreateMat(mat2height, mat2width, mat2format);
|
21 | mat2s = cvCreateMat(mat2height, mat2width, mat2format);
|
22 |
|
23 | mat1size = mat1width * mat1height * (1 << (CV_MAT_DEPTH(mat1format) >> 1));
|
24 | mat1data = malloc(mat1size);
|
25 | memcpy(mat1data, "\xe0 \x1f\x00\x05)\x05\x00!\xa3" "e\x00" "acY\x00", mat1size);
|
26 |
|
27 | mat1 = cvMat(mat1height, mat1width, mat1format, mat1data);
|
28 |
|
29 | cvUseOptimized(true);
|
30 | cvResize(&mat1, mat2v, algo);
|
31 | cvUseOptimized(false);
|
32 | cvResize(&mat1, mat2s, algo);
|
33 |
|
34 | diffs = 0;
|
35 | for (int i = 0; i < mat2width*mat2height; i++) {
|
36 | printf("ptr[%d]: %4d vs. %4d", i, mat2s->data.ptr[i], mat2v->data.ptr[i]);
|
37 | if (mat2s->data.ptr[i] != mat2v->data.ptr[i]) { \
|
38 | printf(" ...NO\n");
|
39 | diffs++;
|
40 | }
|
41 | else printf("\n");
|
42 | }
|
43 | printf("--\n");
|
44 | if (diffs)
|
45 | printf("%d mismatches FOUND!\n", diffs);
|
46 | else printf("No mismatches found.\n");
|
47 | }
|
48 |
|