空指针导致程序出错
This commit is contained in:
parent
3a65f8c468
commit
00a04ff287
|
|
@ -46,13 +46,30 @@ func GetDeviceCurrentFrame(device_id int) (gocv.Mat, int) {
|
||||||
if !ok {
|
if !ok {
|
||||||
return gocv.NewMat(), -1
|
return gocv.NewMat(), -1
|
||||||
}
|
}
|
||||||
mutex := mutex_.(*sync.RWMutex)
|
mutex, ok := mutex_.(*sync.RWMutex)
|
||||||
|
if !ok {
|
||||||
|
log.Fatalf("DeviceRWMap 存储的不是 *sync.RWMutex 类型,device_id: %d", device_id)
|
||||||
|
}
|
||||||
mutex.RLock()
|
mutex.RLock()
|
||||||
defer mutex.RUnlock()
|
defer mutex.RUnlock()
|
||||||
//获取当前帧
|
//获取当前帧
|
||||||
frame, ok := DeviceCurrentFrameMap.Load(device_id)
|
frameIface, ok := DeviceCurrentFrameMap.Load(device_id)
|
||||||
frame_count, ok := DeviceFrameCount.Load(device_id)
|
if !ok {
|
||||||
return frame.(gocv.Mat), frame_count.(int)
|
return gocv.NewMat(), -1
|
||||||
|
}
|
||||||
|
frame, ok := frameIface.(gocv.Mat)
|
||||||
|
if !ok {
|
||||||
|
log.Fatalf("DeviceCurrentFrameMap 存储的不是 gocv.Mat 类型,device_id: %d", device_id)
|
||||||
|
}
|
||||||
|
frame_countIface, ok := DeviceFrameCount.Load(device_id)
|
||||||
|
if !ok {
|
||||||
|
return gocv.NewMat(), -1
|
||||||
|
}
|
||||||
|
frame_count, ok := frame_countIface.(int)
|
||||||
|
if !ok {
|
||||||
|
log.Fatalf("DeviceFrameCount 存储的不是 int 类型,device_id: %d", device_id)
|
||||||
|
}
|
||||||
|
return frame, frame_count
|
||||||
}
|
}
|
||||||
|
|
||||||
func getVideoFrame(device proto.DeviceInfo) {
|
func getVideoFrame(device proto.DeviceInfo) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue