日志输出,空指针导致程序出错,重写释放逻辑
This commit is contained in:
parent
aa898671de
commit
535e61dfa6
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue