From 84e60f21f2a65496abfff59fa4afdc7e63c1ea98 Mon Sep 17 00:00:00 2001 From: lijun Date: Tue, 14 Jan 2025 23:48:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=86=85=E5=AD=98=E6=B3=84?= =?UTF-8?q?=E6=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/tool.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/service/tool.go b/service/tool.go index f025a23..796b148 100644 --- a/service/tool.go +++ b/service/tool.go @@ -58,17 +58,24 @@ func getVideoFrame(device proto.DeviceInfo) { fontColor := color.RGBA{G: 255} lineType := 2 z := 0 + var frame gocv.Mat //当前帧 + defer func(frame *gocv.Mat) { + err2 := frame.Close() + if err2 != nil { + fmt.Println("设备:%d 错误: 无法关闭帧", device.ID) + } + }(&frame) for { if device.LogFrame > 0 && z%device.LogFrame == 0 { - fmt.Printf("设备:%s 当前帧: %d\n", device.ID, z) + fmt.Printf("设备:%d 当前帧: %d\n", device.ID, z) } if device.NextStop { break } - frame := gocv.NewMat() + frame = gocv.NewMat() ok := webcam.Read(&frame) if !ok { - fmt.Printf("设备:%s 错误: 无法从视频流中读取帧\n", device) + fmt.Printf("设备 错误: 无法从视频流中读取帧:", device, "\n") break } if frame.Empty() {