Mobile-SDK-Android icon indicating copy to clipboard operation
Mobile-SDK-Android copied to clipboard

Unity aar plugin crash!

Open hanho5120 opened this issue 5 years ago • 20 comments

I'm working on a Unity aar plugin. If you put Unity context in the context variable part of the following function, an error will occur. Is there a workaround? Is there any other way to use sdk in Unity?

======================================================================= public void startSDKRegistration() { UnityPlayer.UnitySendMessage("GameObject", "Showtext", "startSDKRegistration"); if (isRegistrationInProgress.compareAndSet(false, true)) { AsyncTask.execute(new Runnable() { @Override public void run() { UnityPlayer.UnitySendMessage("GameObject", "Showtext", "registering, pls wait..."); showToast("registering, pls wait...");

                DJISDKManager.getInstance().registerApp(LoginActivity.this.getApplicationContext(), new DJISDKManager.SDKManagerCallback() {
                    @Override
                    public void onRegister(DJIError djiError) {
                        if (djiError == DJISDKError.REGISTRATION_SUCCESS) {
                            result = "Register";
                            DJISDKManager.getInstance().startConnectionToProduct();
                        } else {
                            showToast("Register sdk fails, please check the bundle id and network connection!");
                        }
                        Log.v(TAG, djiError.getDescription());
                    }

                    @Override
                    public void onProductDisconnect() {
                        result = "Product Disconnected============================2";
                        Log.d(TAG, "onProductDisconnect");
                        showToast("Product Disconnected============================2");
                        notifyStatusChange();

                    }
                    @Override
                    public void onProductConnect(BaseProduct baseProduct) {
                        Log.d(TAG, String.format("onProductConnect newProduct:%s", baseProduct));
                        result = "Product Disconnected============================3";
                        showToast("Product Connected====================================3");
                        notifyStatusChange();

                    }
                    @Override
                    public void onComponentChange(BaseProduct.ComponentKey componentKey, BaseComponent oldComponent,
                                                  BaseComponent newComponent) {

                        if (newComponent != null) {
                            newComponent.setComponentListener(new BaseComponent.ComponentListener() {

                                @Override
                                public void onConnectivityChange(boolean isConnected) {
                                    Log.d(TAG, "onComponentConnectivityChanged: " + isConnected);
                                    notifyStatusChange();
                                }
                            });
                        }
                        Log.d(TAG,
                                String.format("onComponentChange key:%s, oldComponent:%s, newComponent:%s",
                                        componentKey,
                                        oldComponent,
                                        newComponent));

                    }

                    @Override
                    public void onInitProcess(DJISDKInitEvent djisdkInitEvent, int i) {

                    }

                    @Override
                    public void onDatabaseDownloadProgress(long l, long l1) {

                    }

                });
            }
        });
    }
}

hanho5120 avatar Mar 04 '20 15:03 hanho5120

Public comment from Luce Luo in Zendesk ticket #32583:

Dear Customer,

Thank you for contacting DJI. Sorry about it. We have no test with Unity and can't promise the MSDK can work with it.

It's recommended to following the official documentation to develop. https://developer.dji.com/mobile-sdk/documentation/introduction/index.html

Thanks,

Luce Luo DJI Dev Team

dji-dev avatar Mar 05 '20 06:03 dji-dev

@hanho5120 have you by any chance managed to solve your issue? I'm also attempting to develop an aar unity plugin, It seems to consistently crash on Helper.install(MApplication.this);

kandabi avatar Apr 19 '20 21:04 kandabi

@hanho5120 have you by any chance managed to solve your issue? I'm also attempting to develop an aar unity plugin, It seems to consistently crash on Helper.install(MApplication.this);

Ive been cross-developing android and unity, along with ties to the DJI suite. I haven't tried the AAR option, but there are other options involved where you can use unity functions alongside the DJI sdk.

My only problem right now is trying to get the DJI camera feed into unity! Would be nice to get help on this, or to team up if you're interested.

roguestarslade avatar Jun 26 '20 04:06 roguestarslade

So you've solved the issue I've been having about the dji and unity connection :) congratz Is your camera issue about displaying the data recieved? Unity does not have a video decoder, therefore the only solution would be to decode it yourself - java has a native media player function that can already decode video streams, but if that doesn't work I have been working on a tello video stream decode using a native c++ plugin ( ffmpeg librar y) it works, but on higher bitrates there are stuttering in android machines, so its not perfect yet.

