【问题标题】:Use PanoramaApi with custom equirectangular image from Assets folder将 PanoramaApi 与 Assets 文件夹中的自定义 equirectangular 图像一起使用
【发布时间】:2016-01-25 11:08:06
【问题描述】:

我有一个像这样的 equirectangular 图像:

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

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

不知何故,如果我检查 result.getViewerIntent,我会得到 null 作为返回值。

我的直觉认为这可能与这张图片不是用谷歌相机应用程序创建的事实有关,因此缺少一些元标记,但我不确定。

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

【问题讨论】:

    标签: android google-api-client android-assets


    【解决方案1】:

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

    这是我找到的。

    here 这个家伙提到了使用 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>
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-27
      • 2016-07-30
      • 1970-01-01
      • 1970-01-01
      • 2012-07-28
      • 2016-06-28
      • 1970-01-01
      相关资源
      最近更新 更多