空指针导致程序出错
This commit is contained in:
parent
1c581654f4
commit
3a65f8c468
|
|
@ -169,7 +169,13 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, device_id int) {
|
|||
if img.Empty() {
|
||||
fmt.Println("device:%d img is empty!", device_id)
|
||||
} else {
|
||||
buf, _ := gocv.IMEncode(".jpg", img)
|
||||
//gocv.Matrix转为jpeg
|
||||
buf, err := gocv.IMEncode(".jpg", img)
|
||||
if err != nil {
|
||||
fmt.Println("img encode err:", err)
|
||||
worker.SetRedisSetRemove(online_conn_key, con_id)
|
||||
goto end
|
||||
}
|
||||
buf1 := buf.GetBytes()
|
||||
|
||||
err2 := ws.WriteMessage(websocket.BinaryMessage, buf1)
|
||||
|
|
@ -193,6 +199,10 @@ func subscribeAndHandleMessagesV3(ws *websocket.Conn, device_id int) {
|
|||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
t_count++
|
||||
err := img.Close()
|
||||
if err != nil {
|
||||
fmt.Println("close img err:", err)
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
|
|
|
|||
Loading…
Reference in New Issue