修复内存泄漏问题
This commit is contained in:
parent
84e60f21f2
commit
1bda7c786e
|
|
@ -58,13 +58,6 @@ 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 //当前帧
|
|
||||||
defer func(frame *gocv.Mat) {
|
|
||||||
err2 := frame.Close()
|
|
||||||
if err2 != nil {
|
|
||||||
fmt.Println("设备:%d 错误: 无法关闭帧", device.ID)
|
|
||||||
}
|
|
||||||
}(&frame)
|
|
||||||
for {
|
for {
|
||||||
if device.LogFrame > 0 && z%device.LogFrame == 0 {
|
if device.LogFrame > 0 && z%device.LogFrame == 0 {
|
||||||
fmt.Printf("设备:%d 当前帧: %d\n", device.ID, z)
|
fmt.Printf("设备:%d 当前帧: %d\n", device.ID, z)
|
||||||
|
|
@ -72,7 +65,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 {
|
||||||
fmt.Printf("设备 错误: 无法从视频流中读取帧:", device, "\n")
|
fmt.Printf("设备 错误: 无法从视频流中读取帧:", device, "\n")
|
||||||
|
|
@ -98,6 +91,10 @@ func getVideoFrame(device proto.DeviceInfo) {
|
||||||
fmt.Printf("设备:%s 错误: 无法设置当前帧\n", device)
|
fmt.Printf("设备:%s 错误: 无法设置当前帧\n", device)
|
||||||
}
|
}
|
||||||
z++
|
z++
|
||||||
|
err2 := frame.Close()
|
||||||
|
if err2 != nil {
|
||||||
|
fmt.Println("设备:%d 错误: 无法关闭帧", device.ID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue