bonjours; lors de compilation du code suivant(téléchargé du net):
//defs.h
//matchWin32.c
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 /************************************************************************ Demo software: Invariant keypoint matching. Author: David Lowe defs.h: This file contains the headers for a sample program to read images and keypoints, then perform simple keypoint matching. *************************************************************************/ /* From the standard C libaray: */ #include <stdlib.h> #include <math.h> #include <assert.h> #include <stdio.h> #include <string.h> /*------------------------------ Macros ---------------------------------*/ #define ABS(x) (((x) > 0) ? (x) : (-(x))) #define MAX(x,y) (((x) > (y)) ? (x) : (y)) #define MIN(x,y) (((x) < (y)) ? (x) : (y)) /*---------------------------- Structures --------------------------------*/ /* Data structure for a float image. */ typedef struct ImageSt { int rows, cols; /* Dimensions of image. */ float **pixels; /* 2D array of image pixels. */ struct ImageSt *next; /* Pointer to next image in sequence. */ } *Image; /* Data structure for a keypoint. Lists of keypoints are linked by the "next" field. */ typedef struct KeypointSt { float row, col; /* Subpixel location of keypoint. */ float scale, ori; /* Scale and orientation (range [-PI,PI]) */ unsigned char *descrip; /* Vector of descriptor values */ struct KeypointSt *next; /* Pointer to next keypoint in list. */ } *Keypoint; /*-------------------------- Function prototypes -------------------------*/ /* These are prototypes for the external functions that are shared between files. */ /* From util.c */ void FatalError(char *fmt, ...); Image CreateImage(int rows, int cols); Image ReadPGMFile(char *filename); Image ReadPGM(FILE *fp); void WritePGM(FILE *fp, Image image); void DrawLine(Image image, int r1, int c1, int r2, int c2); Keypoint ReadKeyFile(char *filename); Keypoint ReadKeys(FILE *fp);
j'ai eu les erreures suivantes:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158 #include "defs.h" /* -------------------- Local function prototypes ------------------------ */ void FindMatches(Image im1, Keypoint keys1, Image im2, Keypoint keys2); Keypoint CheckForMatch(Keypoint key, Keypoint klist); int DistSquared(Keypoint k1, Keypoint k2); Image CombineImagesVertically(Image im1, Image im2); /*----------------------------- Routines ----------------------------------*/ /* Top level routine. Read PGM images and keypoints from files given in command line arguments, then call FindMatches. */ int main (int argc, char **argv) { int arg = 0; Image im1 = NULL, im2 = NULL; Keypoint k1 = NULL, k2 = NULL; /* Parse command line arguments and read given files. The command line must specify two input images and two files of keypoints using command line arguments as follows: match -im1 i1.pgm -k1 k1.key -im2 i2.pgm -k2 k2.key > result.v */ while (++arg < argc) { if (! strcmp(argv[arg], "-im1")) im1 = ReadPGMFile(argv[++arg]); else if (! strcmp(argv[arg], "-im2")) im2 = ReadPGMFile(argv[++arg]); else if (! strcmp(argv[arg], "-k1")) k1 = ReadKeyFile(argv[++arg]); else if (! strcmp(argv[arg], "-k2")) k2 = ReadKeyFile(argv[++arg]); else FatalError("Invalid command line argument: %s", argv[arg]); } if (im1 == NULL || im2 == NULL || k1 == NULL || k2 == NULL) FatalError("Command line does not specify all images and keys."); FindMatches(im1, k1, im2, k2); exit(0); } /* Given a pair of images and their keypoints, pick the first keypoint from one image and find its closest match in the second set of keypoints. Then write the result to a file. */ void FindMatches(Image im1, Keypoint keys1, Image im2, Keypoint keys2) { Keypoint k, match; Image result; int count = 0; /* Create a new image that joins the two images vertically. */ result = CombineImagesVertically(im1, im2); /* Match the keys in list keys1 to their best matches in keys2. */ for (k= keys1; k != NULL; k = k->next) { match = CheckForMatch(k, keys2); /* Draw a line on the image from keys1 to match. Note that we must add row count of first image to row position in second so that line ends at correct location in second image. */ if (match != NULL) { count++; DrawLine(result, (int) k->row, (int) k->col, (int) (match->row + im1->rows), (int) match->col); } } /* Write result image to standard output. */ WritePGM(stdout, result); fprintf(stderr,"Found %d matches.\n", count); } /* This searches through the keypoints in klist for the two closest matches to key. If the closest is less than 0.6 times distance to second closest, then return the closest match. Otherwise, return NULL. */ Keypoint CheckForMatch(Keypoint key, Keypoint klist) { int dsq, distsq1 = 100000000, distsq2 = 100000000; Keypoint k, minkey = NULL; /* Find the two closest matches, and put their squared distances in distsq1 and distsq2. */ for (k = klist; k != NULL; k = k->next) { dsq = DistSquared(key, k); if (dsq < distsq1) { distsq2 = distsq1; distsq1 = dsq; minkey = k; } else if (dsq < distsq2) { distsq2 = dsq; } } /* Check whether closest distance is less than 0.6 of second. */ if (10 * 10 * distsq1 < 6 * 6 * distsq2) return minkey; else return NULL; } /* Return squared distance between two keypoint descriptors. */ int DistSquared(Keypoint k1, Keypoint k2) { int i, dif, distsq = 0; unsigned char *pk1, *pk2; pk1 = k1->descrip; pk2 = k2->descrip; for (i = 0; i < 128; i++) { dif = (int) *pk1++ - (int) *pk2++; distsq += dif * dif; } return distsq; } /* Return a new image that contains the two images with im1 above im2. */ Image CombineImagesVertically(Image im1, Image im2) { int rows, cols, r, c; Image result; rows = im1->rows + im2->rows; cols = MAX(im1->cols, im2->cols); result = CreateImage(rows, cols); /* Set all pixels to 0,5, so that blank regions are grey. */ for (r = 0; r < rows; r++) for (c = 0; c < cols; c++) result->pixels[r][c] = 0.5; /* Copy images into result. */ for (r = 0; r < im1->rows; r++) for (c = 0; c < im1->cols; c++) result->pixels[r][c] = im1->pixels[r][c]; for (r = 0; r < im2->rows; r++) for (c = 0; c < im2->cols; c++) result->pixels[r + im1->rows][c] = im2->pixels[r][c]; return result; }
comment resoudre ce problème ? (configuration: mvc++2010/ windows 7 64bit)Error 7 error LNK1120: 6 unresolved externals C:\Users\mohamed\documents\visual studio 2010\Projects\basicSkilll\Debug\basicSkilll.exe basicSkilll
Error 6 error LNK2019: unresolved external symbol "struct ImageSt * __cdecl CreateImage(int,int)" (?CreateImage@@YAPAUImageSt@@HH@Z) referenced in function "struct ImageSt * __cdecl CombineImagesVertically(struct ImageSt *,struct ImageSt *)" (?CombineImagesVertically@@YAPAUImageSt@@PAU1@0@Z) C:\Users\mohamed\documents\visual studio 2010\Projects\basicSkilll\basicSkilll\matchWin32.obj basicSkilll
Error 3 error LNK2019: unresolved external symbol "struct ImageSt * __cdecl ReadPGMFile(char *)" (?ReadPGMFile@@YAPAUImageSt@@PAD@Z) referenced in function _main C:\Users\mohamed\documents\visual studio 2010\Projects\basicSkilll\basicSkilll\matchWin32.obj basicSkilll
Error 2 error LNK2019: unresolved external symbol "struct KeypointSt * __cdecl ReadKeyFile(char *)" (?ReadKeyFile@@YAPAUKeypointSt@@PAD@Z) referenced in function _main C:\Users\mohamed\documents\visual studio 2010\Projects\basicSkilll\basicSkilll\matchWin32.obj basicSkilll
Error 5 error LNK2019: unresolved external symbol "void __cdecl DrawLine(struct ImageSt *,int,int,int,int)" (?DrawLine@@YAXPAUImageSt@@HHHH@Z) referenced in function "void __cdecl FindMatches(struct ImageSt *,struct KeypointSt *,struct ImageSt *,struct KeypointSt *)" (?FindMatches@@YAXPAUImageSt@@PAUKeypointSt@@01@Z) C:\Users\mohamed\documents\visual studio 2010\Projects\basicSkilll\basicSkilll\matchWin32.obj basicSkilll
Error 1 error LNK2019: unresolved external symbol "void __cdecl FatalError(char *,...)" (?FatalError@@YAXPADZZ) referenced in function _main C:\Users\mohamed\documents\visual studio 2010\Projects\basicSkilll\basicSkilll\matchWin32.obj basicSkilll
Error 4 error LNK2019: unresolved external symbol "void __cdecl WritePGM(struct _iobuf *,struct ImageSt *)" (?WritePGM@@YAXPAU_iobuf@@PAUImageSt@@@Z) referenced in function "void __cdecl FindMatches(struct ImageSt *,struct KeypointSt *,struct ImageSt *,struct KeypointSt *)" (?FindMatches@@YAXPAUImageSt@@PAUKeypointSt@@01@Z) C:\Users\mohamed\documents\visual studio 2010\Projects\basicSkilll\basicSkilll\matchWin32.obj basicSkilll
cordialement.
Partager