Android Question DJI sdk : get camera histograms

freedom2000

Well-Known Member
Licensed User
Longtime User
Hi all,

I have tried, with the help of a well known member, to get the camera histograms from the DJI SDK.

The documentation is here : https://developer.dji.com/api-refer...ra.html#djicamera_sethistogramcallback_inline

Basically it looks very similar to the GetGimbal method,
the following code is working for the gimbal

B4X:
Sub setGimbalStateListener
    Try
        Dim aircraftjo As JavaObject = Main.aircraft
        Dim gimbal As JavaObject = aircraftjo.RunMethod("getGimbal", Null)
        If gimbal.IsInitialized Then
            Dim callback As Object = gimbal.CreateEventFromUI("dji.common.gimbal.GimbalState$Callback", "gimbalState", Null)
            gimbal.RunMethod("setStateCallback", Array(callback))
        End If
    Catch
        Log(LastException)
    End Try
End Sub
Sub gimbalState_Event (MethodName As String, Args() As Object) As Object
    Dim gimbalState As JavaObject = Args(0)
    Dim gimbalAttitude As JavaObject
    Dim r, y As Float
    gimbalAttitude.InitializeNewInstance("dji.common.gimbal.Attitude", Array(myCameraState.gimbalPitch,r,y) )
    gimbalAttitude = gimbalState.RunMethod("getAttitudeInDegrees", Null)
    myCameraState.gimbalPitch = gimbalAttitude.RunMethod("getPitch",Null)
    Return Null
End Sub

So I tried to derive this code for the histogram but got stuck for... hours
Here is my latest attempt which rises an exception : java.lang.ClassNotFoundException: dji$sdk$camera$HistogramCallback

and the failing code :

B4X:
Sub getHistogram
    Try
        Dim aircraftjo As JavaObject = Main.aircraft
        Dim myCam As JavaObject = aircraftjo.RunMethod("getCamera",Null)
        If myCam.IsInitialized Then
            Dim callback As Object = myCam.CreateEventFromUI("dji.sdk.camera.HistogramCallback", "histogram",Null)
            myCam.RunMethod("setHistogramCallback", Array(callback))
        End If
    Catch
        Log(LastException)
    End Try
End Sub

Sub histogram_Event (MethodName As String, Args() As Object) As Object
    Dim histo As JavaObject = Args(0)
'    '....
    Return Null
End Sub

this code fails on this line : Dim callback As Object = myCam.CreateEventFromUI("dji.sdk.camera.HistogramCallback", "histogram",Null)
so well before the event !

If you have any idea.... thanks in advance
 

freedom2000

Well-Known Member
Licensed User
Longtime User
Try this
B4X:
Dim callback As Object = myCam.CreateEventFromUI("dji.sdk.camera$HistogramCallback", "histogram",Null)
I tried but got the same error : java.lang.ClassNotFoundException: dji$sdk$camera$HistogramCallback
 
Upvote 0
Top