DEV Community

Cover image for HowTo: Augmented Reality without ArCore -> kotlin + mobile sensors + Rx 💥 🚀
Mateusz for Netguru

Posted on

HowTo: Augmented Reality without ArCore -> kotlin + mobile sensors + Rx 💥 🚀

Augmented Reality

Do you ever wanted to play with AR a little but didn't want to dive deep into whole ARCore experience?
In our company as a part of R&D research we developed a little library that provides you with a view showing labels of the destinations provided by you. It's an open source project so you can contribute or write suggestions of new features at our repo https://github.com/netguru/ar-localizer-view-android

You can easily use it in your projects:

Using library

  1. Add repository in you projects build.gradle file

    repositories {
        maven {  url 'https://dl.bintray.com/netguru/maven/' }
        ...
    }
    
  2. Add library dependency

        dependencies {
                implementation 'com.netguru.arlocalizerview:arlocalizerview:0.1.0'
        }
    
  3. Add view to your layout

     <co.netguru.arlocalizer.arview.ARLocalizerView
            android:id="@+id/arLocalizer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />
    
  4. In in arLocalizerView onCreate method you need to provide

    interface ARLocalizerDependencyProvider {
        fun getSensorsContext(): Context
        fun getARViewLifecycleOwner(): LifecycleOwner
        fun getPermissionActivity(): Activity
    }
    
    fun arLocalizerView.onCreate(arLocalizerDependencyProvider: ARLocalizerDependencyProvider)
    
  5. In order to process the permission request you need to provide permission results to the view.

        fun onRequestPermissionResult(
            requestCode: Int,
            permissions: Array<out String>,
            grantResults: IntArray
        )
    
  6. Finally in order to display the destination labels on the camera preview use

    arLocalizerView.setDestinations(destinations: List<LocationData>)
    

Library in action!

Library in action
Library in action
Library in action

Top comments (0)