Get Image matrix from camera

Hi to all,
I need to acquire the Image from a camera and send that as matrix throug an UDP socket.
I’ve already built the UDP socket system, but I’m still wondering about how to get the Image from the camera and eventually convert it into a matrix.

The aim of the project is to do some object recognition into the image by a remote dedicated server.

Thanks to everyone in advance