日志输出,空指针导致程序出错-测试获取帧
This commit is contained in:
parent
6a63d53117
commit
dea8f6e113
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue