From 535e61dfa687472a9af095f619d99e8b12cd2d7d Mon Sep 17 00:00:00 2001 From: lijun Date: Thu, 16 Jan 2025 13:58:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=BE=93=E5=87=BA=EF=BC=8C?= =?UTF-8?q?=E7=A9=BA=E6=8C=87=E9=92=88=E5=AF=BC=E8=87=B4=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E5=87=BA=E9=94=99,=E9=87=8D=E5=86=99=E9=87=8A=E6=94=BE?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/tool.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/service/tool.go b/service/tool.go index c9971cf..e8fbfcc 100644 --- a/service/tool.go +++ b/service/tool.go @@ -28,6 +28,17 @@ func SetDeviceCurrentFrame(frame gocv.Mat, device_id int) error { mutex := mutex_.(*sync.RWMutex) mutex.Lock() defer mutex.Unlock() + //获取前一帧,将前一帧释放 + framePrev, ok := DeviceCurrentFrameMap.Load(device_id) + if ok { + frame_, ok2 := framePrev.(gocv.Mat) + if ok2 { + err2 := frame_.Close() + if err2 != nil { + log.Printf("设备:%d, 错误: 无法关闭帧\n", device_id) + } + } + } //设置当前帧 DeviceCurrentFrameMap.Store(device_id, frame) frame_count, ok := DeviceFrameCount.Load(device_id) @@ -138,10 +149,6 @@ func getVideoFrame(device proto.DeviceInfo) { log.Printf("设备:%d 错误: 无法设置当前帧,err:%s \n", device.ID, err3.Error()) } z++ - err2 := frame.Close() - if err2 != nil { - log.Printf("设备:%d,计数z=%d, 错误: 无法关闭帧\n", device.ID, z) - } } }