How to adjust focus on Mavic 3E camera

已完成

评论

17 条评论

  • DJI Developer Support
    The KeyCameraFocusRingValue interface is only available in manual focus mode, meaning it may not be possible to achieve automatic focus adjustment through algorithms. I checked the specifications of the Mavic 3E, and the minimum focus distance it supports is 1 meter. Achieving a focus distance of 0.5 meters may not be feasible.
    0
    评论操作 固定链接
  • Robert Devenyi

    Yes that's why I want to use manual focus the KeyCameraFocusRingValue interface. My question is how to set up the whole interface programatically in a way that turns manual focus mode on and applies some focus (any random number, I will be experimenting for the optimal one). I would want some example code that uses manual focus and sets a focus value using KeyCameraFocusRingValue. I have a problem with figuring what objects to create and which methods to user. My code does not work right now, nothing happens just a constant zoom that is triggered by

    stream.setValue(ZOOM_CAMERA, null, null) 

    from:

    private fun manualFocus(focus: Int) {

    KeyCameraFocusMode.apply{ MANUAL }
    Log.d("focusing", "manual camera mode is on")

    //set video stream to zoom camera
    val stream = KeyCameraVideoStreamSource()
    stream.setValue(ZOOM_CAMERA, null, null)

    //set focus value
    KeyCameraFocusRingValue.create(50)
    Log.d("focusing", "focus changed")
    }
    0
    评论操作 固定链接
  • Robert Devenyi
    The following code does not do anything:
    KeyCameraFocusRingValue.create(50)
    0
    评论操作 固定链接
  • Robert Devenyi

    The most important question is how do I turn on MANUL FOCUS MODE ?

    I am using this - does this turn on manual focus mode? or i need to do something else: 

    KeyCameraFocusMode.apply { MANUAL }

    0
    评论操作 固定链接
  • Robert Devenyi

    Also, once I have this question, can i also get an example code snippet about adjusting exposure on the camera? Thank you in advance.

    0
    评论操作 固定链接
  • DJI Developer Support
    focusModeKey = KeyTools.createCameraKey(CameraKey.KeyCameraFocusMode,cameraIndex,lensType);  KeyManager.getInstance().setValue(focusModeKey, CameraFocusMode.MANUAL, new CommonCallbacks.CompletionCallback() {  @Override  public void onSuccess() {  //result  }  @Override  public void onFailure(@NonNull IDJIError idjiError) { //result  }  }); The text above is a sample code. Its function is to switch the focus mode to manual mode. You can review the method it uses to create KeyInfo and how to use KeyInfo to control the camera. The usage of KeyCameraFocusRingValue is similar.
    0
    评论操作 固定链接
  • Robert Devenyi

    Thank you this is promising. Which cameraindex is the zoom / focus camera? The Mavic 3E has two cameras. I am using index 0 right now.

    0
    评论操作 固定链接
  • Robert Devenyi

    Hi! This is what I have now but the camera does not focus. When I call the function both callbacks succeed. What might be the problem here?

    private fun manualFocus(focus: Int) {
    var focusModeKey = KeyTools.createCameraKey(
    KeyCameraFocusMode,
    ComponentIndexType.find(0),
    CameraLensType.CAMERA_LENS_ZOOM
    )
    var setfocusModeKey = KeyTools.createCameraKey(
    KeyCameraFocusRingValue,
    ComponentIndexType.find(0),
    CameraLensType.CAMERA_LENS_ZOOM
    )

    KeyManager.getInstance().setValue(focusModeKey, MANUAL, object : CommonCallbacks.CompletionCallback {
    override fun onSuccess() {
    Log.d("Jimmy","MANUAL focus mode is on.")
    }
    override fun onFailure(error: IDJIError) {
    Log.e("Jimmy", "MANUAL focus mode failed.")
    }
    })

    KeyManager.getInstance().setValue(setfocusModeKey, focus, object : CommonCallbacks.CompletionCallback {
    override fun onSuccess() {
    Log.d("Jimmy","Focus value set success.")
    }
    override fun onFailure(error: IDJIError) {
    Log.e("Jimmy", "Focus value set failure.")
    }
    })

    }
    0
    评论操作 固定链接
  • Robert Devenyi

    This is all in Kotlin.

    0
    评论操作 固定链接
  • Robert Devenyi

    I implemented your suggestion but the camera is not focusing at all, nothing is happening. I am using 

    ComponentIndexType.find(0) for cameraIndex and CAMERA_LENS_ZOOM for lensType,
    The rest of my code is the one i showed you above.
    0
    评论操作 固定链接
  • Robert Devenyi

    So i guess the next step would be to adjust focus to some value. i.e. 50. Is this the correct way to do it?

    var setfocusModeKey = KeyTools.createCameraKey(
    KeyCameraFocusRingValue,
    ComponentIndexType.find(0),
    CameraLensType.CAMERA_LENS_ZOOM
    )
    KeyManager.getInstance().setValue(setfocusModeKey, 50, object : CommonCallbacks.CompletionCallback {
    override fun onSuccess() {
    Log.d("Jimmy","Focus value set success.")
    }
    override fun onFailure(error: IDJIError) {
    Log.e("Jimmy", "Focus value set failure.")
    }
    })
    0
    评论操作 固定链接
  • Robert Devenyi

    Or am I missing sth here? Thanks for your help. I know I am asking a lot of questions, but the documentation is hard to navigate and there are many functions / methods that are not documented and the documentation also lacks examples.

    0
    评论操作 固定链接
  • Robert Devenyi

    If I add the following lines as requested in the documentation https://developer.dji.com/api-reference-v5/android-api/Components/IKeyManager/Key_Camera_CameraKey.html?search=keycamerafocusringval&i=0&#key_camera_camerafocusringvalue_inline, the camera zooms in but focus is not affected / cannot be set afterwards.

    val stream = KeyCameraVideoStreamSource()
    stream.setValue(ZOOM_CAMERA, null, null)
    0
    评论操作 固定链接
  • DJI Developer Support
    Above the KeyCameraFocusRingValue, there are two interfaces: KeyCameraFocusRingMinValue and KeyCameraFocusRingMaxValue. These interfaces are responsible for obtaining the focus ring range supported by KeyCameraFocusRingValue. When adjusting the focus value for a specific lens, you should ensure that the current image source is from that lens. Additionally, you need to wait until the focus mode switches to manual mode before setting the focus ring. You can either add a delay after setting the manual mode or listen for changes in the focus mode.
    0
    评论操作 固定链接
  • Robert Devenyi

    Ok so it works perfectly fine. I am setting the exposure (ISO, Shutterspeed), zoom and focus. The only new problem is that the feed coming the default camera after setting all the values mentioned above, changes its dimensions from 1920 x 1080 to something else probably 1280 x 960. I do not change anything, this change is triggered for some reason automatically whenever I change mainly the exposure. Any thoughts? Thanks

    0
    评论操作 固定链接
  • DJI Developer Support
    Could you let us know where the resolutions "1920 x 1080" and "1280 x 960" were obtained from?
    0
    评论操作 固定链接

请先登录再写评论。