无法从相机SD卡中下载原图

已完成

评论

9 条评论

  • DJI Developer Support
    接口调用没有问题,但是你的代码不是嵌套在callback里,比如你调用getMediaFileListData的时候pullMediaFileListFromCamera还没有回调成功呢,还没有拉出来照片你就在获取了。我们的Sample你测试是否没问题?
    0
    评论操作 固定链接
  • ZHT

    测试过Sample。我按照您说的做了,可以拉取到MediaFileListData了,但是仍然无法获取到原图,您可以帮我看看我接下来的API调用是否有问题吗?

    报错信息是:I/DJIVideoManagerHelper: (co_a:5) removeVideoObserver: {2=dji.v5.inner.video.callback.co_a@9b8ff76} 
    I/DJIVideoManagerHelper: (co_a:5) removeVideoObserver: {} 
    I/DJIV5/Class@6073264: (co_a:54) Fetch file list failed, retCode -> 0 files -> [{"valid":true,"isManualGroupFile":false,"fileIndex":5768048,"fileType":0,"fileName":"DJI_880.jpg","fileSize":14878915,"date":{"year":2023,"month":1,"day":31,"hour":16,"minute":19,"second":38},"starTag":0,"isCloudDownload":false,"duration":0,"orientation":0,"cameraOrientation":0,"frameRate":65535,"resolution":65535,"videoType":65535,"photoType":0,"panoType":65535,"videoEncodeType":255,"videoSpeedRatio":0,"panoCount":0,"hasOriginalFile":false,"guid":0,"fileGroupIndex":32823,"subIndex":0,"segSubIndex":0,"timeLapseInterval":0,"EXIFInfo":{"focalLength35mmFormatEnabled":true,"lightSourceEnabled":true,"meteringModeEnabled":true,"exposureCompensationEnabled":true,"isoEnabled":true,"exposureProgramEnabled":true,"fNumberEnabled":true,"exposureTimeEnabled":true,"exposureProgram":1,"iso":100,"meteringMode":1,"lightSource":1,"focalLength35mmFormat":35,"shutterNumerator":1,"shutterDenominator":100,"shutterSpeedText":"1\/100","apertureText":"5.6","exposureCompensationText":"-1","hasProxy":false,"proxyInfo":{"proxyIndex":0,"proxySize":0,"proxyDuration":0,"proxyFrameRate":65535,"proxyRotation":65535,"proxyResolution":65535},"physicalPathInfo":[]},"photoRatio":0,"subMediaFile":[],"dcfInfo":{"customKey":"DJI","cameraType":65535,"directoryIndex":22,"fileIndex":55,"fileSetId":360503,"time":{"year":2023,"month":1,"day":31,"hour":15,"minute":47,"second":0}},"isDcfSupported":true,"isEdcfSupported":false,"isPageLastFile":false,"dirIndex":0,"videoBeautifyInfo":{"control":false,"effectSlimming":0,"effectSmoother":0,"effectWhitening":0,"effectEyeEnlarge":0,"effectExposure":0,"effectToning":0,"effectEyeCircle":0},"hasProxy":false,"proxyInfo":{"proxyIndex":-1,"proxySize":-1,"proxyDuration":-1,"proxyFrameRate":65535,"proxyRotation":65535,"proxyResolution":65535},"isSize64File":false,"videoProMetaInfo":{"projectFrameRate":65535,"sensorFrameRate":65535,"timecodeStart":{"hours":0,"minutes":0,"seconds":0,"frames":0},"timecodeEnd":{"hours":0,"minutes":0,"seconds":0,"frames":0},"shutterType":{"value":65535},"shutterSpeed":{"value":65535},"shutterAngle":0,"aperture":0,"ev":{"value":65535},"ei":0,"whiteBalance":{"mode":65535,"colorTemperature":0},"hue":0,"ndFilter":0,"codecParam":65535}}, {"valid":true,"isManualGroupFile":false,"fileIndex":5768032,"fileType":0,"fileName":"DJI_864.jpg","fileSize":14776491,"date":{"year":2023,"month":1,"day":31,"hour":16,"minute":19,"second":36},"starTag":0,"isCloudDownload":false,"duration":0,"orientation":0,"cameraOrientation":0,"frameRate":65535,"resolution":65535,"videoType":65535,"photoType":0,"panoType":65535,"videoEncodeType":255,"videoSpeedRatio":0,"panoCount":0,"hasOriginalFile":false,"guid":0,"fileGroupIndex":32822,"subIndex":0,"segSubIndex":0,"timeLapseInterval":0,"EXIFInfo":{"focalLength35mmFormatEnabled":true,"lightSourceEnabled":true,"meteringModeEnabled":true,"exposureCompensationEnabled":true,"isoEnabled":true,"exposureProgramEnabled":true,"fNumberEnabled":true,"exposureTimeEnabled":true,"exposureProgram":1,"iso":100,"meteringMode":1,"lightSource":1,"focalLength35mmFormat":35,"shutterNumerator":1,"shutterDenominator":100,"shutterSpeedText":"1\/100","apertureText":"5.6","exposureCompensationText":"-1","hasProxy":false,"proxyInfo":{"proxyIndex":0,"proxySize":0,"proxyDuration":0,"proxyFrameRate":65535,"proxyRotation":65535,"proxyResolution":65535},"physicalPathInfo":[]},"photoRatio":0,"subMediaFile":[],"dcfInfo":{"customKey":"DJI","cameraType":65535,"directoryIndex":22,"fileIndex":54,"fileSetId":360502,"time":{"year":2023,"month":1,"day":31,"hour":15,"minute":47,"second":0}},"isDcfSupported":true,"isEdcfSupported":false,"isPageLastFile":false,"dirIndex":0,"videoBeautifyInfo":{"control":false,"effectSlimming":0,"effectSmoother":0,"effectWhitening":0,"effectEyeEnlarge":0,"effectExposure":0,"effectToning":0,"effectEyeCircle":0},"hasProxy":false,"proxyInfo":{"proxyIndex":-1,"proxySize":-1,"proxyDuration":-1,"proxyFrameRate":65535,"proxyRotation":65535,"proxyResolution":65535},"isSize64File":false,"videoProMetaInfo
    I/V5_Test_App: pullMediaFileList Success
    D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000
    D/GRALLOC-ROCKCHIP: enter, w : 110, h : 494, format : 0x1, usage : 0xb00.
    D/GRALLOC-ROCKCHIP: enter, w : 110, h : 494, format : 0x1, usage : 0xb00.
    I/DJIVideoManagerHelper: (co_b:6) setVideoObserver: {1=dji.v5.inner.video.callback.co_a@e6f62aa} 
    I/AircraftVideoStreamManagerDelegate: (co_i:4) liveVideoSourceEntity = {"sourceId":42008576,"majorType":2,"minorType":129,"position":0} 
    I/art: Do partial code cache collection, code=123KB, data=97KB
    I/art: After code cache collection, code=123KB, data=97KB
    I/art: Increasing code cache capacity to 512KB
    I/DJIVideoManagerHelper: (co_b:6) setVideoObserver: {1=dji.v5.inner.video.callback.co_a@e6f62aa, 2=dji.v5.inner.video.callback.co_a@9b8ff76} 
    I/AircraftVideoStreamManagerDelegate: (co_i:4) liveVideoSourceEntity = {"sourceId":2556672,"majorType":0,"minorType":39,"position":3} 
    I/AircraftVideoStreamManagerDelegate: (co_i:4) liveVideoSourceEntity = {"sourceId":42008576,"majorType":2,"minorType":129,"position":0} 
    I/AircraftVideoStreamManagerDelegate: (co_i:4) liveVideoSourceEntity = {"sourceId":2556672,"majorType":0,"minorType":39,"position":3} 
    I/AircraftVideoStreamManagerDelegate: (co_i:4) liveVideoSourceEntity = {"sourceId":42008576,"majorType":2,"minorType":129,"position":0} 
    D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000
    D/GRALLOC-ROCKCHIP: enter, w : 110, h : 411, format : 0x1, usage : 0xb00.
    D/GRALLOC-ROCKCHIP: enter, w : 110, h : 411, format : 0x1, usage : 0xb00.
    D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000
    D/GRALLOC-ROCKCHIP: enter, w : 110, h : 363, format : 0x1, usage : 0xb00.
    D/GRALLOC-ROCKCHIP: enter, w : 110, h : 363, format : 0x1, usage : 0xb00.
    I/art: Background sticky concurrent mark sweep GC freed 47993(1847KB) AllocSpace objects, 125(2MB) LOS objects, 38% free, 7MB/11MB, paused 5.400ms total 33.739ms
    E/BackgroundUtil: (co_a:5) checkIsForeground, isForeground : false 
    W/art: Suspending all threads took: 6.990ms
    private void pull_media(MediaFile mediaFile) throws FileNotFoundException {
    String mediaFileDir = "V5_Test";
    File dirs = new File(DiskUtil.getExternalCacheDirPath(ContextUtil.getContext(), mediaFileDir));
    if (!dirs.exists()) {
    dirs.mkdirs();
    }
    String filepath = DiskUtil.getExternalCacheDirPath(ContextUtil.getContext(), mediaFileDir + "/" +mediaFile.getFileName());
    File file = new File(filepath);
    if (file.exists()) {
    file.delete();
    }

    Long offset = 0L;
    if (file.exists()) {
    offset = file.length();
    }

    FileOutputStream outputStream = new FileOutputStream(file);
    BufferedOutputStream bos = new BufferedOutputStream(outputStream);

    mediaFile.pullOriginalMediaFileFromCamera(offset, new MediaFileDownloadListener() {
    @Override
    public void onStart() {
    Toast.makeText(MainActivity.this, "start to pull media", Toast.LENGTH_LONG).show();
    }

    @Override
    public void onProgress(long total, long current) {

    }

    @Override
    public void onRealtimeDataUpdate(byte[] data, long position) {
    try {

    bos.write(data, 0, data.length);
    bos.flush();
    } catch (Exception e) {
    LogUtils.e("MediaFile" , "write error" + e);
    }

    }

    @Override
    public void onFinish() {
    Toast.makeText(MainActivity.this, "pulling finished", Toast.LENGTH_LONG).show();
    try {
    outputStream.close();
    bos.close();
    } catch (Exception e) {
    LogUtils.e("MediaFile" , "close error$error" + e);
    }
    }

    @Override
    public void onFailure(IDJIError error) {
    LogUtils.e("MediaFile" , "download error$error" );


    }
    });
    0
    评论操作 固定链接
  • DJI Developer Support
    下载的代码可以参考这篇文章,https://sdk-forum.dji.net/hc/zh-cn/articles/11810412570393
    0
    评论操作 固定链接
  • ZHT

    我就是按照这篇写的代码,几乎一模一样。

    0
    评论操作 固定链接
  • DJI Developer Support
    会不会是和安卓版本有关,因为我看你用得是M300,M300遥控器是安卓7。Demo上得代码适配得是安卓10。从安卓10版本开始,对于安卓设备存储读写权限有更改。你确认下载数据是没问题,问题是否出在写文件上。
    0
    评论操作 固定链接
  • ZHT

    上述问题已然解决,然而现在出现的新问题是,“无人机在空中时无法下载照片到遥控器上, APP会直接闪退”,目前毫无头绪,请问

    pullOriginalMediaFileFromCamera

    API是否无法空中使用?或者有什么使用限制条件?

    0
    评论操作 固定链接
  • ZHT

    是否有办法获取SDK中API运行的log信息?

    0
    评论操作 固定链接
  • DJI Developer Support
    如果你M300RTK用得是H20系列镜头,则可以边拍照边下载。闪退你总有闪退日志吧。pullOriginalMediaFileFromCamera第二个参数也有callback可以看到是什么情况呀。如何下载照片看这篇文章,https://sdk-forum.dji.net/hc/zh-cn/articles/11810412570393
    0
    评论操作 固定链接
  • ZHT

    查看闪退日志,是安卓问题,已解决,已能正常下载图片,谢谢支持。再请教一下,pullOriginalMediaFileFromCamera是个异步接口,有没有什么设置能让它“同步”呢?即执行完后再做下一个动作,只能在回调函数里写嵌套吗?此外我翻了一下API文档,是否只能从无人机上拉文件到遥控器,无法从遥控器上传文件至相机SD卡?

    0
    评论操作 固定链接

请先登录再写评论。