dji-sdk / Mobile-SDK-Android

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

DJI Phantom 4 Advanced - Question about sending a photo.. #1065

Open Inbi-Yeo opened 2 years ago

Inbi-Yeo commented 2 years ago

I really appreciate for your help..

I have some problems for developing an app. Here is my problem...

I took a picture and tried to send it to my phone. However, when I measured the time, it took more than 2 minutes to send 1 pic. Is somebody know why this happens? Is there any problem with my code? Here is my code...

`public File file = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);

private void captureAction() {
    final Camera camera = Instance.getCameraInstance();
    if (camera != null) {
        camera.setPhotoAspectRatio(SettingsDefinitions.PhotoAspectRatio.RATIO_16_9, new CommonCallbacks.CompletionCallback() {
            @Override
            public void onResult(DJIError djiError) {
                if (djiError == null) {
                    showToast("Aspect Ratio Setting Succeed");
                } else {
                    showToast("Aspect Ratio Setting Failed");
                }
            }
        });
        SettingsDefinitions.ShootPhotoMode photoMode = SettingsDefinitions.ShootPhotoMode.SINGLE; // Set the camera capture mode as Single mode
        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!");
            }
        });
    }
}`
dji-dev commented 2 years ago

Agent comment from DJI SDK in Zendesk ticket #56703:

尊敬的开发者,感谢您联系DJI 大疆创新 由于github不是我们主要的咨询渠道,您的问题可能跟进不及时。我们建议您通过填写表单( https://djisdksupport.zendesk.com/hc/zh-cn/requests/new )向我们反馈问题。或者您也可以在论坛发帖,与其它开发者交流。论坛链接:https://djisdksupport.zendesk.com/hc/zh-cn/community/topics

Dear developer, thank you for contacting DJI. Since github is not our main consultation channel, your questions may not be followed up in time. We recommend that you fill in the form (https://djisdksupport.zendesk.com/hc/en-us/requests/new) to report problems to us. Or you can post in the forum to communicate with other developers. Forum link: https://djisdksupport.zendesk.com/hc/zh-cn/community/topics

°°°

DJI-William commented 2 years ago

The code does not contain how you download the picture to your phone. Did you use fetchFileData? What is the download rate by using official app?

luoyexk commented 2 years ago
camera.setMediaFileCallback(new MediaFile.Callback() {
            @Override
            camera.setMediaFileCallback(new MediaFile.Callback() {
            @Override
            public void onNewFile(@NonNull MediaFile mediaFile) {
// do not download mediaFile immediately when you receive it, please enter download mode
                mediaFile.fetchFileData(file, "imageData", new DownloadListener<String>() {
  1. enter the download mode, and then download. camera.setMode(SettingsDefinitions.CameraMode.MEDIA_DOWNLOAD)
  2. start download mediaFile.fetchFileData(file, "imageData", new DownloadListener<String>()
  3. after download finished, call camera.setMode(SettingsDefinitions.CameraMode.SHOOT_PHOTO) to continue take photo.