Git Product home page Git Product logo

panoramagl's Introduction

PanoramaGL Android

PanoramaGL library was the first open source library in the world to see panoramic views on Android. This is a gradle build adaptation, along with other changes and updates. I am evolving the library to something easy to use any help is welcome.

The supported features are:

  • OpenGL ES 1.0 and 1.1.
  • Support for spherical, cubic and cylindrical panoramic images.
  • Scrolling and continuous scrolling.
  • Inertia to stop continuous scrolling.
  • Zoom in and zoom out (moving two fingers on the screen).
  • Reset (placing three fingers on the screen or shaking the device).
  • Scrolling left to right and from top to bottom using the accelerometer.
  • Sensorial rotation (Only compatible for devices with Gyroscope or Accelerometer and Magnetometer).
  • Full control of camera including field of view, zoom, rotation, rotation range, animations, etc.
  • Hotspots with commands.
  • Simple JSON protocol.
  • Creation of virtual tours using the JSON protocol or with programming.
  • Transitions between panoramas.
  • Support for events.

Usage

https://jitpack.io/#hannesa2/panoramagl

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
    implementation 'com.github.hannesa2:panoramagl:$latestVersion'
}

Create a PLManagerobject and add the bindings to the activity lifecycle methods:

    private PLManager plManager;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        plManager = new PLManager(this);
        plManager.onCreate();
    }

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

    @Override
    protected void onPause() {
        plManager.onPause();
        super.onPause();
    }
    @Override
    protected void onDestroy() {
        plManager.onDestroy();
        super.onDestroy();
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return plManager.onTouchEvent(event);
    }

Next set the view, before calling plManager.onCreate:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        plManager = new PLManager(this);
        plManager.setContentView(R.layout.activity_main);
        plManager.onCreate();
    }

Finally add the panorama you want, for example;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        plManager = new PLManager(this);
        plManager.setContentView(R.layout.activity_main);
        plManager.onCreate();

        PLSphericalPanorama panorama = new PLSphericalPanorama();
        panorama.getCamera().lookAt(30.0f, 90.0f);

        panorama.setImage(new PLImage(PLUtils.getBitmap(this, R.raw.sighisoara_sphere), false));
        plManager.setPanorama(panorama);
    }

License PanoramaGL Android

Copyright 2022

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

panoramagl's People

Contributors

dependabot[bot] avatar gradle-update-robot avatar grammesm avatar hannesa2 avatar harshsharma94 avatar lespinsideg avatar marcosanz12 avatar marianmoldovan avatar martirius avatar wcl9900 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

panoramagl's Issues

Panorama Not Moving

I can't get the panorama image to move when touched. It stays static and cannot be interacted with. I have the panorama on a fragment.

class CaptureInteriorLockFragment :
  CaptureBaseFragment<FragmentCaptureInteriorLockBinding>() {
  private lateinit var plManager: PLManager
  private val panorama = PLSphericalPanorama()

  override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)
    captureViewModel = ViewModelProvider(
      requireActivity(),
      ViewModelFactory(getFragmentRepository())
    )[getViewModel()]

    plManager = PLManager(view.context).apply {
      setContentView(binding.photosphereViewer)
      onCreate()
      isInertiaEnabled = false
      isAccelerometerEnabled = false
      isZoomEnabled = false
    }

    panorama.setImage(PLImage(PLUtils.getBitmap(requireContext(), R.raw.interior_test_1), false))
    plManager.panorama = panorama
  }

  override fun onResume() {
    super.onResume()
    plManager.onResume()
  }

  override fun onPause() {
    super.onPause()
    plManager.onPause()
  }

  override fun onDestroy() {
    super.onDestroy()
    plManager.onDestroy()
  }

  override fun getFragmentBinding(
    inflater: LayoutInflater,
    container: ViewGroup?
  ): FragmentCaptureInteriorLockBinding =
    FragmentCaptureInteriorLockBinding.inflate(inflater, container, false)
}

Is there anything that i am missing here?

Thanks!

Does not support ARM v9 Nexus 6P

Hi @marianmoldovan , thanx for cool gradle adaptation of the library. I tried to do it myself but it seems eclipse project does not support Android 6. I tried this repository and it runs successfully on Android 6 but not on Nexus 6P. Do you have any suggestions how it can be fixed?

I build library with tools v23 and set APP_ABI := all. I got this warning in eclipse

jni/com_panoramagl_opengl_GLUES.c: In function 'gluesCallErrorCallback': jni/com_panoramagl_opengl_GLUES.c:76:77: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] (*env)->CallStaticVoidMethod(env, sclass, methodID, (jvalue*)qobj, (jint)(jvalue*)(jint)gluesErrorCode);
Can this warning be related to Nexus 6P error?

Any suggestions appreciated

HotSpot stretching deformation

HotSpot Can you support always facing the screen to avoid stretching deformation?
(HotSpot是否可以支持一直正对屏幕避免拉伸变形)

How to create Virtual Tours using multiple Panoramas/360

Hi,

I am interested in the point mentioned in README "Creation of virtual tours using the JSON protocol or with programming."

  • Is there any wiki page explaining the steps. I couldn't see any demo sample in the app.
    Kindly provide some tutorials for this.

Thanks for the awesome project..

Hotspot on Click

Not Able to get the actual touch coordinate of the panorama image
create a hotspot with GestureDetector - on long press on the Screen

error java.lang.NullPointerException

 public void vr() {
        setContentView(R.layout.fragment_vr);
        PLManager plManager = new PLManager(MainActivity.this);
        plManager.setContentView(R.layout.fragment_vr);
        PLSphericalPanorama panorama = new PLSphericalPanorama();
        panorama.getCamera().lookAt(30.0f, 90.0f);

        panorama.setImage(new PLImage(PLUtils.getBitmap(MainActivity.this, R.raw.room_vr), false));
        plManager.setPanorama(panorama);
    }

when i try to load the R.layout.fragment_vr it says
Required type:
ViewGroup
Provided:
int

then tried this

 LayoutInflater inflater = LayoutInflater.from(MainActivity.this);
        ViewGroup contentView = (ViewGroup) inflater.inflate(R.layout.fragment_vr, null);
        plManager.setContentView(contentView);

and i get this error
java.lang.NullPointerException
at com.panoramagl.PLManager.onGLSurfaceViewCreated(PLManager.kt:1393)

Load Image From URI / URL to Panorama

I can't get an image to display in the panorama when the image is from a URI / URL and not from a fixed image file that's in the res folder. It's shows a blank panorama. It works fine when the image is not from a URI.

Utility Functions:

fun getBitmap(contentResolver: ContentResolver, fileUri: Uri?): Bitmap {
  return ImageDecoder.decodeBitmap(ImageDecoder.createSource(contentResolver, fileUri!!))
}

fun resizePhotosphere(bitmap: Bitmap): Bitmap {
  return Bitmap.createScaledBitmap(bitmap, 2048,1024, true)
}
class CaptureInteriorLockFragment :
  CaptureBaseFragment<FragmentCaptureInteriorLockBinding>() {
  private lateinit var plManager: PLManager
  private val panorama = PLSphericalPanorama()

  override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)
   
    captureViewModel = ViewModelProvider(
      requireActivity(),
      ViewModelFactory(getFragmentRepository())
    )[getViewModel()]

    plManager = PLManager(view.context).apply {
      setContentView(binding.photosphereViewer)
      onCreate()
      isInertiaEnabled = false
      isAccelerometerEnabled = false
      isZoomEnabled = false
    }

    var bitmap = resizePhotosphere(getBitmap(view.context.contentResolver, captureViewModel.interiorUri.value))
    panorama.setImage(PLImage(bitmap, false))
    plManager.panorama = panorama

    binding.photosphereTest.setImageBitmap(bitmap)

    binding.root.setOnTouchListener { _, event ->
      plManager.onTouchEvent(event)
    }
  }

  override fun onResume() {
    super.onResume()
    plManager.onResume()
  }

  override fun onPause() {
    super.onPause()
    plManager.onPause()
  }

  override fun onDestroy() {
    super.onDestroy()
    plManager.onDestroy()
  }

  override fun getFragmentBinding(
    inflater: LayoutInflater,
    container: ViewGroup?
  ): FragmentCaptureInteriorLockBinding =
    FragmentCaptureInteriorLockBinding.inflate(inflater, container, false)
}

Problem with hotspot and ray collision

Hi,
I have noticed a problem with touch event interceptor on an hotspot.
It seems that vertices are not calculated correctly (but hotspots are showed correctly).

Screen Shot 2021-05-24 at 18 07 32

As shown in the picture, bounding boxes are delimited inside white box and goes outside of the size of the picture.

In this case instead, the box is completely shifted on a lower Y (and all others of this type), and no collision is intercepted if i click on the grey hotspot; instead if I click on the white box, the touch is intercepted.

Screen Shot 2021-05-24 at 17 58 31

Don't really know where to see for a solution.

64 bits support

Ty for this awsome library.
For information, i ported it on Xamarin Android, it works really well.
I still have a pb : panoramagl doesn't support x86_64 and arm64-v8a arhitecture.
Can you confirm this point ? Or did i miss something ?
There isn't any 64 bits versions of libglues.so ? Any help, advice on this point would really be appreciated.
64 bits will be mandatory in 2019. So ...
Ty in advance.

HotSpot not work

on 1.9.1 panorama.addHotspot not work. Arrows are not displayed

Mandatory HIGH_SAMPLING_RATE_SENSORS special permission in Android 12 +

Hello !
I've seen the library currently requires the permission HIGH_SAMPLING_RATE SENSORS in API 31+ .

When SensorManager registers the listener for the sensors, it uses a sampling rate of 33 microseconds and this is called at least
during plManager.startSensorialRotation() & plManager.onResume().

These functions call activateAccelerometer(), activateGyroscope() and activateMagnetometer() registering the listener.
I don't know If there's any way to change the sampling rate to avoid using the permission which makes publishing apps in the Play Store harder because it requires a google review

The listener ->
protected fun activateGyroscope(): Boolean { return sensorManager.registerListener( this, sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), (PLConstants.kDefaultGyroscopeInterval * 1000.0f).toInt() ) }

The error ->
java.lang.RuntimeException: Unable to resume activity {com.myapplication.app/com.myapplication.app.SampleActivity}: java.lang.SecurityException: To use the sampling rate of 33 microseconds, app needs to declare the normal permission HIGH_SAMPLING_RATE_SENSORS.

Thanks

stop continuous scrolling

I am using android panoramaGL,it is working fine 360 sphere and sensor rotation. But when you click on image and scroll some distance with out lifting fingure on screen, it is scrolling continuously(my fingure is not moving but it is scrolling)how to stop it...

freeze ui

Hi thanks for creating this library, when I set panorama image the app UI freezes

Out of memory error when click next/prev

Hello

We are using the library to show tiled images, we fetch each tile then create a bitmap for each, and then merge them to create the whole bitmap. But when we click next/prev buttons a few times we get out of memory error. We recycle the previous bitmaps on every click on the buttons, but on the profiler, it shows that they're still existing in the ram.

Can you help me to fix this issue?

Thanks

Black screen instead of panorama

Hi, i've created activity that loads photosphere and should display it:

