Get a frame of depth image using Depth API ARCORE in Kotlin

  android, api, depth, kotlin

I am trying to get a frame of the Depth Image, my goal is not to see the frame but only to get the width and height and in the future get the data and send it by sockets to a server.
I am getting errors in the frame object. I already imported the "import com.google.ar.core.Frame" but it still doesn’t work. Can someone help? thanks

try {
                //val frame: Frame = session!!.update()
                val depthImage: Image = frame.acquireDepthImage()
                val depthTextureWidth = depthImage.width
                val depthTextureHeight = depthImage.height


                Log.i(TAG, "Working!!!!")
                Log.i(TAG, "Width!!!! ${depthTextureWidth}")
                Log.i(TAG, "Height!!!! ${depthTextureHeight}")

                depthImage.close()
            } catch (e: NotYetAvailableException) {
                // This means that depth data is not available yet.
                // Depth data will not be available if there are no tracked
                // feature points. This can happen when there is no motion, or when the
                // camera loses its ability to track objects in the surrounding
                // environment.
            }

Source: Android Questions

LEAVE A COMMENT