javaandroidimage-processingfile-uploaddji-sdk

Question about Real time Image data sending from drone


I have a question for developing a function...

I'm developing a function that receives image datas from 2 drones(Phantom 4 Advanced, Inspire 2) in real time and merges them.

For test, I tried to receive a picture, but it took a long time to receive..

here is my code...

camera.setShootPhotoMode(photoMode, new CommonCallbacks.CompletionCallback() {
            @Override
            public void onResult(DJIError djiError) {
                if (null == djiError) {
                    mHandler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            camera.startShootPhoto(new CommonCallbacks.CompletionCallback() {
                                @Override
                                public void onResult(DJIError djiError) {
                                    if (djiError == null) {
                                        showToast("take photo: success");
                                        //start 시간 찍고
                                        Log.d("Start Time: ", Long.toString(System.currentTimeMillis()));
                                    } else {
                                        showToast(djiError.getDescription());
                                    }
                                }
                            });
                        }
                    }, 2000);
                }
            }
        });
        //카메라 데이터 핸드폰에 저장
        camera.setMediaFileCallback(new MediaFile.Callback() {
            @Override
            public void onNewFile(@NonNull MediaFile mediaFile) {
                mediaFile.fetchFileData(file, "imageData", new DownloadListener<String>() {
                    @Override
                    public void onStart() {
                        showToast("Start downloading.");
                    }

                    @Override
                    public void onRateUpdate(long l, long l1, long l2) {

                    }

                    @Override
                    public void onRealtimeDataUpdate(byte[] bytes, long l, boolean b) {

                    }

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

                    }

                    @Override
                    public void onSuccess(String s) {
                        showToast("Download Succeed.");
                        //end time
                        Log.d("End Time: ", Long.toString(System.currentTimeMillis()));
                    }

                    @Override
                    public void onFailure(DJIError djiError) {
                        if(djiError != null){
                            showToast("Failed..");
                            //end time
                            Log.d("End Time: ", Long.toString(System.currentTimeMillis()));
                        }
                    }
                });
                showToast("Image is successfully Saved");
                Log.d("Camera Image Transfer: ", "Succeed!");
            }
        });

I use shootphotomode and setmediafilecallback to send it to my Phone..

Is there any other ways to receive data in real time?

I'm always appreciate that you take a couple of time to read my problem..Thank you very much!


Solution

  • Fullres photos take a long time, you can't do anything about that. This will never be realtime.

    If you need realtime image, you must grab frames from the fpv livestream, which is lowres and 720p/1080p h264 coded. This is realtime with about 200ms delay, like what you see in fpvview.

    I usually just export a bitmap from the fpvview, that's the fastest way, since you don't need to decode 264. Can easily read 60fps with that method.