parent
08315bf54b
commit
ed64a9c5a3
|
|
@ -19,10 +19,11 @@ const ruleFormRef = ref<FormInstance>()
|
|||
const ruleForm = reactive<RuleForm>({
|
||||
vidPath: '',
|
||||
function: [
|
||||
// 'runSam3',
|
||||
// 'runHazardCheck',
|
||||
// 'runGenerateReport',
|
||||
// 'runAudioRecognition',
|
||||
'runAudioRecognition',
|
||||
'runSam3',
|
||||
'runHazardCheck',
|
||||
'runGenerateReport',
|
||||
'convertToMp4',
|
||||
],
|
||||
})
|
||||
|
||||
|
|
@ -71,30 +72,47 @@ async function runCheck(formEl: FormInstance | undefined) {
|
|||
}
|
||||
})
|
||||
if (valid) {
|
||||
isRunningCheck.value = true
|
||||
startTimer()
|
||||
if (ruleForm.function.includes('runAudioRecognition')) {
|
||||
await runApiAudio('recognize', 'GET', {
|
||||
path: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)],
|
||||
runProcess()
|
||||
}
|
||||
}
|
||||
|
||||
async function runProcess() {
|
||||
isRunningCheck.value = true
|
||||
startTimer()
|
||||
const tasks: Promise<any>[] = []
|
||||
|
||||
if (ruleForm.function.includes('runAudioRecognition')) {
|
||||
tasks.push(runApiAudio('recognize', 'GET', {
|
||||
path: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)],
|
||||
}))
|
||||
}
|
||||
|
||||
if (ruleForm.function.includes('convertToMp4')) {
|
||||
tasks.push(runApiAudio('convert', 'GET', {
|
||||
path: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)],
|
||||
}))
|
||||
}
|
||||
|
||||
tasks.push(runApi('/run', {
|
||||
vid_file: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)],
|
||||
run_sam3: ruleForm.function.includes('runSam3'),
|
||||
run_inspection: ruleForm.function.includes('runHazardCheck'),
|
||||
gen_report: ruleForm.function.includes('runGenerateReport'),
|
||||
}))
|
||||
|
||||
await Promise.all(tasks).then((results) => {
|
||||
isRunningCheck.value = false
|
||||
// 判定是否成功运行
|
||||
const lastRes = results[results.length - 1]
|
||||
if (lastRes !== 'error') {
|
||||
router.push({
|
||||
path: '/nav/hazardCheckResult',
|
||||
query: { vid_file: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)] },
|
||||
})
|
||||
}
|
||||
await runApi('/run', {
|
||||
vid_file: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)],
|
||||
run_sam3: ruleForm.function.includes('runSam3'),
|
||||
run_inspection: ruleForm.function.includes('runHazardCheck'),
|
||||
gen_report: ruleForm.function.includes('runGenerateReport'),
|
||||
}).then((res) => {
|
||||
isRunningCheck.value = false
|
||||
stopTimer()
|
||||
// 判定是否成功运行
|
||||
if (res !== 'error') {
|
||||
router.push({
|
||||
path: '/nav/hazardCheckResult',
|
||||
query: { vid_file: vidPaths.value[vidPaths.value.indexOf(ruleForm.vidPath)] },
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
stopTimer()
|
||||
}
|
||||
|
||||
async function reloadFiles() {
|
||||
|
|
@ -153,6 +171,12 @@ onMounted(() => {
|
|||
</el-form-item>
|
||||
<el-form-item label="功能选择" prop="function">
|
||||
<el-checkbox-group v-model="ruleForm.function" class="checkbox-group">
|
||||
<el-checkbox value="convertToMp4" name="function">
|
||||
视频转码
|
||||
</el-checkbox>
|
||||
<el-checkbox value="runAudioRecognition" name="function">
|
||||
音频识别
|
||||
</el-checkbox>
|
||||
<el-checkbox value="runSam3" name="function">
|
||||
物体识别
|
||||
</el-checkbox>
|
||||
|
|
@ -162,9 +186,6 @@ onMounted(() => {
|
|||
<el-checkbox value="runGenerateReport" name="function">
|
||||
生成报告
|
||||
</el-checkbox>
|
||||
<el-checkbox value="runAudioRecognition" name="function">
|
||||
音频识别
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="!isRunningCheck">
|
||||
|
|
|
|||
|
|
@ -327,29 +327,17 @@ onMounted(async () => {
|
|||
const vidFile = router.currentRoute.value.query.vid_file as string
|
||||
if (vidFile) {
|
||||
// 调用接口获取完整视频路径
|
||||
runApi('/get_full_vid_path', {
|
||||
vid_file: vidFile,
|
||||
runApiAudio('/getVidUrl', 'GET', {
|
||||
path: vidFile,
|
||||
}).then((res) => {
|
||||
if (res === 'error') {
|
||||
console.error('获取视频路径失败')
|
||||
return
|
||||
}
|
||||
// console.log('接口调用成功,返回数据:', res)
|
||||
vidUrl.value = (res as string[])[0]
|
||||
|
||||
// 截取文件名
|
||||
const fileName = vidUrl.value.split('\\').pop() || ''
|
||||
// 去掉文件扩展名
|
||||
const fileNameNoExt = fileName.split('.')[0]
|
||||
// 文件扩展名
|
||||
// const fileExt = fileName.split('.')[1]
|
||||
// 临时拼接视频路径
|
||||
vidUrl.value = `http://localhost:8086/${fileNameNoExt}_h264.mp4`
|
||||
vidUrl.value = res.url
|
||||
})
|
||||
|
||||
// 临时拼接视频路径
|
||||
// 去掉文件扩展名
|
||||
// const fileNameNoExt = vidFile.split('.')[0]
|
||||
// // 文件扩展名
|
||||
// const fileExt = vidFile.split('.')[1]
|
||||
// vidUrl.value = `http://localhost:8086/${fileNameNoExt}_h264.${fileExt}`
|
||||
|
||||
// 调用接口获取隐患数据
|
||||
runApi('/run', {
|
||||
vid_file: vidFile,
|
||||
|
|
|
|||
Loading…
Reference in New Issue