Browse Source

feat: toggle

main
少轻狂 2 years ago
parent
commit
820fdc2abe
No known key found for this signature in database GPG Key ID: 80E176093D33A9AB
6 changed files with 34 additions and 31 deletions
  1. +5
    -2
      app/api/api.py
  2. +9
    -9
      app/api/config.json
  3. +0
    -1
      app/main.py
  4. +8
    -2
      src/components/Setting.vue
  5. +12
    -16
      src/components/daisy/DSelect.vue
  6. +0
    -1
      src/pages/AdvancedSettings.vue

+ 5
- 2
app/api/api.py View File

@@ -6,6 +6,7 @@ import json
import datetime import datetime
import os import os
import sys import sys
from utils.utils import send_notifycation


def getFile(ruleFile): def getFile(ruleFile):
if getattr(sys, 'frozen', False): if getattr(sys, 'frozen', False):
@@ -84,8 +85,8 @@ class API:
self.net = PicoDet( self.net = PicoDet(
get_settings_status_name(self.args,"ModelSetting","模型版本设置"), get_settings_status_name(self.args,"ModelSetting","模型版本设置"),
self.args['classfile'], self.args['classfile'],
prob_threshold=get_setting_status(self.args,"ModelSetting",'confThreshold'),
iou_threshold=get_setting_status(self.args,"ModelSetting",'nmsThreshold'))
prob_threshold=float(get_setting_status(self.args,"ModelSetting",'confThreshold')),
iou_threshold=float(get_setting_status(self.args,"ModelSetting",'nmsThreshold')))


# net.detect_folder(args['img_fold'], args['result_fold']) # net.detect_folder(args['img_fold'], args['result_fold'])


@@ -93,6 +94,8 @@ class API:
self.cap = cv2.VideoCapture(0) # 开启摄像头 self.cap = cv2.VideoCapture(0) # 开启摄像头
# cv2.namedWindow('Video Cam', cv2.WINDOW_NORMAL) # cv2.namedWindow('Video Cam', cv2.WINDOW_NORMAL)
if(self.args['toggle'] and self.args['tip']):
send_notifycation("功能已开启")






+ 9
- 9
app/api/config.json View File

@@ -2,12 +2,12 @@
"classfile": "coco_label.txt", "classfile": "coco_label.txt",
"img_fold": "./imgs", "img_fold": "./imgs",
"result_fold": "results", "result_fold": "results",
"toggle": false,
"tip": false,
"toggle": true,
"tip": true,
"control": [ "control": [
{ {
"name": "嘴控", "name": "嘴控",
"status": false
"status": true
}, },
{ {
"name": "眼控", "name": "眼控",
@@ -15,7 +15,7 @@
}, },
{ {
"name": "嘴/眼控", "name": "嘴/眼控",
"status": true
"status": false
} }
], ],
"ControlSetting": [ "ControlSetting": [
@@ -24,7 +24,7 @@
"status": [ "status": [
{ {
"name": "开/关/开", "name": "开/关/开",
"status": true
"status": false
}, },
{ {
"name": "关/开/关", "name": "关/开/关",
@@ -32,7 +32,7 @@
}, },
{ {
"name": "闭上持续2S", "name": "闭上持续2S",
"status": false
"status": true
}, },
{ {
"name": "张开持续2S", "name": "张开持续2S",
@@ -69,15 +69,15 @@
}, },
{ {
"name": "置信度", "name": "置信度",
"status": 0.5
"status": "0.5"
}, },
{ {
"name": "confThreshold", "name": "confThreshold",
"status": 0.5
"status": "0.5"
}, },
{ {
"name": "nmsThreshold", "name": "nmsThreshold",
"status": 0.6
"status": "0.6"
}, },
{ {
"name": "图片载入方式", "name": "图片载入方式",


+ 0
- 1
app/main.py View File

@@ -42,6 +42,5 @@ if __name__ == "__main__":
default='False', default='False',
help="开发模式") help="开发模式")
args = parser.parse_args() args = parser.parse_args()
send_notifycation('EMC程序已启动')
WebViewApp(args.port,args.dev=='True') WebViewApp(args.port,args.dev=='True')

+ 8
- 2
src/components/Setting.vue View File

@@ -17,6 +17,10 @@ watch(() => props.settingData, () => {
deep: true, deep: true,
}) })


const handleChange = () => {

}

const { t } = useI18n() const { t } = useI18n()
</script> </script>


@@ -38,11 +42,13 @@ const { t } = useI18n()
</select> --> </select> -->
<d-select v-model:options="item.status" class="select select-sm max-w-xs" /> <d-select v-model:options="item.status" class="select select-sm max-w-xs" />
</div> </div>
<div v-else-if="typeof (item.status) == 'number'" class="flex justify-between mx-8 items-center">
<div v-else class="flex justify-between mx-8 items-center">
<div class="setting-item-title self-center flex justify-center items-center " :data-tip="item.description" :class="!!item.description ? 'tooltip tooltip-primary tooltip-right' : ''"> <div class="setting-item-title self-center flex justify-center items-center " :data-tip="item.description" :class="!!item.description ? 'tooltip tooltip-primary tooltip-right' : ''">
{{ t(item.name) }}<div v-if="!!item.description" i-carbon-information class="ml-1 " /> {{ t(item.name) }}<div v-if="!!item.description" i-carbon-information class="ml-1 " />
</div> </div>
<input type="range" min="0" max="1" :value="item.status" class="range range-xs" step="0.05">
<div class="tooltip tooltip-primary tooltip-left">
<input v-model="item.status" type="range" min="0" max="1" class="range range-xs" step="0.05">
</div>
</div> </div>
</div> </div>
</div> </div>


+ 12
- 16
src/components/daisy/DSelect.vue View File

@@ -6,23 +6,19 @@ const props = defineProps({
}, },
}) })
const emit = defineEmits(['update:options']) const emit = defineEmits(['update:options'])
let selectedOption = $ref(!!props.options && props.options.find(option => option.status === true)?.name)

const handleChange = () => {
props.options.forEach((option) => {
if (option.name === selectedOption)
option.status = true
else
option.status = false
const selectedOption = computed(
{
get() {
const opt = !!props.options && props.options.find(option => option.status === true)
return opt ? opt.name : ''
},
set(newVal) {
props.options.forEach((option) => {
option.status = option.name === newVal
})
emit('update:options', props.options)
},
}) })
emit('update:options', props.options)
}
watch(() => props.options, () => { // 无延时props不起作用
if (selectedOption === false)
selectedOption = props.options.find(option => option.status === true).name
}, {
deep: true,
})
</script> </script>


<template> <template>


+ 0
- 1
src/pages/AdvancedSettings.vue View File

@@ -8,7 +8,6 @@ const settings = reactive({
}) })
const getAdvanceSetting = async () => { const getAdvanceSetting = async () => {
[settings.ControlSetting, settings.ModelSetting, settings.otherSetting] = await window.pywebview.api.getAdvanceSetting() [settings.ControlSetting, settings.ModelSetting, settings.otherSetting] = await window.pywebview.api.getAdvanceSetting()
console.log(settings)
} }


watch(() => settings, async () => { watch(() => settings, async () => {


Loading…
Cancel
Save