如何使用“ encoding / gob”在Go中可靠地编码和发送OpenCV Mat对象?

This is a heavily edited post.

I’m working on a client/server setup to practice golang where I use gocv to grab an image from my webcam and process it on a remote server using gocv again. Both processes are written in Go. What would be the best way to transmit the mat to the server process?

I have already tried to use gob like so:

func svr(){

    ln, _ := net.Listen("tcp", ":8090")
    conn, _ := ln.Accept()
    dec := gob.NewDecoder(conn)
    var p gocv.Mat

    dec.Decode(&p)

    gocv.IMWrite("copy.jpg", p)
    conn.Close()

}

func clnt(){

    time.Sleep(19999)

    conn, _ := net.Dial("tcp", "localhost:8090")
    encoder := gob.NewEncoder(conn)
    var chip gocv.Mat
    chip = gocv.IMRead("test.jpg", 0)
    encoder.Encode(chip)

}

func main(){

    go svr()

    clnt()
    time.Sleep(10000)
}

The program doesn't return any errors but doesn't create a file, either. I'm not sure what's wrong here. What am I doing wrong?

gob: type gocv.Mat has no exported fields
这个是错误信息 我也在找解决方法