On Fri, Jun 26, 2020, 7:46 AM Slade Villena [email protected] wrote:

@hanho5120 https://github.com/hanho5120 have you by any chance managed to solve your issue? I'm also attempting to develop an aar unity plugin, It seems to consistently crash on Helper.install(MApplication.this);

Ive been cross-developing android and unity, along with ties to the DJI suite. I haven't tried the AAR option, but there are other options involved where you can use unity functions alongside the DJI sdk.

My only problem right now is trying to get the DJI camera feed into unity! Would be nice to get help on this, or to team up if you're interested.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dji-sdk/Mobile-SDK-Android/issues/489#issuecomment-649961987, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACKZ7EJMOFTUOMALEF2JTUTRYQR3XANCNFSM4LBK4HVQ .

kandabi avatar Jun 26 '20 09:06 kandabi

You mind sharing your code for the ffmpeg-based library? I'm willing to share some source from my end, basically 2 projects (one in Unity, the other in Android studio).

Much of my work is based on https://github.com/Unity-Technologies/uaal-example and also on https://github.com/robsondepaula/unity-android-native-camera (basically, I've used both projects).

Anyway, hit me up on [email protected] ! Would love to collaborate with you since we're working on the same problems :)

So you've solved the issue I've been having about the dji and unity connection :) congratz Is your camera issue about displaying the data recieved? Unity does not have a video decoder, therefore the only solution would be to decode it yourself - java has a native media player function that can already decode video streams, but if that doesn't work I have been working on a tello video stream decode using a native c++ plugin ( ffmpeg librar y) it works, but on higher bitrates there are stuttering in android machines, so its not perfect yet. On Fri, Jun 26, 2020, 7:46 AM Slade Villena @.***> wrote: @hanho5120 https://github.com/hanho5120 have you by any chance managed to solve your issue? I'm also attempting to develop an aar unity plugin, It seems to consistently crash on Helper.install(MApplication.this); Ive been cross-developing android and unity, along with ties to the DJI suite. I haven't tried the AAR option, but there are other options involved where you can use unity functions alongside the DJI sdk. My only problem right now is trying to get the DJI camera feed into unity! Would be nice to get help on this, or to team up if you're interested. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#489 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACKZ7EJMOFTUOMALEF2JTUTRYQR3XANCNFSM4LBK4HVQ .

roguestarslade avatar Jun 26 '20 13:06 roguestarslade

Is your camera issue about displaying the data received?

By the way, this is exactly my issue. class DJICodecManager has a problem with getRgbaData, when performed without the use of an android native activity (I use a Unity-based activity). The problem seems to be abstracted out, since its a lot of boilerplate OpenGL/Android API code, and also DJIs internal source regarding the decoder.

I basically thought I could getRgbaData, put it into glTexSubImage2D passing to a texture defined in Unity, but apparently getRgbaData and getYuvData for the DJICodecManager work only in the context of an Android native activity, with a proper TextureView (tied to a Layout).

Anyway, would love to collaborate with your solution. Unfortunately, I don't think a DJI unity-aar is possible quite yet, but it is possible to export from Unity to android (using Unity as a library), and then using the Android project as the base of the app.

Lets talk more on email! :)

Unity does not have a video decoder, therefore the only solution would be to decode it yourself - java has a native media player function that can already decode video streams, but if that doesn't work I have been working on a tello video stream decode using a native c++ plugin ( ffmpeg librar y) it works, but on higher bitrates there are stuttering in android machines, so its not perfect yet.

roguestarslade avatar Jun 26 '20 13:06 roguestarslade

Sure I dont mind sharing code, in your situation of using unity as a native library it should be relatively simple using the ffmpeg c++ code Im using to decode the video stream. Ill send you the github project i've used as well - ill try to do it on saturday or sunday.

On Fri, Jun 26, 2020, 5:00 PM Slade Villena [email protected] wrote:

Is your camera issue about displaying the data received?

By the way, this is exactly my issue. class DJICodecManager has a problem with getRgbaData, when performed without the use of an android native activity (I use a Unity-based activity). The problem seems to be abstracted out, since its a lot of boilerplate OpenGL/Android API code, and also DJIs internal source regarding the decoder.

