内存泄漏问题
This commit is contained in:
parent
8fbc54c2af
commit
4c1a397775
|
|
@ -53,7 +53,7 @@ func SetDeviceCurrentFrame(frame gocv.Mat, device_id int) error {
|
|||
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)
|
||||
if !ok {
|
||||
|
|
@ -65,9 +65,9 @@ func SetDeviceCurrentFrameV2(frame gocv.Mat, device_id int) error {
|
|||
//设置当前帧
|
||||
switch device_id {
|
||||
case 1:
|
||||
Device1CurrentFrame = frame
|
||||
Device1CurrentFrame = *frame
|
||||
case 50:
|
||||
Device50CurrentFrame = frame
|
||||
Device50CurrentFrame = *frame
|
||||
}
|
||||
frame_count, ok := DeviceFrameCount.Load(device_id)
|
||||
if !ok {
|
||||
|
|
@ -224,6 +224,7 @@ func getVideoFrame(device proto.DeviceInfo) {
|
|||
fontColor := color.RGBA{G: 255}
|
||||
lineType := 2
|
||||
z := 0
|
||||
var frame gocv.Mat
|
||||
for {
|
||||
if device.LogFrame > 0 && z%device.LogFrame == 0 {
|
||||
log.Printf("设备:%d 当前帧: %d\n", device.ID, z)
|
||||
|
|
@ -231,7 +232,7 @@ func getVideoFrame(device proto.DeviceInfo) {
|
|||
if device.NextStop {
|
||||
break
|
||||
}
|
||||
frame := gocv.NewMat()
|
||||
frame = gocv.NewMat()
|
||||
ok := webcam.Read(&frame)
|
||||
if !ok {
|
||||
log.Printf("设备:%v 错误: 无法从视频流中读取帧\n", device)
|
||||
|
|
@ -252,16 +253,16 @@ func getVideoFrame(device proto.DeviceInfo) {
|
|||
currentTime := time.Now().Format("2006-01-02 15:04:05")
|
||||
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 {
|
||||
log.Printf("设备:%d 错误: 无法设置当前帧,err:%s \n", device.ID, err3.Error())
|
||||
}
|
||||
z++
|
||||
//关闭帧
|
||||
err4 := frame.Close()
|
||||
if err4 != nil {
|
||||
log.Printf("设备:%d 错误: 无法关闭帧,err:%s \n", device.ID, err4.Error())
|
||||
}
|
||||
}
|
||||
//关闭帧
|
||||
err4 := frame.Close()
|
||||
if err4 != nil {
|
||||
log.Printf("设备:%d 错误: 无法关闭帧,err:%s \n", device.ID, err4.Error())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue