diff options
Diffstat (limited to 'SD-VBS/benchmarks/sift/src/matlab/siftread.m')
| -rw-r--r-- | SD-VBS/benchmarks/sift/src/matlab/siftread.m | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/sift/src/matlab/siftread.m b/SD-VBS/benchmarks/sift/src/matlab/siftread.m new file mode 100644 index 0000000..76945c8 --- /dev/null +++ b/SD-VBS/benchmarks/sift/src/matlab/siftread.m | |||
| @@ -0,0 +1,101 @@ | |||
| 1 | function [frames,descriptors] = siftread(file) | ||
| 2 | % SIFTREAD Read Lowe's SIFT implementation data files | ||
| 3 | % [FRAMES, DESCRIPTORS] = READSIFT(FILE) reads the frames and the | ||
| 4 | % descriptors from the specified file. The function reads files | ||
| 5 | % produced by Lowe's SIFT implementation. | ||
| 6 | % | ||
| 7 | % FRAMES and DESCRIPTORS have the same format used by SIFT(). | ||
| 8 | % | ||
| 9 | % REMARK. Lowe's and our implementations use a silightly different | ||
| 10 | % convention to store the orientation of the frame. When the file | ||
| 11 | % is read, the orientation is changed to match our convention. | ||
| 12 | % | ||
| 13 | % See also SIFT(). | ||
| 14 | |||
| 15 | % AUTORIGHTS | ||
| 16 | % Copyright (c) 2006 The Regents of the University of California. | ||
| 17 | % All Rights Reserved. | ||
| 18 | % | ||
| 19 | % Created by Andrea Vedaldi | ||
| 20 | % UCLA Vision Lab - Department of Computer Science | ||
| 21 | % | ||
| 22 | % Permission to use, copy, modify, and distribute this software and its | ||
| 23 | % documentation for educational, research and non-profit purposes, | ||
| 24 | % without fee, and without a written agreement is hereby granted, | ||
| 25 | % provided that the above copyright notice, this paragraph and the | ||
| 26 | % following three paragraphs appear in all copies. | ||
| 27 | % | ||
| 28 | % This software program and documentation are copyrighted by The Regents | ||
| 29 | % of the University of California. The software program and | ||
| 30 | % documentation are supplied "as is", without any accompanying services | ||
| 31 | % from The Regents. The Regents does not warrant that the operation of | ||
| 32 | % the program will be uninterrupted or error-free. The end-user | ||
| 33 | % understands that the program was developed for research purposes and | ||
| 34 | % is advised not to rely exclusively on the program for any reason. | ||
| 35 | % | ||
| 36 | % This software embodies a method for which the following patent has | ||
| 37 | % been issued: "Method and apparatus for identifying scale invariant | ||
| 38 | % features in an image and use of same for locating an object in an | ||
| 39 | % image," David G. Lowe, US Patent 6,711,293 (March 23, | ||
| 40 | % 2004). Provisional application filed March 8, 1999. Asignee: The | ||
| 41 | % University of British Columbia. | ||
| 42 | % | ||
| 43 | % IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY | ||
| 44 | % FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, | ||
| 45 | % INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND | ||
| 46 | % ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN | ||
| 47 | % ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF | ||
| 48 | % CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT | ||
| 49 | % LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| 50 | % A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" | ||
| 51 | % BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE | ||
| 52 | % MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | ||
| 53 | |||
| 54 | verbosity=0 ; | ||
| 55 | |||
| 56 | g = fopen(file, 'r'); | ||
| 57 | if g == -1 | ||
| 58 | error(['Could not open file ''', file, '''.']) ; | ||
| 59 | end | ||
| 60 | [header, count] = fscanf(g, '%d', [1 2]) ; | ||
| 61 | if count ~= 2 | ||
| 62 | error('Invalid keypoint file header.'); | ||
| 63 | end | ||
| 64 | K = header(1) ; | ||
| 65 | DL = header(2) ; | ||
| 66 | |||
| 67 | if(verbosity > 0) | ||
| 68 | fprintf('%d keypoints, %d descriptor length.\n', K, DL) ; | ||
| 69 | end | ||
| 70 | |||
| 71 | %creates two output matrices | ||
| 72 | P = zeros(4,K) ; | ||
| 73 | L = zeros(DL,K) ; | ||
| 74 | |||
| 75 | %parse tmp.key | ||
| 76 | for k = 1:K | ||
| 77 | |||
| 78 | % Record format: i,j,s,th | ||
| 79 | [record, count] = fscanf(g, '%f', [1 4]) ; | ||
| 80 | if count ~= 4 | ||
| 81 | error(... | ||
| 82 | sprintf('Invalid keypoint file (parsing keypoint %d)',k) ); | ||
| 83 | end | ||
| 84 | P(:,k) = record(:) ; | ||
| 85 | |||
| 86 | % Record format: descriptor | ||
| 87 | [record, count] = fscanf(g, '%d', [1 DL]) ; | ||
| 88 | if count ~= DL | ||
| 89 | error(... | ||
| 90 | sprintf('Invalid keypoint file (parsing keypoint %d)',k) ); | ||
| 91 | end | ||
| 92 | L(:,k) = record(:) ; | ||
| 93 | |||
| 94 | end | ||
| 95 | fclose(g) ; | ||
| 96 | |||
| 97 | L=double(L) ; | ||
| 98 | P(1:2,:)=flipud(P(1:2,:)) ; % i,j -> x,y | ||
| 99 | |||
| 100 | frames=[ P(1:2,:) ; P(3,:) ; -P(4,:) ] ; | ||
| 101 | descriptors = L ; | ||
