将PanoramaApi与Assets文件夹中的自定义等角矩形图像一起使用 [英] Use PanoramaApi with custom equirectangular image from Assets folder

查看:297
本文介绍了将PanoramaApi与Assets文件夹中的自定义等角矩形图像一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have an equirectangular image like this:

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

I have the image in my AssetsFolder, therefor I pass this uri to the Panorama.PanoramaApi.loadPanoramaInfo method:

Uri uri = Uri.parse("file:///android_asset/panorama/equi_1.jpg");

以某种方式,如果我检查result.getViewerIntent,我将得到null作为返回值.

Somehow, if I check the result.getViewerIntent, I get null as return value.

我的直觉认为这可能与以下事实有关:该图片不是使用Google相机应用创建的,因此缺少一些元标记,但我不确定.

My gut feeling says this could have to do with the fact that this image is not created with the google camera app, and therefor missing some meta tags, but I'm not sure.

我的PanoramaActivity的完整代码:

The complete code of my PanoramaActivity:

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();
    }
}

推荐答案

我认为您的直觉是正确的,Google可能需要元数据来解析图像.

I think your gut is correct, Google probably requires metadata to parse the image.

这就是我发现的东西.

此人此处提到了有关使用photoshop将xml元数据嵌入jpg中的信息. >

This guy here mentions about using photoshop to embed xml metadata into a 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>

通过这里该项目显示了在全景图api中加载jpg的示例.我不知道如何从该jpg中读取元数据,但是我敢说它对您来说很有趣并且可能会有所帮助. jpg位于原始资产文件夹中.

Over here the project shows an example of loading a jpg in the panorama api. I don't know how to read the metadata from that jpg, but I'd venture to say it will be pretty interesting for you and probably helpful. The jpg is in the raw assets folder.

这篇关于将PanoramaApi与Assets文件夹中的自定义等角矩形图像一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