I basically thought I could getRgbaData, put it into glTexSubImage2D passing to a texture defined in Unity, but apparently getRgbaData and getYuvData for the DJICodecManager work only in the context of an Android native activity, with a proper TextureView (tied to a Layout).

Anyway, would love to collaborate with your solution. Unfortunately, I don't think a DJI unity-aar is possible quite yet, but it is possible to export from Unity to android (using Unity as a library), and then using the Android project as the base of the app.

Lets talk more on email! :)

Unity does not have a video decoder, therefore the only solution would be to decode it yourself - java has a native media player function that can already decode video streams, but if that doesn't work I have been working on a tello video stream decode using a native c++ plugin ( ffmpeg librar y) it works, but on higher bitrates there are stuttering in android machines, so its not perfect yet.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dji-sdk/Mobile-SDK-Android/issues/489#issuecomment-650195417, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACKZ7EPMBGA4FJ6TJSQXQT3RYSSV5ANCNFSM4LBK4HVQ .

kandabi avatar Jun 26 '20 15:06 kandabi

when performed without the use of an android native activity (I use a Unity-based activity)

That was my exact issue as well and was the reason why I gave up on the DJI sdk and moved to the open Tello sdk. So you didnt exactly get the DJI sdk up and running within unity 100%... in my own attempts I kept trying to set up the sdk inside of an android plugin without much success, so I wouldnt recommend this method. But it does seem interesting your way of running unity as a plugin! Maybe there is a way of running unity as a plugin inside of a native android app? That might solve the issue we are having with the DJI sdk.

On Fri, Jun 26, 2020, 6:10 PM Aviv Kandabi [email protected] wrote:

Sure I dont mind sharing code, in your situation of using unity as a native library it should be relatively simple using the ffmpeg c++ code Im using to decode the video stream. Ill send you the github project i've used as well - ill try to do it on saturday or sunday.

On Fri, Jun 26, 2020, 5:00 PM Slade Villena [email protected] wrote:

Is your camera issue about displaying the data received?

By the way, this is exactly my issue. class DJICodecManager has a problem with getRgbaData, when performed without the use of an android native activity (I use a Unity-based activity). The problem seems to be abstracted out, since its a lot of boilerplate OpenGL/Android API code, and also DJIs internal source regarding the decoder.

I basically thought I could getRgbaData, put it into glTexSubImage2D passing to a texture defined in Unity, but apparently getRgbaData and getYuvData for the DJICodecManager work only in the context of an Android native activity, with a proper TextureView (tied to a Layout).

Anyway, would love to collaborate with your solution. Unfortunately, I don't think a DJI unity-aar is possible quite yet, but it is possible to export from Unity to android (using Unity as a library), and then using the Android project as the base of the app.

Lets talk more on email! :)

Unity does not have a video decoder, therefore the only solution would be to decode it yourself - java has a native media player function that can already decode video streams, but if that doesn't work I have been working on a tello video stream decode using a native c++ plugin ( ffmpeg librar y) it works, but on higher bitrates there are stuttering in android machines, so its not perfect yet.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dji-sdk/Mobile-SDK-Android/issues/489#issuecomment-650195417, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACKZ7EPMBGA4FJ6TJSQXQT3RYSSV5ANCNFSM4LBK4HVQ .

kandabi avatar Jun 26 '20 15:06 kandabi

That was my exact issue as well and was the reason why I gave up on the DJI sdk and moved to the open Tello sdk. So you didnt exactly get the DJI sdk up and running within unity 100%...

Precisely. Importing an AAR of DJIs code seems unfeasible, since the have to use the "Helper.install" functions for their base app. It seems that the DJI SDK requires functions contained in import com.secneo.sdk.Helper, and other libraries involved in the DJI SDK, and I'm not sure how to package all those dependencies as an AAR (my guess is, its a LOT of java class jars that require to be downloaded, and each packed into a separate unity AAR).

However, following https://github.com/Unity-Technologies/uaal-example and making Unity itself as the library package to be used in an Android native app, I'm able to make a Unity-based Activity inside Android, and the unity activity can start toggling the DJI SDK code easily.

in my own attempts I kept trying to set up the sdk inside of an android plugin without much success, so I wouldnt recommend this method. But it does seem interesting your way of running unity as a plugin! Maybe there is a way of running unity as a plugin inside of a native android app? That might solve the issue we are having with the DJI sdk.

