M300无人机在遥控器上把一个目标给框起来,无人机自动追踪目标,我需要无人机自动追踪目标时的标志位和目标框的左上角和...
CompletedM300无人机在遥控器上把一个目标给框起来,无人机自动追踪目标,我需要无人机自动追踪目标时的标志位和目标框的左上角和右下角两个坐标点,需要用到哪些类和方法?
-
需要用到智能跟随activeTrack,相关的类有ActiveTrackOperator和ActiveTrackMission。相关的方法都封装在这两个类里,可以在API文档中检索这两个类。API:https://developer.dji.com/api-reference/android-api/Components/Missions/DJIActiveTrackMissionOperator.html 知识库也给出了智能跟随使用的方法,可以参考一下:M300的智能跟随怎么使用?- https://sdk-forum.dji.net/hc/zh-cn/articles/4413893670297?source=search&auth_token=eyJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50X2lkIjo5Nzg4MTcsInVzZXJfaWQiOjM2NTI3NTk5MjczNCwidGlja2V0X2lkIjo2ODM2MiwiY2hhbm5lbF9pZCI6NjMsInR5cGUiOiJTRUFSQ0giLCJleHAiOjE2NjE1NzE3MTd9.vsmtf-l5x9SCGoqsevCYY6_FVeZ7M40yKTJj9OdX1N0 -
代码是这么写的吗
package com.dji.sdk.sample.internal.controller;
import android.graphics.RectF;
import dji.common.error.DJIError;
import dji.common.mission.activetrack.ActiveTrackMission;
import dji.common.mission.activetrack.ActiveTrackMode;
import dji.common.util.CommonCallbacks;
import dji.sdk.mission.MissionControl;
import dji.sdk.mission.activetrack.ActiveTrackOperator;
/**
* 无人机目标自动追踪类
*/
public class TrackingActivity{
private ActiveTrackOperator mActiveTrackOperator;
private ActiveTrackMission mActiveTrackMission;
private ActiveTrackMode startMode = ActiveTrackMode.TRACE;
public TrackingActivity() {
mActiveTrackOperator = MissionControl.getInstance().getActiveTrackOperator();
if (mActiveTrackOperator == null) {
return;
}
mActiveTrackMission = new ActiveTrackMission(null, startMode);
//开始追踪
mActiveTrackOperator.startTracking(mActiveTrackMission, new CommonCallbacks.CompletionCallback() {
@Override
public void onResult(DJIError error) {
if (error == null) {
/**
* todo
* 调用第三方api把无人机开始追踪的信号和用户画的矩形框的4个角的坐标点等信息发送过去
*/
RectF targetRect = mActiveTrackMission.getTargetRect();
}
}
});
//停止追踪
mActiveTrackOperator.stopTracking(new CommonCallbacks.CompletionCallback() {
@Override
public void onResult(DJIError error) {
if (error == null) {
//todo 调用第三方api把无人机停止追踪的信号发送过去
}
}
});
}
}
Please sign in to leave a comment.
Comments
3 comments