dji-sdk / Mobile-SDK-Android

DJI Mobile SDK for Android: http://developer.dji.com/mobile-sdk/
Other
978 stars 580 forks source link

Laser measure information H20T #1264

Open vfrabel opened 8 months ago

vfrabel commented 8 months ago

Hello everyone,

I am trying to show on screen the laser distance measurement of my H20T camera but something is not working. I use a M350RTK and the 4.17 version of the msdk. I have assumed that I should use the infrared lens of the camera but maybe I am wrong.

Below you can see the code where I deal with it. Do you know why is it not working? Thanks.


private lateinit var laserMeasureInformationCallback: LaserMeasureInformation.Callback

// ...

laserMeasureInformationCallback = LaserMeasureInformation.Callback {

     val laserMeasureInformation =  it.targetDistance

     Log.d("LASER INFO", laserMeasureInformation.toString())

}

// ...

val camera = DJISDKManager.getInstance().product!!.camera!!
val lenses = camera.lenses

var lens = camera.getLens(0)

for (pos in lenses!!.indices) {

     if (lenses[pos].type.toString() == "INFRARED_THERMAL") {

          lens = lenses[pos]

     }

}

camera.setLaserEnabled(true) {

     if (it == null) {

          Log.d("LaserEnabled", "True")

          lens.setLaserMeasureInformationCallback { laserMeasureInformationCallback ->

               Log.d("LaserInfo", "${laserMeasureInformationCallback.targetDistance}")

          }
     }
}
dji-lyt commented 8 months ago

Laser measurement can be used with every lens. What does "not working" refer to? If you are indoors, you need to use a simulator or DA2 to provide the drone with simulated GPS signals, so that the laser measurement function can obtain data.