提交 6d902d12 作者: 翁进城

fix: 航点动作AI补充

上级 afacdbff
......@@ -132,8 +132,8 @@ export default {
await this.getAirwayList();
// 获取正在飞行的航线
console.log('当前飞行状态', this.uavRealTimeData.isFlying);
if (this.uav && this.uavRealTimeData.isFlying) {
console.log('当前飞行状态', this.uavRealTimeData?.isFlying);
if (this.uav && this.uavRealTimeData?.isFlying) {
let res = await TaskInfo.getTaskInfoRecord({
deviceId: this.uav.deviceId,
});
......
......@@ -112,13 +112,20 @@ export default {
this.bus.$on("refreshAirway", this.getAirwayList);
await this.getAirwayList();
// 获取正在飞行的航线
console.log("当前飞行状态", this.uavRealTimeData.isFlying);
if (this.uav && this.uavRealTimeData.isFlying) {
console.log("当前飞行状态", this.uavRealTimeData?.isFlying);
if (this.uav && this.uavRealTimeData?.isFlying) {
let res = await TaskInfo.getTaskInfoRecord({
deviceId: this.uav.deviceId,
});
if (res.code === 0) {
this.selectedAirwayId = res.data.reouteId;
// 在一次时机中再取航线数据存进store中
this.$nextTick(() =>
this.$store.commit("MMCFlightControlCenter/uav/setState", {
key: "airlineData",
value: this.selectedAirway,
})
);
}
}
},
......
......@@ -3,7 +3,7 @@
<el-tooltip content="AI识别" placement="bottom">
<div class="menu-item">
<img src="./assets/images/car1.png" @click="aiVisible = !aiVisible" />
<div class="ai-list" v-if="aiVisible">
<div class="ai-list" v-show="aiVisible">
<el-tooltip
v-for="(item,index) in aiIdentifyList"
:key="index"
......@@ -68,7 +68,7 @@ export default {
{
title: "烟雾识别",
type: "smoke",
typeId: 4,
typeId: 7,
img: require("./assets/images/烟雾识别.svg"),
},
{
......@@ -98,6 +98,21 @@ export default {
* ai识别事件
*/
onAiIdentify(type) {
this.aiIdentify(type, (img) => {
if (img) {
// 展示识别结果
this.$message.success("识别成功");
this.aiResultImg = img;
this.aiResultShow = true;
} else {
this.$message.error("识别失败");
}
});
},
/**
* ai处理, 父组件也调用
*/
aiIdentify(type, callback) {
let find = this.aiIdentifyList.find((item) => item.type === type);
this.aiTitle = find.title;
let isSuccess = false;
......@@ -117,7 +132,7 @@ export default {
];
switch (type) {
// 车牌识别 自研
/* case "plate": {
/* case "plate": {
let formData = new FormData();
formData.append("image", blob, `下载.jpeg`);
formData.append("iscount", 1);
......@@ -238,7 +253,7 @@ export default {
]; */
results =
res?.data?.data?.targets?./* targets. */map((item) => {
res?.data?.data?.targets?./* targets. */ map((item) => {
return {
x: item.bbox.box.left_top_x,
y: item.bbox.box.left_top_y,
......@@ -260,7 +275,7 @@ export default {
if (isSuccess) {
console.log("识别结果", results);
this.$message.success("识别成功");
// 将识别结果绘制到图片上
let img = new Image();
img.onload = async () => {
......@@ -271,11 +286,9 @@ export default {
// 现在可以在Canvas上绘制图片和矩形框
let canvas = this.drawOnCanvas(img, width, height, results);
// 展示识别结果
this.aiResultImg = canvas.toDataURL("image/svg");
this.aiResultShow = true;
// 识别结果上传到视图库
callback(canvas.toDataURL("image/svg"));
// 识别结果上传到视图库
canvas.toBlob(async (blob1) => {
console.log("识别结果", blob1);
let formData = new FormData();
......@@ -303,9 +316,8 @@ export default {
});
};
img.src = base64;
// img.src = testImg;
} else {
this.$message.error("识别失败");
callback(false);
}
},
});
......
......@@ -240,7 +240,13 @@ export default {
console.log(val, "航点");
val.speed = this.speed;
// this.$set(val, "aiList", this.aiList);
val.aiList = JSON.parse(JSON.stringify(this.aiList));
val.aiList = this.aiList
.filter((item) => item.switch)
.map((item) => ({
id: item.id,
type: item.type,
isSingle: item.check,
}));
val.actions[2].param1 = this.min * 60 + this.se;
}
});
......@@ -326,7 +332,7 @@ export default {
img: svgFace,
},
{
id: 2,
id: 8,
type: "车牌识别",
switch: false,
check: false,
......@@ -339,23 +345,24 @@ export default {
check: false,
img: svgPeople,
},
{
id: 4,
type: "游泳识别",
id: 7,
type: "烟雾识别",
switch: false,
check: false,
img: svgSwim,
img: svgYan,
},
{
id: 7,
type: "烟雾识别",
id: 4,
type: "漏油识别",
switch: false,
check: false,
img: svgYan,
img: svgSwim,
},
{
id: 6,
type: "异物识别",
type: "裸土识别",
switch: false,
check: false,
img: svgThings,
......@@ -488,16 +495,6 @@ export default {
});
let time = parseInt(distance / 6);
let aiList = this.aiList
.filter((item) => item.switch)
.map((item) => {
return {
id: item.id,
type: item.type,
isSingle: item.check,
};
});
let waypoints = this.pointList.map((val) => {
return {
altitude: val.alt,
......@@ -509,7 +506,7 @@ export default {
speed: this.speed,
stay: 0,
waypointActions: val.actions,
aiList: aiList,
aiList: val.aiList,
};
});
let data = {
......
......@@ -336,7 +336,7 @@
<img src="./assets/images/photojz.svg" />
</div>
</el-tooltip>
<AiList @screenShot="onAiScreenShot"></AiList>
<AiList ref="aiList" @screenShot="onAiScreenShot"></AiList>
<div class="menu-item" @click="startLinePoint" content="航点动作">
<img src="./assets/images/point_small.svg" />
</div>
......@@ -362,7 +362,7 @@ import SRSPlayer from "./components/srs";
import { to_moveMount } from "../../../../utils/to_moveMount.js";
import Obstacle from "./components/obstacle";
import PointList from "./components/pointList";
import videoModelChange from "./components/videoModelChange";;
import videoModelChange from "./components/videoModelChange";
import { mapState } from "vuex";
import AiList from "./components/aiList";
......@@ -426,10 +426,16 @@ export default {
},
isInfoShow: false,
showFlywayAction: false, //显示航点动作
aiTimeHandle: null, //ai执行定时句柄
};
},
computed: {
...mapState("MMCFlightControlCenter/uav", ["uav", "selectMount", "isQingLiu"]),
...mapState("MMCFlightControlCenter/uav", [
"uav",
"selectMount",
"isQingLiu",
"airlineData",
]),
/**
* 播放器组件名
*/
......@@ -550,17 +556,52 @@ export default {
}
},
},
uavRealTimeData: function (newval) {
"uavRealTimeData.airlineProgress": {
handler(newVal, oldVal) {
//获取当前航线航点的ai, 进行ai操作
if (newVal?.waypointIndex === oldVal?.waypointIndex) {
return;
}
//清除上一个航点的执行定时器
clearInterval(this.aiTimeHandle);
let find = this.airlineData?.linePointSaveReqVOS?.find(
(item, i) => i === newVal.waypointIndex
);
if (find) {
let singleList = find.pointDetectorSaveReqVOS.filter(
(item) => item.detectorValue === 0
); //汇总单点
let manyList = find.pointDetectorSaveReqVOS.filter(
(item) => item.detectorValue === 1
); //汇总多次
//执行单点
this.$nextTick(() => {
singleList.forEach((item) => {
this.$refs.aiList.aiIdentify(item.id);
});
});
//定时执行
this.aiTimeHandle = setInterval(() => {
manyList?.forEach((item) => {
this.$refs.aiList.aiIdentify(item.id);
});
}, 3000);
}
},
},
uavRealTimeData: function (newVal) {
let gps = null;
if (
newval &&
newval.rtk &&
newval.rtk.type == 19 &&
newval.rtk.isMainSensor
newVal &&
newVal.rtk &&
newVal.rtk.type == 19 &&
newVal.rtk.isMainSensor
) {
gps = newval.rtk;
gps = newVal.rtk;
} else {
gps = newval.gps;
gps = newVal.gps;
}
if (!gps) {
return;
......@@ -610,6 +651,7 @@ export default {
},
beforeDestroy() {
window.removeEventListener("resize", this.fullScreenChangeFn);
clearInterval(this.aiTimeHandle);
},
methods: {
startLinePoint() {
......@@ -747,7 +789,7 @@ export default {
this.$store.dispatch("MMCFlightControlCenter/uav/takePhotos", {
isQingLiu: this.isQingLiu,
videoID: 1, // 视频通道ID(需保持唯一)
/* dbID: "929", // 历史记录id
/* dbID: "929", // 历史记录id
name: "z30Pro", // 挂载名称(如果知道挂载名称,将传名称即可,通道号可以不用传)
taskID: "", // 任务ID,可传可不传 */
callback: (isOk) => {
......
......@@ -18,7 +18,7 @@ const defaultPos = {
function initUavRealTimeData() {
return {
isFlying: false, // true 飞机处于飞行中,电动机解锁后,飞机就处于飞行中
isFlying: false, // true 飞机处于飞行中,电动机解锁后,飞机就处于飞行中
attitude: {
roll: 0, // 飞机的俯仰值:向前为正,向后为负。单位为度。
pitch: 0, // 飞机的横滚值:正向为正,反向为负。单位为度。
......@@ -183,6 +183,15 @@ function initUavRealTimeData() {
autoFlightSpeed: 0, //航线飞行速度默认5m
waypointList: null,
},
airlineProgress: {
action: "NON", //执行的动作,NON表示飞到航点位置
actionIndex: 1, //航点动作执行索引
isFinish: true, //true航线任务执行完成,false未完成
isFinishAction: true, //航点执行完成,true执行完成,false为执行完成
progress: 0, //航线任务执行进度
totalWaypointCount: 0, //航线任务总进度
waypointIndex: 1, //执行航点索引值,从1开始
},
};
}
......@@ -313,6 +322,7 @@ const actions = {
const type270 = data[270]?.data; // 飞控应答消息
const type260 = data[260]?.data; // 无人机提示信息
const type261 = data[261]?.data; // 航线上传完成信息
const type265 = data[265]?.data; // 航线执行进度
let msgList = state.uavRealTimeData.msgList || [];
......@@ -392,6 +402,7 @@ const actions = {
msg: type270,
msgList,
uploadAirline: type261,
airlineProgress: type265,
},
});
......@@ -674,7 +685,7 @@ const actions = {
// 生成架次号
const flightSortieId = await TaskInfo.flightSortieId({
device_id: state.hangar.uav.deviceId,
reouteId: state.airlineData.id
reouteId: state.airlineData.id,
});
/* const flightSortieId = {
data: `tmj-v4-${Date.now()}`
......@@ -1176,7 +1187,7 @@ const actions = {
type: 528,
};
let isQingLiu = state.isQingLiu;
if(data.isQingLiu !== undefined){
if (data.isQingLiu !== undefined) {
isQingLiu = data.isQingLiu;
}
if (isQingLiu) {
......@@ -1246,7 +1257,7 @@ const actions = {
type: 528,
};
let isQingLiu = state.isQingLiu;
if(data.isQingLiu !== undefined){
if (data.isQingLiu !== undefined) {
isQingLiu = data.isQingLiu;
}
if (isQingLiu) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论