|
@@ -95,17 +95,30 @@
|
|
|
<view class="recognition-result" v-if="pestList.length">
|
|
<view class="recognition-result" v-if="pestList.length">
|
|
|
<view class="result-title">当前图片识别结果</view>
|
|
<view class="result-title">当前图片识别结果</view>
|
|
|
<!-- 一类害虫 -->
|
|
<!-- 一类害虫 -->
|
|
|
- <view class="pest-category" v-for="(pest,index) in pestList" :key="index">
|
|
|
|
|
- <view class="category-header">
|
|
|
|
|
- <text class="category-title">{{ pest[0] }}</text>
|
|
|
|
|
- <text class="category-count">数量</text>
|
|
|
|
|
|
|
+ <view v-if="is_mark == 0">
|
|
|
|
|
+ <view class="pest-category" v-for="(pest,index) in pestList" :key="index">
|
|
|
|
|
+ <view class="category-header">
|
|
|
|
|
+ <text class="category-title">{{ pest[0] }}</text>
|
|
|
|
|
+ <text class="category-count">数量</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view class="pest-item" v-for="(p, i) in pest[1]" :key="i">
|
|
|
|
|
+ <view class="pest-info">
|
|
|
|
|
+ <view class="pest-color" :style="{ backgroundColor: getPestColor(p.pest_name) }"></view>
|
|
|
|
|
+ <text class="pest-name">{{ p.pest_name }}</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <text class="pest-count">{{ p.pest_num }}</text>
|
|
|
|
|
+ </view>
|
|
|
</view>
|
|
</view>
|
|
|
- <view class="pest-item" v-for="(p, i) in pest[1]" :key="i">
|
|
|
|
|
- <view class="pest-info">
|
|
|
|
|
- <view class="pest-color" :style="{ backgroundColor: getPestColor(p.pest_name) }"></view>
|
|
|
|
|
- <text class="pest-name">{{ p.pest_name }}</text>
|
|
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view v-else>
|
|
|
|
|
+ <view class="pest-category" v-for="(pest,index) in pestList" :key="index">
|
|
|
|
|
+ <view class="pest-item">
|
|
|
|
|
+ <view class="pest-info">
|
|
|
|
|
+ <view class="pest-color" :style="{ backgroundColor: getPestColor(pest[1].text) }"></view>
|
|
|
|
|
+ <text class="pest-name">{{ pest[1].text }}</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <text class="pest-count">{{ pest[1].value }}</text>
|
|
|
</view>
|
|
</view>
|
|
|
- <text class="pest-count">{{ p.pest_num }}</text>
|
|
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -138,6 +151,7 @@ export default {
|
|
|
title: '查看图片',
|
|
title: '查看图片',
|
|
|
currentThumbnail: 2,
|
|
currentThumbnail: 2,
|
|
|
pestYype:{},
|
|
pestYype:{},
|
|
|
|
|
+ is_mark:0,
|
|
|
device_id: '',
|
|
device_id: '',
|
|
|
time_begin: this.formatTime(new Date(new Date().getFullYear(), 0, 1)),
|
|
time_begin: this.formatTime(new Date(new Date().getFullYear(), 0, 1)),
|
|
|
time_end: this.formatTime(new Date()),
|
|
time_end: this.formatTime(new Date()),
|
|
@@ -190,13 +204,16 @@ export default {
|
|
|
}
|
|
}
|
|
|
this.pestList = [];
|
|
this.pestList = [];
|
|
|
await this.getPestDict();
|
|
await this.getPestDict();
|
|
|
- this.getPestLevelMap();
|
|
|
|
|
- this.getPestList();
|
|
|
|
|
|
|
+ await this.getPestLevelMap();
|
|
|
|
|
+ await this.getPestList();
|
|
|
// this.getDevicePhotoDetails();
|
|
// this.getDevicePhotoDetails();
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
getPestName(id){
|
|
getPestName(id){
|
|
|
- return this.pestDict[id] || id;
|
|
|
|
|
|
|
+ if(this.is_mark == 0){
|
|
|
|
|
+ return this.pestDict[id] || id;
|
|
|
|
|
+ }
|
|
|
|
|
+ return id;
|
|
|
},
|
|
},
|
|
|
async confirmHandler(e){
|
|
async confirmHandler(e){
|
|
|
this.currentYear = this.selectorRange[e].id;
|
|
this.currentYear = this.selectorRange[e].id;
|
|
@@ -209,8 +226,8 @@ export default {
|
|
|
this.time_begin = this.formatTime(new Date(this.currentYear, 0, 1));
|
|
this.time_begin = this.formatTime(new Date(this.currentYear, 0, 1));
|
|
|
this.time_end = this.formatTime(new Date(this.currentYear, 11, 31));
|
|
this.time_end = this.formatTime(new Date(this.currentYear, 11, 31));
|
|
|
this.maxDate = this.formatTime(new Date(this.currentYear, 11, 31));
|
|
this.maxDate = this.formatTime(new Date(this.currentYear, 11, 31));
|
|
|
- this.minDate = this.formatTime(new Date(this.currentYear, 0, 1));
|
|
|
|
|
- this.defaultDate = this.minDate;
|
|
|
|
|
|
|
+ this.minDate = this.formatTime(new Date(this.currentYear, 0, 1));
|
|
|
|
|
+ this.defaultDate = this.minDate;
|
|
|
}
|
|
}
|
|
|
this.showPicker = false;
|
|
this.showPicker = false;
|
|
|
this.pestList = [];
|
|
this.pestList = [];
|
|
@@ -364,13 +381,20 @@ export default {
|
|
|
}
|
|
}
|
|
|
pest_list.forEach(item => {
|
|
pest_list.forEach(item => {
|
|
|
if(!pesAlltList.includes(item.pest_name)){
|
|
if(!pesAlltList.includes(item.pest_name)){
|
|
|
- pestArr.get('其他害虫').push(item)
|
|
|
|
|
|
|
+ if(pestArr.has('其他害虫')){
|
|
|
|
|
+ pestArr.get('其他害虫').push(item)
|
|
|
|
|
+ }else{
|
|
|
|
|
+ pestArr.set('其他害虫', [item])
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
const pestList = []
|
|
const pestList = []
|
|
|
for(let key of pestArr){
|
|
for(let key of pestArr){
|
|
|
pestList.push(key)
|
|
pestList.push(key)
|
|
|
}
|
|
}
|
|
|
|
|
+ if (this.currentImg.is_mark != 0) {
|
|
|
|
|
+ this.processBugMarkers();
|
|
|
|
|
+ }
|
|
|
this.pestList = pestList
|
|
this.pestList = pestList
|
|
|
},
|
|
},
|
|
|
onImageLoad(e) {
|
|
onImageLoad(e) {
|
|
@@ -391,66 +415,120 @@ export default {
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
processBugMarkers() {
|
|
processBugMarkers() {
|
|
|
- console.log('开始处理label参数:', this.currentImg.label);
|
|
|
|
|
- if (!this.currentImg.label) {
|
|
|
|
|
- console.log('没有label参数');
|
|
|
|
|
- this.bugMarkers = [];
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (this.currentImg.is_mark === 0) {
|
|
|
|
|
+ if (!this.currentImg.label) {
|
|
|
|
|
+ console.log('没有label参数');
|
|
|
|
|
+ this.bugMarkers = [];
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 如果没有图片尺寸,先设置默认值
|
|
|
|
|
- if (!this.imageWidth || !this.imageHeight) {
|
|
|
|
|
- console.log('没有图片尺寸,使用默认值');
|
|
|
|
|
- this.imageWidth = 1000;
|
|
|
|
|
- this.imageHeight = 1000;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 如果没有图片尺寸,先设置默认值
|
|
|
|
|
+ if (!this.imageWidth || !this.imageHeight) {
|
|
|
|
|
+ console.log('没有图片尺寸,使用默认值');
|
|
|
|
|
+ this.imageWidth = 1000;
|
|
|
|
|
+ this.imageHeight = 1000;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- try {
|
|
|
|
|
- // 处理label参数,将单引号替换为双引号
|
|
|
|
|
- let labelStr = this.currentImg.label;
|
|
|
|
|
- labelStr = labelStr.replace(/'/g, '"');
|
|
|
|
|
- const label = JSON.parse(labelStr);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 根据原图宽度计算缩放比例
|
|
|
|
|
+ let scaleRatio;
|
|
|
|
|
+ if (this.imageWidth >= 5000) {
|
|
|
|
|
+ scaleRatio = 1;
|
|
|
|
|
+ } else if (this.imageWidth >= 4000) {
|
|
|
|
|
+ scaleRatio = 1;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ scaleRatio = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 处理label参数,将单引号替换为双引号
|
|
|
|
|
+ let labelStr = this.currentImg.label;
|
|
|
|
|
+ labelStr = labelStr.replace(/'/g, '"');
|
|
|
|
|
+ console.log(labelStr,'labelStrlabelStr')
|
|
|
|
|
+ const label = JSON.parse(labelStr);
|
|
|
|
|
+ const markers = [];
|
|
|
|
|
+
|
|
|
|
|
+ console.log('原图宽度:', this.imageWidth, '缩放比例:', scaleRatio);
|
|
|
|
|
+
|
|
|
|
|
+ label.forEach(item => {
|
|
|
|
|
+ for (let key in item) {
|
|
|
|
|
+ const [x1, y1, x2, y2] = item[key];
|
|
|
|
|
+ // 使用缩放比例计算标记位置和尺寸
|
|
|
|
|
+ const x = (x1 * scaleRatio / this.imageWidth) * 100;
|
|
|
|
|
+ const y = (y1 * scaleRatio / this.imageHeight) * 100;
|
|
|
|
|
+ const width = ((x2 - x1) * scaleRatio / this.imageWidth) * 100;
|
|
|
|
|
+ const height = ((y2 - y1) * scaleRatio / this.imageHeight) * 100;
|
|
|
|
|
+
|
|
|
|
|
+ // 从字典中获取虫子名字(尝试字符串和数字两种类型)
|
|
|
|
|
+ const pestName = this.pestDict[key] || this.pestDict[String(key)] || key;
|
|
|
|
|
+ const color = this.getPestColor(pestName);
|
|
|
|
|
+
|
|
|
|
|
+ markers.push({
|
|
|
|
|
+ id: pestName, // 显示虫子名字
|
|
|
|
|
+ x,
|
|
|
|
|
+ y,
|
|
|
|
|
+ width,
|
|
|
|
|
+ height,
|
|
|
|
|
+ color
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ console.log(markers,'markersmarkers')
|
|
|
|
|
+ this.bugMarkers = markers;
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('处理label参数失败:', error);
|
|
|
|
|
+ this.bugMarkers = [];
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.pestList = [];
|
|
|
const markers = [];
|
|
const markers = [];
|
|
|
-
|
|
|
|
|
// 根据原图宽度计算缩放比例
|
|
// 根据原图宽度计算缩放比例
|
|
|
- let scaleRatio;
|
|
|
|
|
- if (this.imageWidth >= 5000) {
|
|
|
|
|
- scaleRatio = 1;
|
|
|
|
|
- } else if (this.imageWidth >= 4000) {
|
|
|
|
|
- scaleRatio = 1;
|
|
|
|
|
- } else {
|
|
|
|
|
- scaleRatio = 1;
|
|
|
|
|
- }
|
|
|
|
|
- console.log('原图宽度:', this.imageWidth, '缩放比例:', scaleRatio);
|
|
|
|
|
-
|
|
|
|
|
- label.forEach(item => {
|
|
|
|
|
- for (let key in item) {
|
|
|
|
|
- const [x1, y1, x2, y2] = item[key];
|
|
|
|
|
- // 使用缩放比例计算标记位置和尺寸
|
|
|
|
|
- const x = (x1 * scaleRatio / this.imageWidth) * 100;
|
|
|
|
|
- const y = (y1 * scaleRatio / this.imageHeight) * 100;
|
|
|
|
|
- const width = ((x2 - x1) * scaleRatio / this.imageWidth) * 100;
|
|
|
|
|
- const height = ((y2 - y1) * scaleRatio / this.imageHeight) * 100;
|
|
|
|
|
-
|
|
|
|
|
- // 从字典中获取虫子名字(尝试字符串和数字两种类型)
|
|
|
|
|
- const pestName = this.pestDict[key] || this.pestDict[String(key)] || key;
|
|
|
|
|
- const color = this.getPestColor(pestName);
|
|
|
|
|
-
|
|
|
|
|
- markers.push({
|
|
|
|
|
- id: pestName, // 显示虫子名字
|
|
|
|
|
- x,
|
|
|
|
|
- y,
|
|
|
|
|
- width,
|
|
|
|
|
- height,
|
|
|
|
|
- color
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ let scaleRatio = 4;
|
|
|
|
|
+ // if (this.imageWidth >= 5000) {
|
|
|
|
|
+ // scaleRatio = 4;
|
|
|
|
|
+ // } else if (this.imageWidth >= 4000) {
|
|
|
|
|
+ // scaleRatio = 1;
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // scaleRatio = 2.5;
|
|
|
|
|
+ // }
|
|
|
|
|
+ const pestArr = new Map()
|
|
|
|
|
+ this.currentImg.mark.map((item, index) => {
|
|
|
|
|
+ if(pestArr.has(item.text)){
|
|
|
|
|
+ pestArr.set(item.text,{
|
|
|
|
|
+ value: pestArr.get(item.text).value+=1,
|
|
|
|
|
+ text: item.text
|
|
|
|
|
+ })
|
|
|
|
|
+ }else{
|
|
|
|
|
+ pestArr.set(item.text, {
|
|
|
|
|
+ value: 1,
|
|
|
|
|
+ text: item.text
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ const pestList = []
|
|
|
|
|
+ for(let key of pestArr){
|
|
|
|
|
+ pestList.push(key)
|
|
|
}
|
|
}
|
|
|
|
|
+ this.pestList = pestList
|
|
|
|
|
+ this.is_mark = 1
|
|
|
|
|
+ const { startX, startY,text } = item;
|
|
|
|
|
+ // 使用缩放比例计算标记位置和尺寸
|
|
|
|
|
+ const x = (startX * scaleRatio / this.imageWidth) * 100;
|
|
|
|
|
+ const y = (startY * scaleRatio / this.imageHeight) * 100;
|
|
|
|
|
+ const width = (item.width * scaleRatio / this.imageWidth) * 100;
|
|
|
|
|
+ const height = (item.height * scaleRatio / this.imageHeight) * 100;
|
|
|
|
|
+
|
|
|
|
|
+ // 从字典中获取虫子名字(尝试字符串和数字两种类型)
|
|
|
|
|
+ const pestName = text;
|
|
|
|
|
+ const color = this.getPestColor(text);
|
|
|
|
|
+
|
|
|
|
|
+ markers.push({
|
|
|
|
|
+ id: pestName, // 显示虫子名字
|
|
|
|
|
+ x,
|
|
|
|
|
+ y,
|
|
|
|
|
+ width,
|
|
|
|
|
+ height,
|
|
|
|
|
+ color
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
this.bugMarkers = markers;
|
|
this.bugMarkers = markers;
|
|
|
- } catch (error) {
|
|
|
|
|
- console.error('处理label参数失败:', error);
|
|
|
|
|
- this.bugMarkers = [];
|
|
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
handleBack() {
|
|
handleBack() {
|