无法从相机SD卡中下载原图
已完成MSDK版本:V5.2.0
目标:从摄像头的SD卡中下载原图至遥控器(摄像头为P1摄像头,无人机为M300 RTK)
问题:
1、请反馈我的图片下载API调用步骤是否有问题,若无问题是否API问题?
2、以及,我是用JAVA进行API调用的,V5 SDK中是否存在只能使用kotlin语法特性的API。
做法:
1、新建空白项目,导入MSDK,进行APP注册。
注册调用API:
SDKManager.getInstance().init(this, new SDKManagerCallback(){});
2、利用MediaManager进行原图下载
下载依次调用API:
IMediaManager mediaManager = MediaDataCenter.getInstance().getMediaManager();
mediaManager.addMediaFileListStateListener(mediaFileListState -> {
});
mediaManager.enable(new CommonCallbacks.CompletionCallback() {});
MediaFileFilter mediaFileFilter = MediaFileFilter.PHOTO;
mediaManager.pullMediaFileListFromCamera(new PullMediaFileListParam.Builder().filter(mediaFileFilter).build(), new CommonCallbacks.CompletionCallback() {});
MediaFileListData mediaFileListData = mediaManager.getMediaFileListData();
List<MediaFile> mediaFiles = mediaFileListData.getData();
MediaFile mediaFile = mediaFiles.get(0);
结果:返回mediaFileListData为空,无法获取原图。
-
测试过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.990msprivate 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" );
}
}); -
-
如果你M300RTK用得是H20系列镜头,则可以边拍照边下载。闪退你总有闪退日志吧。pullOriginalMediaFileFromCamera第二个参数也有callback可以看到是什么情况呀。如何下载照片看这篇文章,https://sdk-forum.dji.net/hc/zh-cn/articles/11810412570393
请先登录再写评论。
评论
9 条评论