Android 将PanoramaApi与资源文件夹中的自定义等矩形图像一起使用

Android 将PanoramaApi与资源文件夹中的自定义等矩形图像一起使用,android,google-api-client,android-assets,Android,Google Api Client,Android Assets,我有一个这样的等矩形图像: 我的AssetFolder中有图像,因此我将此uri传递给Panorama.PanoramaApi.loadPanoramaInfo方法: Uri uri = Uri.parse("file:///android_asset/panorama/equi_1.jpg"); 不知何故,如果我检查result.getviewerinent,我会得到null作为返回值 我的直觉告诉我,这可能是因为这张图片不是用谷歌相机应用程序创建的,因此丢失了一些元标记,但我不确定 “我

我有一个这样的等矩形图像:

我的AssetFolder中有图像,因此我将此uri传递给Panorama.PanoramaApi.loadPanoramaInfo方法:

Uri uri = Uri.parse("file:///android_asset/panorama/equi_1.jpg");
不知何故,如果我检查result.getviewerinent,我会得到null作为返回值

我的直觉告诉我,这可能是因为这张图片不是用谷歌相机应用程序创建的,因此丢失了一些元标记,但我不确定

“我的全景”活动的完整代码:

public class PanoramaActivity extends Activity implements GoogleApiClient.ConnectionCallbacks,
        GoogleApiClient.OnConnectionFailedListener {

    public static final String PANORAMA_URI = "panorama_uri";
    private GoogleApiClient gacClient;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        gacClient = new GoogleApiClient.Builder(this, this, this)
                .addApi(Panorama.API)
                .build();
    }

    @Override
    public void onStart() {
        super.onStart();
        gacClient.connect();
    }

    @Override
    public void onConnected(Bundle connectionHint) {
        Intent intent = getIntent();
        if (intent != null) {
            String fileUri = intent.getStringExtra(PANORAMA_URI);
            if (fileUri != null && !fileUri.isEmpty()) {
                Uri uri = Uri.parse("file:///android_asset/panorama" + fileUri);

                Panorama.PanoramaApi.loadPanoramaInfo(gacClient, uri).setResultCallback(
                        new ResultCallback<PanoramaApi.PanoramaResult>() {
                            @Override
                            public void onResult(PanoramaApi.PanoramaResult result) {
                                Intent i;
                                if (result.getStatus().isSuccess() && (i = result.getViewerIntent()) != null) {
                                    startActivity(i);
                                } else {
                                    // Handle unsuccessful result
                                }
                            }
                        });
            } else {
                finish();
            }
        } else {
            finish();
        }
    }

    @Override
    public void onConnectionSuspended(int cause) {
        // Handle connection being suspended
    }

    @Override
    public void onConnectionFailed(ConnectionResult status) {
        // Handle connection failure.
    }

    @Override
    public void onStop() {
        super.onStop();
        gacClient.disconnect();
    }
}
公共类PanoramaActivity扩展活动实现GoogleAppClient.ConnectionCallbacks,
GoogleAppClient.OnConnectionFailedListener{
公共静态最终字符串PANORAMA\u URI=“PANORAMA\u URI”;
私人GoogleapClient gacClient;
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
gacClient=new GoogleApiClient.Builder(这个,这个,这个)
.addApi(Panorama.API)
.build();
}
@凌驾
public void onStart(){
super.onStart();
gacClient.connect();
}
@凌驾
未连接的公共无效(捆绑连接提示){
Intent=getIntent();
if(intent!=null){
stringfileuri=intent.getStringExtra(全景URI);
if(fileUri!=null&&!fileUri.isEmpty()){
Uri=Uri.parse(“file:///android_asset/panorama“+fileUri);
Panorama.PanoramaApi.loadPanoramaInfo(gacClient,uri).setResultCallback(
新的ResultCallback(){
@凌驾
公共void onResult(panoramapi.PanoramaResult){
意图一;
if(result.getStatus().issucess()&&(i=result.getviewerinent())!=null){
星触觉(i);
}否则{
//处理不成功的结果
}
}
});
}否则{
完成();
}
}否则{
完成();
}
}
@凌驾
连接上的公共无效已暂停(内部原因){
//句柄连接被挂起
}
@凌驾
public void onConnectionFailed(连接结果状态){
//处理连接故障。
}
@凌驾
公共void onStop(){
super.onStop();
gacClient.disconnect();
}
}

我认为你的直觉是正确的,谷歌可能需要元数据来解析图像

这是我发现的

这家伙提到了使用photoshop将xml元数据嵌入jpg

<?xpacket begin='' id=''?><x:xmpmeta xmlns:x='adobe:ns:meta/'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about="" xmlns:GPano="http://ns.google.com/photos/1.0/panorama/">
    <GPano:UsePanoramaViewer>True</GPano:UsePanoramaViewer>
    <GPano:CaptureSoftware>Photo Sphere</GPano:CaptureSoftware>
    <GPano:StitchingSoftware>Photo Sphere</GPano:StitchingSoftware>
    <GPano:ProjectionType>equirectangular</GPano:ProjectionType>
    <GPano:PoseHeadingDegrees>350.0</GPano:PoseHeadingDegrees>
    <GPano:InitialViewHeadingDegrees>90.0</GPano:InitialViewHeadingDegrees>
    <GPano:InitialViewPitchDegrees>0.0</GPano:InitialViewPitchDegrees>
    <GPano:InitialViewRollDegrees>0.0</GPano:InitialViewRollDegrees>
    <GPano:InitialHorizontalFOVDegrees>75.0</GPano:InitialHorizontalFOVDegrees>
    <GPano:CroppedAreaLeftPixels>0</GPano:CroppedAreaLeftPixels>
    <GPano:CroppedAreaTopPixels>0</GPano:CroppedAreaTopPixels>
    <GPano:CroppedAreaImageWidthPixels>4000</GPano:CroppedAreaImageWidthPixels>
    <GPano:CroppedAreaImageHeightPixels>2000</GPano:CroppedAreaImageHeightPixels>
    <GPano:FullPanoWidthPixels>4000</GPano:FullPanoWidthPixels>
    <GPano:FullPanoHeightPixels>2000</GPano:FullPanoHeightPixels>
    <GPano:FirstPhotoDate>2012-11-07T21:03:13.465Z</GPano:FirstPhotoDate>
    <GPano:LastPhotoDate>2012-11-07T21:04:10.897Z</GPano:LastPhotoDate>
    <GPano:SourcePhotosCount>50</GPano:SourcePhotosCount>
    <GPano:ExposureLockUsed>False</GPano:ExposureLockUsed>
</rdf:Description>

真的
光球
光球
等矩形
350
90
0
0
75
0
0
4000
2000
4000
2000
2012-11-07T21:03:13.465Z
2012-11-07T21:04:10.897Z
50
假的

该项目显示了在panorama api中加载jpg的示例。我不知道如何从jpg中读取元数据,但我敢说,这对您来说非常有趣,可能会有所帮助。jpg位于原始资产文件夹中