Yes this is precisely what I use. I use the Unity "export to android" function, which produces an Android project containing all the Unity assets, packages and scripts, and an Android native app can launch the Unity window no problem.

My last problem integrating Unity with the DJI SDK is preparing a drone camera video feed to read the video stream, and pass it to a Texture object inside of Unity! :)

roguestarslade avatar Jun 26 '20 15:06 roguestarslade

Then I believe I can help you out, do you crash before getting the video feed back? If there is data recieved I believe we can decode it using a c++ plugin.

On Fri, Jun 26, 2020, 6:44 PM Slade Villena [email protected] wrote:

That was my exact issue as well and was the reason why I gave up on the DJI sdk and moved to the open Tello sdk. So you didnt exactly get the DJI sdk up and running within unity 100%...

Precisely. Importing an AAR of DJIs code seems unfeasible, since the have to use the "Helper.install" functions for their base app. It seems that the DJI SDK requires functions contained in import com.secneo.sdk.Helper, and other libraries involved in the DJI SDK, and I'm not sure how to package all those dependencies as an AAR (my guess is, its a LOT of java class jars that require to be downloaded, and each packed into a separate unity AAR).

However, following https://github.com/Unity-Technologies/uaal-example and making Unity itself as the library package to be used in an Android native app, I'm able to make a Unity-based Activity inside Android, and the unity activity can start toggling the DJI SDK code easily.

in my own attempts I kept trying to set up the sdk inside of an android plugin without much success, so I wouldnt recommend this method. But it does seem interesting your way of running unity as a plugin! Maybe there is a way of running unity as a plugin inside of a native android app? That might solve the issue we are having with the DJI sdk.

Yes this is precisely what I use. I use the Unity "export to android" function, which produces an Android project containing all the Unity assets, packages and scripts, and an Android native app can launch the Unity window no problem.

My last problem integrating Unity with the DJI SDK is preparing a drone camera video feed to read the video stream, and pass it to a Texture object inside of Unity! :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dji-sdk/Mobile-SDK-Android/issues/489#issuecomment-650249977, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACKZ7EP5MHIGAHCCGACIYB3RYS67HANCNFSM4LBK4HVQ .

kandabi avatar Jun 26 '20 15:06 kandabi

https://github.com/comoc/TelloForUnity This was the library that helped me decode an h.264 based stream, it uses ffmpeg to do so, unfortunately its a work in progress and was never finished, I had to tinker with it a lot in order to have it decode the video stream without stuttering using android ( works Great on PC). I believe we can leverage that same code to decode whatever camera data you are getting from the DJI sdk. What do you think? https://youtu.be/_MmPO0d6ah8

it looks like a feasible solution. Compiling the lib to work as an Android native plugin / Unity native plugin would be the first piece of work, but I would only need the decoder part of it (basically something to replace the DJICodecManager.

On Fri, Jun 26, 2020, 6:20 PM Aviv Kandabi @.> wrote: when performed without the use of an android native activity (I use a Unity-based activity) That was my exact issue as well and was the reason why I gave up on the DJI sdk and moved to the open Tello sdk. So you didnt exactly get the DJI sdk up and running within unity 100%... in my own attempts I kept trying to set up the sdk inside of an android plugin without much success, so I wouldnt recommend this method. But it does seem interesting your way of running unity as a plugin! Maybe there is a way of running unity as a plugin inside of a native android app? That might solve the issue we are having with the DJI sdk. On Fri, Jun 26, 2020, 6:10 PM Aviv Kandabi @.> wrote: > Sure I dont mind sharing code, in your situation of using unity as a > native library it should be relatively simple using the ffmpeg c++ code Im > using to decode the video stream. > Ill send you the github project i've used as well - ill try to do it on > saturday or sunday. > > On Fri, Jun 26, 2020, 5:00 PM Slade Villena @.***> > wrote: > >> Is your camera issue about displaying the data received? >> >> By the way, this is exactly my issue. class DJICodecManager has a >> problem with getRgbaData, when performed without the use of an android >> native activity (I use a Unity-based activity). The problem seems to be >> abstracted out, since its a lot of boilerplate OpenGL/Android API code, and >> also DJIs internal source regarding the decoder. >> >> I basically thought I could getRgbaData, put it into glTexSubImage2D >> passing to a texture defined in Unity, but apparently getRgbaData and >> getYuvData for the DJICodecManager work only in the context of an Android >> native activity, with a proper TextureView (tied to a Layout). >> >> Anyway, would love to collaborate with your solution. Unfortunately, I >> don't think a DJI unity-aar is possible quite yet, but it is possible to >> export from Unity to android (using Unity as a library), and then using the >> Android project as the base of the app. >> >> Lets talk more on email! :) >> >> Unity does not have a video decoder, therefore the only solution would >> be to decode it yourself - java has a native media player function that can >> already decode video streams, but if that doesn't work I have been working >> on a tello video stream decode using a native c++ plugin ( ffmpeg librar y) >> it works, but on higher bitrates there are stuttering in android machines, >> so its not perfect yet. >> >> — >> You are receiving this because you commented. >> Reply to this email directly, view it on GitHub >> <#489 (comment)>, >> or unsubscribe >> https://github.com/notifications/unsubscribe-auth/ACKZ7EPMBGA4FJ6TJSQXQT3RYSSV5ANCNFSM4LBK4HVQ >> . >> >

