我正在尝试使用 LibRAW 库解析尼康 RAW 文件。该库为我提供了一个 32 字节的 GPS 数据 int 数组。我找不到任何文档来解释如何解释这个 32 x int 数组。
以下是我提取的 GPS 数据示例 -
GPS:32
GPS:1
GPS:112393
GPS:10000
GPS:0
GPS:1
GPS:104
GPS:1
GPS:253126
GPS:10000
GPS:0
GPS:1
GPS:18
GPS:1
GPS:35
GPS:1
GPS:4800
GPS:100
GPS:1204
GPS:1
GPS:538976288
GPS:538976288
GPS:32
GPS:875638834
GPS:976302138
GPS:13361
GPS:0
GPS:0
GPS:0
GPS:78
GPS:87
GPS:0
答案1
嗯...我找不到有关unsigned int [32]
for 的任何文档gpsdata
。
我确实找到了一些代码片段这里来自 LibRAW 源。
查看 parse_gps。此代码将 Exif 信息解析到gpsdata[32]
数组中。
#define FORC(cnt) for (c=0; c < cnt; c++)
...
void CLASS parse_gps (int base)
{
unsigned entries, tag, type, len, save, c;
entries = get2();
while (entries--) {
tiff_get (base, &tag, &type, &len, &save);
switch (tag) {
case 1: case 3: case 5:
gpsdata[29+tag/2] = getc(ifp); break;
case 2: case 4: case 7:
FORC(6) gpsdata[tag/3*6+c] = get4(); break;
case 6:
FORC(2) gpsdata[18+c] = get4(); break;
case 18: case 29:
fgets ((char *) (gpsdata+14+tag/3), MIN(len,12), ifp);
}
fseek (ifp, save, SEEK_SET);
}
}
请原谅我缺乏 C++ 知识...但在此来源我找到
GPSLatitudeRef = gpsdata[29+1/2] (Exif tag 0x0001) = [29] 1 char
GPSLongitudeRef = gpsdata[29+3/2] (Exif tag 0x0003) = [30] 1 char
GPSAltitudeRef = gpsdata[29+5/2] (Exif tag 0x0005) = [31] 1 char
GPSLatitude = gpsdata[2/3*6+c] (Exif tag 0x0002) = [ 0] 6 int
GPSLongitude = gpsdata[4/3*6+c] (Exif tag 0x0004) = [ 6] 6 int
GPSTimeStamp = gpsdata[7/3*6+c] (Exif tag 0x0007) = [12] 6 int
GPSAltitude = gpsdata[18+c] (Exif tag 0x0006) = [18] 2 int
GPSMapDatum = gpsdata+14+18/3 (Exif tag 0x0012) = [20] 3 int
GPSDateStamp = gpsdata+14+29/3 (Exif tag 0x001d) = [23] 3 int
在你的情况下这将转化为:
00 GPS:32 GPSLatitude #1
01 GPS:1 #2
02 GPS:112393 #3
03 GPS:10000 #4
04 GPS:0 #5
05 GPS:1 #6
06 GPS:104 GPSLongitude #1
07 GPS:1 #2
08 GPS:253126 #3
09 GPS:10000 #4
10 GPS:0 #5
11 GPS:1 #6
12 GPS:18 GPSTimeStamp #1
13 GPS:1 #2
14 GPS:35 #3
15 GPS:1 #4
16 GPS:4800 #5
17 GPS:100 #6
18 GPS:1204 GPSAltitude #1
19 GPS:1 #2
20 GPS:538976288 GPSMapDatum #1
21 GPS:538976288 #2
22 GPS:32 #3
23 GPS:875638834 GPSDateStamp #1
24 GPS:976302138 #2
25 GPS:13361 #3
26 GPS:0
27 GPS:0
28 GPS:0
29 GPS:78 N GPSLatitudeRef
30 GPS:87 W GPSLongitudeRef
31 GPS:0 ? GPSAltitudeRef
这只是通过对源代码进行一些挖掘来完成的,因此请原谅任何错误......
我希望这能让你走得更远。