提交 6d902d12 作者: 翁进城

fix: 航点动作AI补充

上级 afacdbff
...@@ -132,8 +132,8 @@ export default { ...@@ -132,8 +132,8 @@ export default {
await this.getAirwayList(); await this.getAirwayList();
// 获取正在飞行的航线 // 获取正在飞行的航线
console.log('当前飞行状态', this.uavRealTimeData.isFlying); console.log('当前飞行状态', this.uavRealTimeData?.isFlying);
if (this.uav && this.uavRealTimeData.isFlying) { if (this.uav && this.uavRealTimeData?.isFlying) {
let res = await TaskInfo.getTaskInfoRecord({ let res = await TaskInfo.getTaskInfoRecord({
deviceId: this.uav.deviceId, deviceId: this.uav.deviceId,
}); });
......
...@@ -112,13 +112,20 @@ export default { ...@@ -112,13 +112,20 @@ export default {
this.bus.$on("refreshAirway", this.getAirwayList); this.bus.$on("refreshAirway", this.getAirwayList);
await this.getAirwayList(); await this.getAirwayList();
// 获取正在飞行的航线 // 获取正在飞行的航线
console.log("当前飞行状态", this.uavRealTimeData.isFlying); console.log("当前飞行状态", this.uavRealTimeData?.isFlying);
if (this.uav && this.uavRealTimeData.isFlying) { if (this.uav && this.uavRealTimeData?.isFlying) {
let res = await TaskInfo.getTaskInfoRecord({ let res = await TaskInfo.getTaskInfoRecord({
deviceId: this.uav.deviceId, deviceId: this.uav.deviceId,
}); });
if (res.code === 0) { if (res.code === 0) {
this.selectedAirwayId = res.data.reouteId; this.selectedAirwayId = res.data.reouteId;
// 在一次时机中再取航线数据存进store中
this.$nextTick(() =>
this.$store.commit("MMCFlightControlCenter/uav/setState", {
key: "airlineData",
value: this.selectedAirway,
})
);
} }
} }
}, },
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<el-tooltip content="AI识别" placement="bottom"> <el-tooltip content="AI识别" placement="bottom">
<div class="menu-item"> <div class="menu-item">
<img src="./assets/images/car1.png" @click="aiVisible = !aiVisible" /> <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 <el-tooltip
v-for="(item,index) in aiIdentifyList" v-for="(item,index) in aiIdentifyList"
:key="index" :key="index"
...@@ -68,7 +68,7 @@ export default { ...@@ -68,7 +68,7 @@ export default {
{ {
title: "烟雾识别", title: "烟雾识别",
type: "smoke", type: "smoke",
typeId: 4, typeId: 7,
img: require("./assets/images/烟雾识别.svg"), img: require("./assets/images/烟雾识别.svg"),
}, },
{ {
...@@ -98,6 +98,21 @@ export default { ...@@ -98,6 +98,21 @@ export default {
* ai识别事件 * ai识别事件
*/ */
onAiIdentify(type) { 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); let find = this.aiIdentifyList.find((item) => item.type === type);
this.aiTitle = find.title; this.aiTitle = find.title;
let isSuccess = false; let isSuccess = false;
...@@ -238,7 +253,7 @@ export default { ...@@ -238,7 +253,7 @@ export default {
]; */ ]; */
results = results =
res?.data?.data?.targets?./* targets. */map((item) => { res?.data?.data?.targets?./* targets. */ map((item) => {
return { return {
x: item.bbox.box.left_top_x, x: item.bbox.box.left_top_x,
y: item.bbox.box.left_top_y, y: item.bbox.box.left_top_y,
...@@ -260,7 +275,7 @@ export default { ...@@ -260,7 +275,7 @@ export default {
if (isSuccess) { if (isSuccess) {
console.log("识别结果", results); console.log("识别结果", results);
this.$message.success("识别成功");
// 将识别结果绘制到图片上 // 将识别结果绘制到图片上
let img = new Image(); let img = new Image();
img.onload = async () => { img.onload = async () => {
...@@ -271,11 +286,9 @@ export default { ...@@ -271,11 +286,9 @@ export default {
// 现在可以在Canvas上绘制图片和矩形框 // 现在可以在Canvas上绘制图片和矩形框
let canvas = this.drawOnCanvas(img, width, height, results); let canvas = this.drawOnCanvas(img, width, height, results);
// 展示识别结果 callback(canvas.toDataURL("image/svg"));
this.aiResultImg = canvas.toDataURL("image/svg");
this.aiResultShow = true;
// 识别结果上传到视图库
// 识别结果上传到视图库
canvas.toBlob(async (blob1) => { canvas.toBlob(async (blob1) => {
console.log("识别结果", blob1); console.log("识别结果", blob1);
let formData = new FormData(); let formData = new FormData();
...@@ -303,9 +316,8 @@ export default { ...@@ -303,9 +316,8 @@ export default {
}); });
}; };
img.src = base64; img.src = base64;
// img.src = testImg;
} else { } else {
this.$message.error("识别失败"); callback(false);
} }
}, },
}); });
......
...@@ -240,7 +240,13 @@ export default { ...@@ -240,7 +240,13 @@ export default {
console.log(val, "航点"); console.log(val, "航点");
val.speed = this.speed; val.speed = this.speed;
// this.$set(val, "aiList", this.aiList); // 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; val.actions[2].param1 = this.min * 60 + this.se;
} }
}); });
...@@ -326,7 +332,7 @@ export default { ...@@ -326,7 +332,7 @@ export default {
img: svgFace, img: svgFace,
}, },
{ {
id: 2, id: 8,
type: "车牌识别", type: "车牌识别",
switch: false, switch: false,
check: false, check: false,
...@@ -339,23 +345,24 @@ export default { ...@@ -339,23 +345,24 @@ export default {
check: false, check: false,
img: svgPeople, img: svgPeople,
}, },
{ {
id: 4, id: 7,
type: "游泳识别", type: "烟雾识别",
switch: false, switch: false,
check: false, check: false,
img: svgSwim, img: svgYan,
}, },
{ {
id: 7, id: 4,
type: "烟雾识别", type: "漏油识别",
switch: false, switch: false,
check: false, check: false,
img: svgYan, img: svgSwim,
}, },
{ {
id: 6, id: 6,
type: "异物识别", type: "裸土识别",
switch: false, switch: false,
check: false, check: false,
img: svgThings, img: svgThings,
...@@ -488,16 +495,6 @@ export default { ...@@ -488,16 +495,6 @@ export default {
}); });
let time = parseInt(distance / 6); 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) => { let waypoints = this.pointList.map((val) => {
return { return {
altitude: val.alt, altitude: val.alt,
...@@ -509,7 +506,7 @@ export default { ...@@ -509,7 +506,7 @@ export default {
speed: this.speed, speed: this.speed,
stay: 0, stay: 0,
waypointActions: val.actions, waypointActions: val.actions,
aiList: aiList, aiList: val.aiList,
}; };
}); });
let data = { let data = {
......
...@@ -336,7 +336,7 @@ ...@@ -336,7 +336,7 @@
<img src="./assets/images/photojz.svg" /> <img src="./assets/images/photojz.svg" />
</div> </div>
</el-tooltip> </el-tooltip>
<AiList @screenShot="onAiScreenShot"></AiList> <AiList ref="aiList" @screenShot="onAiScreenShot"></AiList>
<div class="menu-item" @click="startLinePoint" content="航点动作"> <div class="menu-item" @click="startLinePoint" content="航点动作">
<img src="./assets/images/point_small.svg" /> <img src="./assets/images/point_small.svg" />
</div> </div>
...@@ -362,7 +362,7 @@ import SRSPlayer from "./components/srs"; ...@@ -362,7 +362,7 @@ import SRSPlayer from "./components/srs";
import { to_moveMount } from "../../../../utils/to_moveMount.js"; import { to_moveMount } from "../../../../utils/to_moveMount.js";
import Obstacle from "./components/obstacle"; import Obstacle from "./components/obstacle";
import PointList from "./components/pointList"; import PointList from "./components/pointList";
import videoModelChange from "./components/videoModelChange";; import videoModelChange from "./components/videoModelChange";
import { mapState } from "vuex"; import { mapState } from "vuex";
import AiList from "./components/aiList"; import AiList from "./components/aiList";
...@@ -426,10 +426,16 @@ export default { ...@@ -426,10 +426,16 @@ export default {
}, },
isInfoShow: false, isInfoShow: false,
showFlywayAction: false, //显示航点动作 showFlywayAction: false, //显示航点动作
aiTimeHandle: null, //ai执行定时句柄
}; };
}, },
computed: { computed: {
...mapState("MMCFlightControlCenter/uav", ["uav", "selectMount", "isQingLiu"]), ...mapState("MMCFlightControlCenter/uav", [
"uav",
"selectMount",
"isQingLiu",
"airlineData",
]),
/** /**
* 播放器组件名 * 播放器组件名
*/ */
...@@ -550,17 +556,52 @@ export default { ...@@ -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; let gps = null;
if ( if (
newval && newVal &&
newval.rtk && newVal.rtk &&
newval.rtk.type == 19 && newVal.rtk.type == 19 &&
newval.rtk.isMainSensor newVal.rtk.isMainSensor
) { ) {
gps = newval.rtk; gps = newVal.rtk;
} else { } else {
gps = newval.gps; gps = newVal.gps;
} }
if (!gps) { if (!gps) {
return; return;
...@@ -610,6 +651,7 @@ export default { ...@@ -610,6 +651,7 @@ export default {
}, },
beforeDestroy() { beforeDestroy() {
window.removeEventListener("resize", this.fullScreenChangeFn); window.removeEventListener("resize", this.fullScreenChangeFn);
clearInterval(this.aiTimeHandle);
}, },
methods: { methods: {
startLinePoint() { startLinePoint() {
......
...@@ -183,6 +183,15 @@ function initUavRealTimeData() { ...@@ -183,6 +183,15 @@ function initUavRealTimeData() {
autoFlightSpeed: 0, //航线飞行速度默认5m autoFlightSpeed: 0, //航线飞行速度默认5m
waypointList: null, 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 = { ...@@ -313,6 +322,7 @@ const actions = {
const type270 = data[270]?.data; // 飞控应答消息 const type270 = data[270]?.data; // 飞控应答消息
const type260 = data[260]?.data; // 无人机提示信息 const type260 = data[260]?.data; // 无人机提示信息
const type261 = data[261]?.data; // 航线上传完成信息 const type261 = data[261]?.data; // 航线上传完成信息
const type265 = data[265]?.data; // 航线执行进度
let msgList = state.uavRealTimeData.msgList || []; let msgList = state.uavRealTimeData.msgList || [];
...@@ -392,6 +402,7 @@ const actions = { ...@@ -392,6 +402,7 @@ const actions = {
msg: type270, msg: type270,
msgList, msgList,
uploadAirline: type261, uploadAirline: type261,
airlineProgress: type265,
}, },
}); });
...@@ -674,7 +685,7 @@ const actions = { ...@@ -674,7 +685,7 @@ const actions = {
// 生成架次号 // 生成架次号
const flightSortieId = await TaskInfo.flightSortieId({ const flightSortieId = await TaskInfo.flightSortieId({
device_id: state.hangar.uav.deviceId, device_id: state.hangar.uav.deviceId,
reouteId: state.airlineData.id reouteId: state.airlineData.id,
}); });
/* const flightSortieId = { /* const flightSortieId = {
data: `tmj-v4-${Date.now()}` data: `tmj-v4-${Date.now()}`
...@@ -1176,7 +1187,7 @@ const actions = { ...@@ -1176,7 +1187,7 @@ const actions = {
type: 528, type: 528,
}; };
let isQingLiu = state.isQingLiu; let isQingLiu = state.isQingLiu;
if(data.isQingLiu !== undefined){ if (data.isQingLiu !== undefined) {
isQingLiu = data.isQingLiu; isQingLiu = data.isQingLiu;
} }
if (isQingLiu) { if (isQingLiu) {
...@@ -1246,7 +1257,7 @@ const actions = { ...@@ -1246,7 +1257,7 @@ const actions = {
type: 528, type: 528,
}; };
let isQingLiu = state.isQingLiu; let isQingLiu = state.isQingLiu;
if(data.isQingLiu !== undefined){ if (data.isQingLiu !== undefined) {
isQingLiu = data.isQingLiu; isQingLiu = data.isQingLiu;
} }
if (isQingLiu) { if (isQingLiu) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论