|
@@ -12,7 +12,7 @@
|
|
|
<view class=" flex-1 text">
|
|
<view class=" flex-1 text">
|
|
|
介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字
|
|
介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字
|
|
|
</view>
|
|
</view>
|
|
|
- <button class="btn" @click="uploadFile()">我要识别</button>
|
|
|
|
|
|
|
+ <button class="btn" @click="startDiscern('insect')">我要识别</button>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="media-item">
|
|
<view class="media-item">
|
|
@@ -20,11 +20,11 @@
|
|
|
<image src="@/static/demo/demo1.png" mode="aspectFill"></image>
|
|
<image src="@/static/demo/demo1.png" mode="aspectFill"></image>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="media-bd">
|
|
<view class="media-bd">
|
|
|
- <view class="title">虫害识别技术</view>
|
|
|
|
|
|
|
+ <view class="title">病害识别技术</view>
|
|
|
<view class=" flex-1 text">
|
|
<view class=" flex-1 text">
|
|
|
介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字
|
|
介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字介绍文字
|
|
|
</view>
|
|
</view>
|
|
|
- <button class="btn" @click="uploadFile()">我要识别</button>
|
|
|
|
|
|
|
+ <button class="btn" @click="startDiscern('plant')">我要识别</button>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -36,6 +36,10 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
|
+ import {
|
|
|
|
|
+ handlePlantDiscern,
|
|
|
|
|
+ handleInsectDiscern
|
|
|
|
|
+ } from '@/api/pest.js'
|
|
|
export default {
|
|
export default {
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
@@ -43,12 +47,31 @@
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
- // 上传图片
|
|
|
|
|
- async uploadFile(e) {
|
|
|
|
|
- let res = await this.uploadImageSync();
|
|
|
|
|
- if (res.success) {
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 开始识别
|
|
|
|
|
+ * @param {String} type 识别类型 insect:虫害,plant:病害
|
|
|
|
|
+ */
|
|
|
|
|
+ async startDiscern(type) {
|
|
|
|
|
+ let file = await this.uploadImageSync();
|
|
|
|
|
+ if (!file) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ let result;// 识别结果
|
|
|
|
|
+ // 识别虫害
|
|
|
|
|
+ if(type=='insect'){
|
|
|
|
|
+ result = await handleInsectDiscern({
|
|
|
|
|
+ img_file: file
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
+ // 识别病害
|
|
|
|
|
+ if(type=='plant'){
|
|
|
|
|
+ result = await handlePlantDiscern({
|
|
|
|
|
+ img_file: file
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
uploadImageSync() {
|
|
uploadImageSync() {
|
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
@@ -57,8 +80,10 @@
|
|
|
sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|
|
success(res) {
|
|
success(res) {
|
|
|
- const tempFilePaths = res.tempFilePaths;
|
|
|
|
|
-
|
|
|
|
|
|
|
+ resolve(res.tempFiles[0]);
|
|
|
|
|
+ },
|
|
|
|
|
+ fail(e) {
|
|
|
|
|
+ resolve(null);
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|