在Mavic 2 Enterprise Dual上设置相机模式:视觉,热量和MSX开关不起作用

时间:2019-05-21 17:48:53

标签: dji-sdk

连接了Mavic 2 Enterprise Dual时,我试图设置相机模式,但出现错误。该产品应具有setDisplayMode,因为它具有Visual,Infrared和MSX功能:

camera!.setDisplayMode(DJICameraDisplayMode.MSX, withCompletion: nil)

错误:当前产品不支持此功能。(代码:-1013)

SDK版本:4.10

快速版本:5.0

1 个答案:

答案 0 :(得分:2)

发现解决方案:

Mavic 2 Enterprise Dual具有两种摄像头类型:视觉和热成像。为了更改相机的显示类型,您必须使用热像仪。

获取热像仪的代码:

var cameraMode: String = ""

viewDidLoad() {
    checkForMavic2Enterprise()
}

func checkForMavic2Enterprise() {
    guard let product = DJISDKManager.product() else {
        print("No product")
        switchCameraButton.isHidden = true
        return
    }

    if product.model == "Mavic 2 Enterprise Dual" {
        let camera = fetchCamera()
        camera!.setDisplayMode(DJICameraDisplayMode.visualOnly, withCompletion: nil)
        cameraMode = "visual"
    } else {
        switchCameraButton.isHidden = true
    }
}

// get the drone camera
func fetchCamera() -> DJICamera? {
    if let product = DJISDKManager.product() {
        if let productKind = product as? DJIAircraft {
            if productKind.cameras!.count > 1 {
                return productKind.cameras![1] // thermal
            } else {
                return productKind.camera
            }
        } else if let productKind = product as? DJIHandheld {
            print("HANDHELD CAMERA: \(productKind.camera.debugDescription)")
            return productKind.camera
        }
    }
    return nil
}

@IBAction func switchCamera(_ sender: Any) {

    let camera = fetchCamera()

    switch cameraMode {
    case "visual":
        print("SWITCHING TO MSX")
        camera!.setDisplayMode(DJICameraDisplayMode.MSX, withCompletion: nil)
        cameraMode = "MSX"
        break
    case "MSX":
        print("SWITCHING TO THERMAL")
        camera!.setDisplayMode(DJICameraDisplayMode.thermalOnly, withCompletion: nil)
        cameraMode = "thermal"
        break
    default:
        print("SWITCHING TO VISUAL")
        camera!.setDisplayMode(DJICameraDisplayMode.visualOnly, withCompletion: nil)
        cameraMode = "visual"
        break
    }
}