内存泄漏问题
This commit is contained in:
parent
8fbc54c2af
commit
4c1a397775
|
|
@ -53,7 +53,7 @@ func SetDeviceCurrentFrame(frame gocv.Mat, device_id int) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetDeviceCurrentFrameV2(frame gocv.Mat, device_id int) error {
|
func SetDeviceCurrentFrameV2(frame *gocv.Mat, device_id int) error {
|
||||||
//获取读写锁
|
//获取读写锁
|
||||||
mutex_, ok := DeviceRWMap.Load(device_id)
|
mutex_, ok := DeviceRWMap.Load(device_id)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
@ -65,9 +65,9 @@ func SetDeviceCurrentFrameV2(frame gocv.Mat, device_id int) error {
|
||||||
//设置当前帧
|
//设置当前帧
|
||||||
switch device_id {
|
switch device_id {
|
||||||
case 1:
|
case 1:
|
||||||
Device1CurrentFrame = frame
|
Device1CurrentFrame = *frame
|
||||||
case 50:
|
case 50:
|
||||||
Device50CurrentFrame = frame
|
Device50CurrentFrame = *frame
|
||||||
}
|
}
|
||||||
frame_count, ok := DeviceFrameCount.Load(device_id)
|
frame_count, ok := DeviceFrameCount.Load(device_id)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
@ -224,6 +224,7 @@ func getVideoFrame(device proto.DeviceInfo) {
|
||||||
fontColor := color.RGBA{G: 255}
|
fontColor := color.RGBA{G: 255}
|
||||||
lineType := 2
|
lineType := 2
|
||||||
z := 0
|
z := 0
|
||||||
|
var frame gocv.Mat
|
||||||
for {
|
for {
|
||||||
if device.LogFrame > 0 && z%device.LogFrame == 0 {
|
if device.LogFrame > 0 && z%device.LogFrame == 0 {
|
||||||
log.Printf("设备:%d 当前帧: %d\n", device.ID, z)
|
log.Printf("设备:%d 当前帧: %d\n", device.ID, z)
|
||||||
|
|
@ -231,7 +232,7 @@ func getVideoFrame(device proto.DeviceInfo) {
|
||||||
if device.NextStop {
|
if device.NextStop {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
frame := gocv.NewMat()
|
frame = gocv.NewMat()
|
||||||
ok := webcam.Read(&frame)
|
ok := webcam.Read(&frame)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Printf("设备:%v 错误: 无法从视频流中读取帧\n", device)
|
log.Printf("设备:%v 错误: 无法从视频流中读取帧\n", device)
|
||||||
|
|
@ -252,17 +253,17 @@ func getVideoFrame(device proto.DeviceInfo) {
|
||||||
currentTime := time.Now().Format("2006-01-02 15:04:05")
|
currentTime := time.Now().Format("2006-01-02 15:04:05")
|
||||||
gocv.PutText(&frame, currentTime, image.Point{10, 20}, font, fontScale, fontColor, lineType)
|
gocv.PutText(&frame, currentTime, image.Point{10, 20}, font, fontScale, fontColor, lineType)
|
||||||
//需要将帧付给全局变量
|
//需要将帧付给全局变量
|
||||||
err3 := SetDeviceCurrentFrameV2(frame, device.ID)
|
err3 := SetDeviceCurrentFrameV2(&frame, device.ID)
|
||||||
if err3 != nil {
|
if err3 != nil {
|
||||||
log.Printf("设备:%d 错误: 无法设置当前帧,err:%s \n", device.ID, err3.Error())
|
log.Printf("设备:%d 错误: 无法设置当前帧,err:%s \n", device.ID, err3.Error())
|
||||||
}
|
}
|
||||||
z++
|
z++
|
||||||
|
}
|
||||||
//关闭帧
|
//关闭帧
|
||||||
err4 := frame.Close()
|
err4 := frame.Close()
|
||||||
if err4 != nil {
|
if err4 != nil {
|
||||||
log.Printf("设备:%d 错误: 无法关闭帧,err:%s \n", device.ID, err4.Error())
|
log.Printf("设备:%d 错误: 无法关闭帧,err:%s \n", device.ID, err4.Error())
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发起get请求,返回响应状态码
|
// 发起get请求,返回响应状态码
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue