How can you send picture taken from camera to Matlab?

Hi all!
I’ve created a Gadgeteer program that remotely controlled by Matlab GUI.
I’m using the Socket class and I have been wondering, can I send a picture taken from the serial camera module using Socket.Send ?

Thanks :slight_smile:

Yes. I have communicated to Matlab via TCP.

@ Mike - Well? How did you send it? using bytes array or something ?

Counter question:
How does Mathlab expect to get a picture?

Sending the raw pixel data over socket should not be a problem.
You could make a simple message frame like:
2 Byte: Message length
2 Byte: Message type (each number is a different message type, like 1=image, 2=???)
n Byte: Message specific data

This would allow to separate messages on the receiver side
The Bitmap message data could be as follows:
2 Byte: Width in pixel
2 Byte: height in pixel
1 byte: bits per pixel
2 Byte: bytes per row (stitch) (this is not necessary if there are no fill bytes at the end of a row)
n Bytes: Pixel data

Optionally you can add a pixel format info.
On the receiver side you can then reformat the pixel data if necessary.
Performance wise it’s better to do any pixel transformation on the PC side.

1 Like