From dea8f6e113357821eb511a1b6dafe0834ca36b03 Mon Sep 17 00:00:00 2001 From: lijun Date: Wed, 15 Jan 2025 23:54:43 +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-=E6=B5=8B=E8=AF=95=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=B8=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/tool.go | 8 ++++---- service/tool.go | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/handler/tool.go b/handler/tool.go index 4b52c6a..9fc83f5 100644 --- a/handler/tool.go +++ b/handler/tool.go @@ -187,6 +187,10 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, device_id int) { goto end } c = count + err4 := img.Close() + if err4 != nil { + log.Printf("close img err:%v", err) + } } } else { //每秒发送一次心跳检测 @@ -201,10 +205,6 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, device_id int) { } time.Sleep(100 * time.Millisecond) t_count++ - err := img.Close() - if err != nil { - log.Printf("close img err:%v", err) - } } end: diff --git a/service/tool.go b/service/tool.go index 38fcb85..c9971cf 100644 --- a/service/tool.go +++ b/service/tool.go @@ -50,11 +50,12 @@ func GetDeviceCurrentFrame(deviceId int) (gocv.Mat, int) { //获取读写锁 mutex_, ok := DeviceRWMap.Load(deviceId) if !ok { + log.Printf("DeviceRWMap 读写锁不存在,device_id: %d \n", deviceId) return gocv.NewMat(), -1 } mutex, ok := mutex_.(*sync.RWMutex) if !ok { - log.Printf("DeviceRWMap 存储的不是 *sync.RWMutex 类型,device_id: %d", deviceId) + log.Printf("DeviceRWMap 存储的不是 *sync.RWMutex 类型,device_id: %d \n", deviceId) return gocv.NewMat(), -1 } mutex.RLock() @@ -66,7 +67,7 @@ func GetDeviceCurrentFrame(deviceId int) (gocv.Mat, int) { } frame, ok := frameIface.(gocv.Mat) if !ok { - log.Printf("DeviceCurrentFrameMap 存储的不是 gocv.Mat 类型,device_id: %d", deviceId) + log.Printf("DeviceCurrentFrameMap 存储的不是 gocv.Mat 类型,device_id: %d \n", deviceId) } frame_countIface, ok := DeviceFrameCount.Load(deviceId) if !ok {