2016-01-25 28 views
1

定製等距離長方圓柱像我有這樣一個等距離長方圓柱投影圖像:使用PanoramaApi從Assets文件夾

equirectangular image

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

回答

1

我覺得你的直覺是正確的,谷歌可能需要元數據來分析圖像。

這是我發現的。

這個人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位於原始資產文件夾中。

相關問題