-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsiftgeo_read.m
42 lines (34 loc) · 1 KB
/
siftgeo_read.m
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
% This function reads a siftgeo binary file
%
% Usage: [v, meta] = siftgeo_read (filename, maxdes)
% filename the input filename
% maxdes maximum number of descriptors to be loaded
% (default=unlimited)
%
% Returned values
% v the sift descriptors (1 descriptor per line)
% meta meta data for each descriptor, i.e., per line:
% x, y, scale, angle, mi11, mi12, mi21, mi22, cornerness
function [v, meta] = siftgeo_read (filename, maxdes)
if nargin < 2
maxdes = 100000000;
end
% open the file and count the number of descriptors
fid = fopen (filename, 'r');
fseek (fid, 0, 1);
n = ftell (fid) / (9 * 4 + 1 * 4 + 128);
fseek (fid, 0, -1);
if n > maxdes
n = maxdes;
end;
% first read the meta information associated with the descriptor
meta = zeros (n, 9, 'single');
v = zeros (n, 128, 'single');
d = 0;
% read the elements
for i = 1:n
meta(i,:) = fread (fid, 9, 'float');
d = fread (fid, 1, 'int');
v(i,:) = fread (fid, d, 'uint8=>single');
end
fclose (fid);