0

相机应用程序有panorama开源解决方案吗?Android我遇到了这些选项:

  1. 全景gl-android

  2. WideAnglePanoramaModule.java

但是他们看起来有点老,没有支持,有什么更新的吗?

我也遇到了这个页面

但是我找不到太多关于它的文档。

我想获得一个完整的解决方案,包括捕获图像、拼接和显示。

4

1 回答 1

0

看看这篇文章:

https://itnext.io/android-360-panorama-cedbfb47a9e

我不喜欢的是所有图像都来自资产。我用来自firebase的图像做到了:

添加依赖:

  dependencies {
  /*
  * Google VR SDK
  * Release version: https://github.com/googlevr/gvr-android-sdk/releases
  * */
  implementation 'com.google.vr:sdk-panowidget:1.180.0'
  implementation 'com.github.silvestrpredko:dot-progress-bar:1.1'
  }

添加类

public class SimpleVrPanoramaActivity extends Activity {

@BindView(R.id.progressBar2)
DotProgressBar dotProgressBar;

@BindView(R.id.pano_view)
VrPanoramaView panoWidgetView;

private String bar_panorama1;
private String mPost_key = null;
private Bitmap[] bitmaps = new Bitmap[1];
private DatabaseReference databaseReference;
private VrPanoramaView.Options panoOptions = new VrPanoramaView.Options();

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_panorama);

    ButterKnife.bind(this);


    if (getIntent().getExtras() != null) {
        mPost_key = getIntent().getExtras().getString("bar_id");
    }

    panoOptions.inputType = VrPanoramaView.Options.TYPE_MONO;

    databaseReference = FirebaseDatabase.getInstance().getReference().child("bars").child(mPost_key).child("pano");

    fetchPanorama();
}

private void fetchPanorama() {

    databaseReference.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(@NonNull DataSnapshot dataSnapshot) {

            bar_panorama1 = dataSnapshot.child("i1").getValue(String.class);

            glideImage(bar_panorama1);
        }

        @Override
        public void onCancelled(@NonNull DatabaseError databaseError) {

            Toast.makeText(SimpleVrPanoramaActivity.this, "Проверьте подключение к интернету!", Toast.LENGTH_LONG).show();
        }
    });
}

public void glideImage(String bar_panorama) {

    Glide.with(SimpleVrPanoramaActivity.this)
            .asBitmap()
            .load(bar_panorama)
            .into(new CustomTarget<Bitmap>() {
                @Override
                public void onLoadFailed(@Nullable Drawable errorDrawable) {

                    dotProgressBar.setVisibility(View.GONE);
                }

                @Override
                public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {

                    bitmaps[0] = resource;

                    panoWidgetView.loadImageFromBitmap(bitmaps[0], panoOptions);

                    dotProgressBar.setVisibility(View.GONE);
                }

                @Override
                public void onLoadCleared(@Nullable Drawable placeholder) {
                }
            });
}

@Override
protected void onPause() {
    panoWidgetView.pauseRendering();
    super.onPause();
}

@Override
protected void onResume() {
    super.onResume();
    panoWidgetView.resumeRendering();
}

@Override
protected void onDestroy() {
    // Destroy the widget and free memory.
    panoWidgetView.shutdown();

    super.onDestroy();
}


}

添加xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/colorPrimary"
tools:context=".aktau.panorama.PanoramaGLActivity">

<include
    android:id="@+id/toolbar_pano"
    layout="@layout/toolbar_pano"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true" />

<View
    android:id="@+id/yellow_layer"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="@color/colorOrange"
    android:layout_below="@+id/toolbar_pano"
     />

<com.google.vr.sdk.widgets.pano.VrPanoramaView
    android:id="@+id/pano_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/yellow_layer"/>

<com.github.silvestrpredko.dotprogressbar.DotProgressBar
    android:id="@+id/progressBar2"
    android:layout_width="200dp"
    android:layout_height="50dp"
    android:layout_below="@+id/toolbar_pano"
    android:layout_alignParentBottom="true"
    android:layout_marginTop="0dp"
    android:layout_marginBottom="0dp"
    app:amount="3"
    android:layout_centerHorizontal="true"
    app:animationDirection="right"
    app:duration="@android:integer/config_shortAnimTime"
    app:endColor="@color/colorPrimaryDark"
    app:startColor="@color/colorLightBlue" />


</RelativeLayout>
于 2019-12-03T16:23:19.577 回答