roguestarslade avatar Jun 26 '20 15:06 roguestarslade

it looks like a feasible solution. Compiling the lib to work as an Android native plugin / Unity native plugin would be the first piece of work, but I would only need the decoder part of it (basically something to replace the DJICodecManager

The author already compiled it using the ndk, I just had to make some minor adjustments to the makefiles, its a simple c++ plugin, I dont even mind sharing the code its rather simple to use!

On Fri, Jun 26, 2020, 6:49 PM Slade Villena [email protected] wrote:

https://github.com/comoc/TelloForUnity This was the library that helped me decode an h.264 based stream, it uses ffmpeg to do so, unfortunately its a work in progress and was never finished, I had to tinker with it a lot in order to have it decode the video stream without stuttering using android ( works Great on PC). I believe we can leverage that same code to decode whatever camera data you are getting from the DJI sdk. What do you think? https://youtu.be/_MmPO0d6ah8

it looks like a feasible solution. Compiling the lib to work as an Android native plugin / Unity native plugin would be the first piece of work, but I would only need the decoder part of it (basically something to replace the DJICodecManager.

… <#m_-6489197612280507255_> On Fri, Jun 26, 2020, 6:20 PM Aviv Kandabi @.> wrote: when performed without the use of an android native activity (I use a Unity-based activity) That was my exact issue as well and was the reason why I gave up on the DJI sdk and moved to the open Tello sdk. So you didnt exactly get the DJI sdk up and running within unity 100%... in my own attempts I kept trying to set up the sdk inside of an android plugin without much success, so I wouldnt recommend this method. But it does seem interesting your way of running unity as a plugin! Maybe there is a way of running unity as a plugin inside of a native android app? That might solve the issue we are having with the DJI sdk. On Fri, Jun 26, 2020, 6:10 PM Aviv Kandabi @.> wrote: > Sure I dont mind sharing code, in your situation of using unity as a > native library it should be relatively simple using the ffmpeg c++ code Im > using to decode the video stream. > Ill send you the github project i've used as well - ill try to do it on > saturday or sunday. > > On Fri, Jun 26, 2020, 5:00 PM Slade Villena @.***> > wrote: > >> Is your camera issue about displaying the data received? >> >> By the way, this is exactly my issue. class DJICodecManager has a >> problem with getRgbaData, when performed without the use of an android >> native activity (I use a Unity-based activity). The problem seems to be >> abstracted out, since its a lot of boilerplate OpenGL/Android API code, and

also DJIs internal source regarding the decoder. >> >> I basically thought I could getRgbaData, put it into glTexSubImage2D >> passing to a texture defined in Unity, but apparently getRgbaData and >> getYuvData for the DJICodecManager work only in the context of an Android >> native activity, with a proper TextureView (tied to a Layout). >> >> Anyway, would love to collaborate with your solution. Unfortunately, I >> don't think a DJI unity-aar is possible quite yet, but it is possible to >> export from Unity to android (using Unity as a library), and then using the >> Android project as the base of the app. >> >> Lets talk more on email! :) >> >> Unity does not have a video decoder, therefore the only solution would >> be to decode it yourself - java has a native media player function that can already decode video streams, but if that doesn't work I have been working >> on a tello video stream decode using a native c++ plugin ( ffmpeg librar y) >> it works, but on higher bitrates there are stuttering in android machines, >> so its not perfect yet. >> >> — >> You are receiving this because you commented. >> Reply to this email directly, view it on GitHub >> <#489 (comment) https://github.com/dji-sdk/Mobile-SDK-Android/issues/489#issuecomment-650195417>, or unsubscribe >> https://github.com/notifications/unsubscribe-auth/ACKZ7EPMBGA4FJ6TJSQXQT3RYSSV5ANCNFSM4LBK4HVQ . >> >

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dji-sdk/Mobile-SDK-Android/issues/489#issuecomment-650252474, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACKZ7EO4JIUGZRLHLQJJLX3RYS7R5ANCNFSM4LBK4HVQ .

kandabi avatar Jun 26 '20 15:06 kandabi

Then I believe I can help you out, do you crash before getting the video feed back? If there is data received I believe we can decode it using a c++ plugin.

Awesome!

I don't get any crashes actually, I can still basically run the Unity window (within an Android activity, Unity as a library for android....), toggle all the DJI SDK components (including receiving events, and receiving drone connect+disconnects). The only problem right now is my texture isn't rendering at all.....

I'm stuck on one part of my code : transferring a java byte[] array containing RGBA data (from DJICodecManager). Unfortunately it doesnt transfer any data at all, and gives me a silent error coming from the DJI sdk side, whenever I call DJICodecManager.getRgbaData() or DJICodecManager.getYuvData(), both of those functions seem to be tied to an android activity being the main OpenGL context window, and cannot operate outside of it.

Fortunately I know exactly where the H264 video stream is coming from. I can get it via a Java listener, and its active through this function :

        mReceivedVideoDataListener = new VideoFeeder.VideoDataListener() {
            @Override
            public void onReceive(byte[] videoBuffer, int size) {
                if (mCodecManager != null) {
                    //String newMsg = "UnityDJIActivity:onReceive:" + size + "\n";
                    //Log.v(TAG,  newMsg);
                    mCodecManager.sendDataToDecoder(videoBuffer, size);
                }
            }
        };

"videoBuffer" is basically a java byte[] array, and I believe its the H264 stream coming from the camera.

On Fri, Jun 26, 2020, 6:44 PM Slade Villena @.***> wrote: That was my exact issue as well and was the reason why I gave up on the DJI sdk and moved to the open Tello sdk. So you didnt exactly get the DJI sdk up and running within unity 100%... Precisely. Importing an AAR of DJIs code seems unfeasible, since the have to use the "Helper.install" functions for their base app. It seems that the DJI SDK requires functions contained in import com.secneo.sdk.Helper, and other libraries involved in the DJI SDK, and I'm not sure how to package all those dependencies as an AAR (my guess is, its a LOT of java class jars that require to be downloaded, and each packed into a separate unity AAR). However, following https://github.com/Unity-Technologies/uaal-example and making Unity itself as the library package to be used in an Android native app, I'm able to make a Unity-based Activity inside Android, and the unity activity can start toggling the DJI SDK code easily. in my own attempts I kept trying to set up the sdk inside of an android plugin without much success, so I wouldnt recommend this method. But it does seem interesting your way of running unity as a plugin! Maybe there is a way of running unity as a plugin inside of a native android app? That might solve the issue we are having with the DJI sdk. Yes this is precisely what I use. I use the Unity "export to android" function, which produces an Android project containing all the Unity assets, packages and scripts, and an Android native app can launch the Unity window no problem. My last problem integrating Unity with the DJI SDK is preparing a drone camera video feed to read the video stream, and pass it to a Texture object inside of Unity! :) — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#489 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACKZ7EP5MHIGAHCCGACIYB3RYS67HANCNFSM4LBK4HVQ .

roguestarslade avatar Jun 26 '20 15:06 roguestarslade

The author already compiled it using the ndk, I just had to make some minor adjustments to the makefiles, its a simple c++ plugin, I dont even mind sharing the code its rather simple to use!

Very Awesome!

If you're interested, wanna make this a "DJIxUnity" project via Github? If we can get this video stream texturing to a Unity-made texture, we can basically make Unity-DJI projects! :)

Please do email me the source work at [email protected], and I'll make a sample library where you can make a Unity + DJI project via Android, I'm open to your suggestions on how to proceed. :)

