Compare commits
No commits in common. "6a63d53117a40c10f17cf3f4c14c0a0a5e679a2f" and "75d8492618143078139d5f7a9dc2b4a8f2e18a6c" have entirely different histories.
6a63d53117
...
75d8492618
|
|
@ -40,41 +40,35 @@ func SetDeviceCurrentFrame(frame gocv.Mat, device_id int) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func GetDeviceCurrentFrame(deviceId int) (gocv.Mat, int) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
log.Printf("设备:%d 错误: %v\n", deviceId, err)
|
||||
}
|
||||
}()
|
||||
|
||||
func GetDeviceCurrentFrame(device_id int) (gocv.Mat, int) {
|
||||
//获取读写锁
|
||||
mutex_, ok := DeviceRWMap.Load(deviceId)
|
||||
mutex_, ok := DeviceRWMap.Load(device_id)
|
||||
if !ok {
|
||||
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", device_id)
|
||||
return gocv.NewMat(), -1
|
||||
}
|
||||
mutex.RLock()
|
||||
defer mutex.RUnlock()
|
||||
//获取当前帧
|
||||
frameIface, ok := DeviceCurrentFrameMap.Load(deviceId)
|
||||
frameIface, ok := DeviceCurrentFrameMap.Load(device_id)
|
||||
if !ok {
|
||||
return gocv.NewMat(), -1
|
||||
}
|
||||
frame, ok := frameIface.(gocv.Mat)
|
||||
if !ok {
|
||||
log.Printf("DeviceCurrentFrameMap 存储的不是 gocv.Mat 类型,device_id: %d", deviceId)
|
||||
log.Printf("DeviceCurrentFrameMap 存储的不是 gocv.Mat 类型,device_id: %d", device_id)
|
||||
}
|
||||
frame_countIface, ok := DeviceFrameCount.Load(deviceId)
|
||||
frame_countIface, ok := DeviceFrameCount.Load(device_id)
|
||||
if !ok {
|
||||
return gocv.NewMat(), -1
|
||||
}
|
||||
frame_count, ok := frame_countIface.(int)
|
||||
if !ok {
|
||||
log.Printf("DeviceFrameCount 存储的不是 int 类型,device_id: %d", deviceId)
|
||||
log.Printf("DeviceFrameCount 存储的不是 int 类型,device_id: %d", device_id)
|
||||
}
|
||||
return frame, frame_count
|
||||
}
|
||||
|
|
@ -159,11 +153,6 @@ func Get(url string) int {
|
|||
}
|
||||
|
||||
func GetVideoStream(id int) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
log.Printf("设备:%d 错误: %v\n", id, err)
|
||||
}
|
||||
}()
|
||||
is_get, ok := DeviceIsGettingFrame.Load(id)
|
||||
if !ok {
|
||||
log.Printf("device: %d not found", id)
|
||||
|
|
|
|||
Loading…
Reference in New Issue