gpt4 book ai didi

ios - SDK DJI 快速下载照片

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:59:49 25 4
gpt4 key购买 nike

我只是想从我的 DJI 无人机下载最新的访问提要并将提要转换为 UIImage。我认为可以做到这一点的最简单方法是拍照,然后立即从存储中下载最新照片。我将在下面添加从存储代码中下载。这是最简单的方法吗?我一直收到此错误代码 -

Settings parameters operation failed. (Code : -1007)

我研究过但找不到这意味着什么 - DJI 文档仅限于几乎所有 obj-c。这里的代码 -

@IBAction func download(_ sender: UIButton) {
let camera = self.fetchCamera()

// switch camera mode to allow for media downloads
camera?.setMode(DJICameraMode.mediaDownload, withCompletion: {(error) in
if error != nil {
self.status.text="\(error!.localizedDescription)"
}
else {

// get the media manager from the drone to gain access to the files
let manager = camera!.mediaManager!

if error != nil {
self.status.text = "State: \(manager.sdCardFileListState.rawValue)"
self.status.text = "Error refreshing list: \(error)"

}
else {
print("Refreshed file list")
print("State: \(manager.sdCardFileListState.rawValue)")


guard let files = manager.sdCardFileListSnapshot() else {
self.status.text = ("No files to download")
return
}

self.status.text = "There are files to download"

var images: [UIImage] = []

for file in files {

if file.mediaType == .JPEG {

self.status.text = ("Time created: \(file.timeCreated)")

DispatchQueue.main.asyncAfter(deadline: .now() + 1) {

file.fetchData(withOffset: 0, update: DispatchQueue.main, update: {(_ data: Data?, _ isComplete: Bool, _ error: Error?) -> Void in

if error != nil {
self.status.text = "State: \(manager.sdCardFileListState.rawValue)"
self.status.text = "Error downloading photo: \(error!)"
}
else {
// unwrap downloaded data and create image
if let data = data, let downloadedImage = UIImage(data: data) {
self.status.text = "Image was downloaded!"
images.append( downloadedImage )
}
}

}) // end of filedata fetch

}

}

} // end of loop


}

}

})// end of camera setMode block

}`

任何帮助将不胜感激 - 谢谢

最佳答案

@IBAction func download(_ sender: UIButton) {
let camera = self.fetchCamera()

// switch camera mode to allow for media downloads
camera?.setMode(DJICameraMode.mediaDownload, withCompletion: {(error) in
if error != nil {
self.status.text="\(error!.localizedDescription)"
}
else {

// get the media manager from the drone to gain access to the files
let manager = camera!.mediaManager!

if error != nil {
self.status.text = "State: \(manager.sdCardFileListState.rawValue)"
self.status.text = "Error refreshing list: \(error)"

}
else {
print("Refreshed file list")
print("State: \(manager.sdCardFileListState.rawValue)")

while(manager.internalStorageFileListState != .UpToDate) {
// Do nothing...
}
guard let files = manager.sdCardFileListSnapshot() else {
self.status.text = ("No files to download")
return
}

self.status.text = "There are files to download"

var images: [UIImage] = []

for file in files {

if file.mediaType == .JPEG {

self.status.text = ("Time created: \(file.timeCreated)")

DispatchQueue.main.asyncAfter(deadline: .now() + 1) {

file.fetchData(withOffset: 0, update: DispatchQueue.main, update: {(_ data: Data?, _ isComplete: Bool, _ error: Error?) -> Void in

if error != nil {
self.status.text = "State: \(manager.sdCardFileListState.rawValue)"
self.status.text = "Error downloading photo: \(error!)"
}
else {
// unwrap downloaded data and create image
if let data = data, let downloadedImage = UIImage(data: data) {
self.status.text = "Image was downloaded!"
images.append( downloadedImage )
}
}

}) // end of filedata fetch
}
}

} // end of loop
}
}

})// end of camera setMode block
}

关于ios - SDK DJI 快速下载照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54603286/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com