roguestarslade avatar Jun 26 '20 16:06 roguestarslade

I'll be delighted, if we can make it happen it might lead to drone AR games in the future :) Let me send you my source either tommorow or sunday, but basically all the decoding side of the code already exists in that github project I've linked if you'd like to start working on it right away. I can help you out with any of the c++ side of things for the decoder. Cheers!

Thank you for the collab! Yeah, I happen to be making a drone-based AR game :P

Getting the texture from the video camera to Unity is literally the core feature I need. Once we have that, we can make an open source DJIxUnity project! :)

On Fri, Jun 26, 2020, 7:01 PM Slade Villena @.> wrote: The author already compiled it using the ndk, I just had to make some minor adjustments to the makefiles, its a simple c++ plugin, I dont even mind sharing the code its rather simple to use! Very Awesome? If you're interested, wanna make this a "DJIxUnity" project via Github? If we can get this video stream texturing to a Unity-made texture, we can basically make Unity-DJI projects! :) Please do email me the source work at @., and I'll make a sample library where you can make a Unity + DJI project via Android, I'm open to your suggestions on how to proceed. :) — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#489 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACKZ7EJS676Z44TTKN27ZDLRYTA3ZANCNFSM4LBK4HVQ .

roguestarslade avatar Jun 26 '20 16:06 roguestarslade

