sunhongyao341504 1 год назад
Родитель
Сommit
6ce8c93e51

+ 22 - 23
src/views/cameras/preview/components/AlgorithmsSetting/AlgoParamsCard.vue

@@ -166,6 +166,28 @@
     (val) => {
       if (!val) return;
 
+      //先定form字段集合,如果有nextobj,添加子字段
+      const meta = metaObjList.value.find((item) => item.label === val);
+      const nexts = meta.nextObjs;
+      if (nexts) {
+        for (let i = 0; i < nexts.length; i++) {
+          const item = nexts[i];
+          paramItems.value.push({
+            label: item.label,
+            type: 'confidence',
+            prop: `${item.label}.confidence`,
+          });
+          algoParams.value[`${item.label}.confidence`] = Number((item.confidence * 100).toFixed(0));
+          paramItems.value.push({
+            label: item.label,
+            type: 'minArea',
+            prop: '',
+          });
+          algoParams.value[item.label + '.' + 'min_width'] = item['min_width'];
+          algoParams.value[item.label + '.' + 'min_height'] = item['min_height'];
+        }
+      }
+
       const index = selectedAlgoDetail.value.metaValues.findIndex((item) => item.label === val);
       if (selectedAlgoDetail.value.metaValues[index]['min_width']) {
         const countList = getCriticalCounts(selectedAlgoDetail.value.extra);
@@ -173,32 +195,9 @@
         algoParams.value.criticalCount =
           countList && countList.length > index ? countList[index] : 0;
       } else {
-        const meta = metaObjList.value.find((item) => item.label === val);
-        console.log(meta.confidence);
-
         algoParams.value.confidence = Number((meta.confidence * 100).toFixed(0));
         algoParams.value['min_width'] = meta['min_width'];
         algoParams.value['min_height'] = meta['min_height'];
-
-        const nexts = meta.nextObjs;
-        if (nexts) {
-          for (let i = 0; i < nexts.length; i++) {
-            const item = nexts[i];
-            paramItems.value.push({
-              label: item.label,
-              type: 'confidence',
-              prop: `${item.label}.confidence`,
-            });
-            algoParams.value[`${item.label}.confidence`] = Number((item.confidence * 100).toFixed(0));
-            paramItems.value.push({
-              label: item.label,
-              type: 'minArea',
-              prop: '',
-            });
-            algoParams.value[item.label + '.' + 'min_width'] = item['min_width'];
-            algoParams.value[item.label + '.' + 'min_height'] = item['min_height'];
-          }
-        }
       }
     },
     {

+ 2 - 1
src/views/cameras/preview/components/AlgorithmsSetting/AlgorithmsSetting.vue

@@ -51,6 +51,7 @@
     getMetaValues,
     getExtraCommonInfo,
     getDetectionTime,
+    getInferParam,
   } from './utils';
   import { ALGO_ENABLED_STATUS } from '@/api/camera/camera-preview';
   import { watchEffect } from 'vue';
@@ -134,7 +135,7 @@
   const handleSubmit = (param) => {
     console.log('submitParam', param);
     const cameraId = cameraDetailStore.cameraId;
-    const inferParams = {} as any;
+    const inferParams = getInferParam(selectedAlgoDetail.value.extra);
     inferParams.metaObjs = param.metaObjs;
     inferParams.regionJudge = param.regionJudge;
     inferParams.criticalCounts = param.criticalCounts;

+ 8 - 0
src/views/cameras/preview/components/AlgorithmsSetting/utils.ts

@@ -63,6 +63,14 @@ export const getDetectionTimeJSON = (time?: string): TimeRangeItem[] | null => {
   return timeStrArr;
 };
 
+export const getInferParam = (extra: string | undefined | null) => {
+  if (!extra) return {};
+  const extraObj = JSON.parse(extra);
+  const params = extraObj?.inferParams;
+  if (!params || (params && params.length == 0)) return {};
+  return params[0];
+};
+
 export const getMetaValues = (extra: string | undefined | null) => {
   if (!extra) return [];
   const extraObj = JSON.parse(extra);