class PreviewActivity : AppCompatActivity() {
    lateinit var vb: ActivityPreviewBinding
    var plManager: PLManager? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        vb = ActivityPreviewBinding.inflate(layoutInflater)
        setContentView(vb.root)
        plManager = PLManager(this)?.apply {
            isAccelerometerEnabled = false
            isInertiaEnabled = false
            isZoomEnabled = false
            setContentView(vb.activityPreviewFrame)
            onCreate()
        }
        intent.getStringExtra(EXTRA_URL)?.let { url ->
            lifecycleScope.async(Dispatchers.IO) {
                delay(1500)
                val imageLoader =
                    Coil.imageLoader(this@PreviewActivity)
                val request = ImageRequest.Builder(this@PreviewActivity)
                    .data(url!!)
                    .target { drawable ->
                        lifecycleScope.async(Dispatchers.Main) {
                            try {
                                val bitmap = (drawable as BitmapDrawable).bitmap
                                val panorama = PLSphericalPanorama()
                                panorama.setImage(PLImage(bitmap))
                                vb.activityPreviewFrameTmp.setImageDrawable(drawable)
                                plManager?.panorama = panorama
                            } catch (e: Exception) {
                                Log.d("PreviewActivity", "${e.message}")
                            }
                        }
                    }
                    .build()
                imageLoader.execute(request)
            }
        }
    }

    override fun onPause() {
        super.onPause()
        plManager?.onPause()
    }

    override fun onResume() {
        super.onResume()
        plManager?.onResume()
    }

    override fun onDestroy() {
        super.onDestroy()
        plManager?.onDestroy()
    }

    companion object {
        val EXTRA_URL = "EXTRA_URL"
    }

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:id="@+id/activity_preview_frame"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    <ImageView
        android:id="@+id/activity_preview_frame_tmp"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:visibility="invisible"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

I can see image loaded properly into imageView, but panoramaGL is not displaying anything (nothing in logcat). I've tried versions 1.9.3 and up to latest one. Phone: Samsung Galaxy S10, Android 12

Add a hotspot with event

Hi dear , I need to know how i can convert from the clicked touch event x,y to a panorama coordinates to add a new Hotspot in android kotlin , please if you can help!

Development support

How can we use multiple images for a single cube face?. We need to place part images for the single face of a cube.

Thank you.

allow gradle to include lib via JitPack repository dependency

If you tag the sourcecode of the lib with a version number "0.1.1" develeoppers can use the lib via jitpack like this:

Steps to use the lib

Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Step 2. Add the dependency

dependencies {
    implementation  'com.github.marianmoldovan:panoramagl:0.1.1'
}

if you add a tag in the git repository can you also add the "Steps to use the lib" to Reademe.md ?

Update 2018-10-27:

Currently jitpack builds fails with error message

No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android

Google has removed ABI cpu support and old buildtools fail because they check for "ABI" :-(

See https://stackoverflow.com/questions/35128229/error-no-toolchains-found-in-the-ndk-toolchains-folder-for-abi-with-prefix-llv for details.

To fix this you also have to upgrade build-tools and the gradle version, too

classpath "com.android.tools.build:gradle:3.2.0"

If you want i can do this for you and provide you a merge request for this.

I have already done this for https://github.com/k3b/SimplePanorama that uses "panoramagl"

Using more recent gradle/build tools via jitpack may also solve #9

OutOfMemoryError

Thanks for creating this library, when I set panorama image many times by clicking previous/next buttons i got OutOfMemoryError.

Also i tried in Your sample project https://github.com/hannesa2/panoramagl/blob/master/app/src/main/java/com/panoramagl/sample/MainActivity.kt i got the same OutOfMemoryError.

My code:
val panorama = PLSphericalPanorama()
val plImage = PLImage(bm, false)
panorama.setImage(plImage)
plManager.panorama = panorama

After debugging i found that error is not happening when
plManager.panorama = panorama
is commented, so think that the problem is in that line

[Feature] Add images overlay panorama view

I'm checking your library and I want to make my app like the video below.

I just want to ask: Is it possible to overlay images onto your PanoramaView (PLSphericalPanorama)?

5974D825-AF28-4A1D-B589-ACCEC9AF608B.MOV

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.