Hi @roguestarslade and @kandabi! Thank you for an amazing info and ideas. I was trying to integrate the native dji sdk into unity, but with no great success. Integrating it the other way around (unity as a library) could really be the solution. Gonna try that. For starter, it would be success for me to get the flight data and pass them to the unity (GPS, altitude, etc.).

Please keep us updated about your progress with the video integration. I would say that there are a lot of people wanting the Unity-DJI support.

Looking forward to some updates from you! :)

xBambusekD avatar Jul 02 '20 15:07 xBambusekD

Hi hi!

I've managed to load a DJI camera H264 feed directly into a Unity texture! Process involved a lot of decoding, but it is feasible to do so if making a Unity project as an Android-export. I have yet to investigate the feasibility of exporting the DJI-sdk as a Unity plugin AAR, but making Unity the plugin to an android project seems like a more viable option.

I'll be building a DJIxUnity github repository soon. @kandabi is most welcome to be a contributor too (since his Tello code allowed me to study the decoding process even further :) )

More to come, stay tuned here when DJIxUnity releases!

Hi @roguestarslade and @kandabi! Thank you for an amazing info and ideas. I was trying to integrate the native dji sdk into unity, but with no great success. Integrating it the other way around (unity as a library) could really be the solution. Gonna try that. For starter, it would be success for me to get the flight data and pass them to the unity (GPS, altitude, etc.).

Please keep us updated about your progress with the video integration. I would say that there are a lot of people wanting the Unity-DJI support.

Looking forward to some updates from you! :)

roguestarslade avatar Jul 08 '20 17:07 roguestarslade

Hi @roguestarslade!

after some break, I got back to the DJI-Unity project. Are there any updates from you? Glad to hear that the DJI camera feed in the Unity texture works! How the work on the DJIxUnity repository is going? I tried to get at least the flight data into the Unity (camera feed would be just a bonus), but I had some troubles with the DJI sdk activation. Would you be willing to share some of your code?

Thanks for your work!

xBambusekD avatar Sep 01 '20 14:09 xBambusekD

@roguestarslade @kandabi @xBambusekD @hanho5120 Did you manage to solve this issue? I'm trying also to have the DJISDK inside an AAR and consume it, but it seems impossible. Thanks.

edupazpix4d avatar May 31 '21 08:05 edupazpix4d

FYI for anyone else getting a crash after calling registerApp

After looking at the log, I noticed it was complaining about classes not being defined. It turns out registerApp calls a lot of 3rd party stuff, including androidx and org.apache.http. You need to ensure you have these, I resolved the errors one by one.

For example, you may need to add dependencies in your gradle. I needed:

implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.core:core:1.6.0'
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.annotation:annotation:1.3.0'

https://github.com/DJI-Mobile-SDK-Tutorials/Android-ImportAndActivateSDKInAndroidStudio/blob/master/ImportSDKDemo/app/build.gradle

Waffle1434 avatar Mar 02 '22 03:03 Waffle1434