修复ROI截图功能:改用ZLM同步getSnap直接返回图片

- 重写snap端点:直接调用ZLM的getSnap同步API,传入RTSP源地址,
  流式返回图片字节流,不再依赖异步文件存储
- 前端改为传srcUrl参数给snap接口,不需要先拉流即可截图
- 修复之前async=1导致ZLM返回JSON而非图片的问题

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-04 09:21:10 +08:00
parent d7bf969694
commit 5b39a3b947
3 changed files with 53 additions and 42 deletions

View File

@@ -25,6 +25,6 @@ export function stopCamera(id) {
})
}
export function getSnapUrl(cameraId) {
return `/api/ai/roi/snap?cameraId=${encodeURIComponent(cameraId)}`
export function getSnapUrl(srcUrl) {
return `/api/ai/roi/snap?url=${encodeURIComponent(srcUrl)}`
}

View File

@@ -113,10 +113,8 @@ export default {
mounted() {
this.cameraId = decodeURIComponent(this.$route.params.cameraId)
this.srcUrl = this.$route.query.srcUrl || ''
const app = this.$route.query.app || ''
const stream = this.$route.query.stream || ''
if (app && stream) {
this.snapUrl = `/api/ai/roi/snap?app=${encodeURIComponent(app)}&stream=${encodeURIComponent(stream)}`
if (this.srcUrl) {
this.snapUrl = `/api/ai/roi/snap?url=${encodeURIComponent(this.srcUrl)}`
}
this.loadRois()
},
@@ -147,10 +145,8 @@ export default {
this.drawMode = mode
},
refreshSnap() {
const app = this.$route.query.app || ''
const stream = this.$route.query.stream || ''
if (app && stream) {
this.snapUrl = `/api/ai/roi/snap?app=${encodeURIComponent(app)}&stream=${encodeURIComponent(stream)}&t=${Date.now()}`
if (this.srcUrl) {
this.snapUrl = `/api/ai/roi/snap?url=${encodeURIComponent(this.srcUrl)}&t=${Date.now()}`
}
},
onRoiDrawn(data) {