日志输出,空指针导致程序出错-测试获取帧
This commit is contained in:
parent
6a63d53117
commit
dea8f6e113
|
|
@ -187,6 +187,10 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, device_id int) {
|
||||||
goto end
|
goto end
|
||||||
}
|
}
|
||||||
c = count
|
c = count
|
||||||
|
err4 := img.Close()
|
||||||
|
if err4 != nil {
|
||||||
|
log.Printf("close img err:%v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//每秒发送一次心跳检测
|
//每秒发送一次心跳检测
|
||||||
|
|
@ -201,10 +205,6 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, device_id int) {
|
||||||
}
|
}
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
t_count++
|
t_count++
|
||||||
err := img.Close()
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("close img err:%v", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,12 @@ func GetDeviceCurrentFrame(deviceId int) (gocv.Mat, int) {
|
||||||
//获取读写锁
|
//获取读写锁
|
||||||
mutex_, ok := DeviceRWMap.Load(deviceId)
|
mutex_, ok := DeviceRWMap.Load(deviceId)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
log.Printf("DeviceRWMap 读写锁不存在,device_id: %d \n", deviceId)
|
||||||
return gocv.NewMat(), -1
|
return gocv.NewMat(), -1
|
||||||
}
|
}
|
||||||
mutex, ok := mutex_.(*sync.RWMutex)
|
mutex, ok := mutex_.(*sync.RWMutex)
|
||||||
if !ok {
|
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
|
return gocv.NewMat(), -1
|
||||||
}
|
}
|
||||||
mutex.RLock()
|
mutex.RLock()
|
||||||
|
|
@ -66,7 +67,7 @@ func GetDeviceCurrentFrame(deviceId int) (gocv.Mat, int) {
|
||||||
}
|
}
|
||||||
frame, ok := frameIface.(gocv.Mat)
|
frame, ok := frameIface.(gocv.Mat)
|
||||||
if !ok {
|
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)
|
frame_countIface, ok := DeviceFrameCount.Load(deviceId)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue