问题描述
我开发的应该充分利用谷歌相机的新的深度图生成功能的Android应用程序。
基本上谷歌已经说明使用的元数据
我可以访问大部分的元数据,但不幸的是最重要的数据是EN $ C $光盘作为extendedXmp,我不能得到任何XMP解析库正确解析吧!
我试过用CC-成像,元数据提取以及最近坯XMPCore
XMPCore也许能处理扩展版本,但没有文件我怎样才能得到它来解析从JPG文件中的数据,其假设的原始数据XMP要传递
有没有正确执行XMP解析,包括的JPG文件扩展部件或我只是做错了什么?
下面是我的尝试:
随着公地成像:
{尝试
。串imageParser =新JpegImageParser()getXmpXml(新ByteSourceInputStream(的ImageStreamimg.jpg),新的HashMap&下;串,对象>()); Log.v(TAG,imageParser); }赶上(ImageReadException E1){
// TODO自动生成catch块
e1.printStackTrace();
}
使用元数据提取
元数据元数据= ImageMetadataReader.readMetadata(
新的BufferedInputStream(的ImageStream),FALSE);
XmpDirectory XMP元数据=
.getDirectory(XmpDirectory.class);
XMPMeta xmpMeta = xmp.getXMPMeta(); 字符串URI =http://ns.google.com/photos/1.0/depthmap/; Log.v(TAG,xmpMeta.doesPropertyExist(URI,GDepth:格式)+); 尝试{
XMPProperty hasExtendedXMP = xmpMeta.getProperty(http://ns.adobe.com/xmp/note/,xmpNote:HasExtendedXMP); Log.v(。TAG,hasExtendedXMP.getValue()的toString()++新的String(Base64.de code(hasExtendedXMP.getValue()的toString(),Base64.DEFAULT))); }赶上(XMPException E){
e.printStackTrace();
}
起初,Adobe公司没想到的XMP数据长度将超过一JPEG段(约64K)和XMP规格的限制规定的XMP数据必须符合成一个。后,当他们发现单个JPEG APP1段是没有大到足以容纳XMP数据,他们改变了规范以允许整个XMP数据的多个APP1段。数据被分为两部分:标准的XMP和ExtendedXMP。标准XMP部分是一个正常的XMP结构与包包装而ExtendedXMP部分不具有包包装。所述ExtendedXMP数据可以进一步划分,以适应成多个APP1
下面的报价是从Adobe XMP规范第3部分为ExtendedXMP块为JPEG APP1:
We can see besides the null-terminated string as an id for the ExtendedXMP data, there is also a GUID which should be the same value as the one found in the standard XMP part. The offset is used to join the different parts of the ExtendedXMP - so the sequence for the ExtendedXMP APP1 may not even be in order. Then come the actual data part and this is why @Matt's answer need some way to fix the string. There is another value - full length of the ExtendedXMP serialization which serves two purposes: check the integrity of the data as well as provides the buffer size for joining the data.
When we found a ExtendedXMP segment, we need to join the current data with the other ExtendedXMP segments and finally got the whole ExtendedXMP data. We then join the two XML tree together (removing the GUID from the standard XMP part as well) to retrieve the entire XMP data.
I have coded something in Java to extract and insert XMP as well as ExtendedXMP. One of the usecase for the ExtendedXMP is for Google's depth map data which in fact is a grayscale image hidden inside the actual image as a metadata, and in the case of JPEG, as XMP data. The depth map image could be used for example to blur the original image. The depth map data are usually large and have to be split into standard and extended XMP parts. The whole data is Base64 encoded and could be in PNG format.
The following is an example image and the extracted depth map:
The original image comes from here.
这篇关于读取JPG文件的XMP元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!