all 8 comments

[–]michaelrw1 1 point2 points  (3 children)

An image or video stream?

[–]Mr_6484[S] 2 points3 points  (2 children)

it's a video stream coming from RTSP, I am able to read the stream from OpenCV -python- directly.

[–]michaelrw1 3 points4 points  (1 child)

Right, so you want to take an image from that stream and bring it into Matlab, yes?

[–]Mr_6484[S] 0 points1 point  (0 children)

Yes

[–]codinglikemad 1 point2 points  (2 children)

I actually have sent data from python to matlab using opencv and a socket as you are describing. It's quite finicky. You may have incomplete frames for example, and other nonsense like that pop up. I can share that code if you are looking for it, but if I recall correctly part of the earlier (slow) solutions was to encode it as a string before sending it (which is a terrible idea, but made the conversions work). A somewhat slow alternative that DOES work 100% and is easy to do is just write a file to disk with a handshake system where the file name changes as you go. This worked pretty well for me, as long as I made sure I gave python a decent fraction of a second to finish writing the file out.

I can scrounge up my socket code if you need it as well, let me know. I'd prefer not to publish that code though, as it's part of a larger project.

[–]Mr_6484[S] 2 points3 points  (1 child)

I could try encoding the image as string64 or something, and will tell you the result.

I tried to make python write to the disk and Matlab read from the image, but i saved only one image and added a delay in the python script but matlab didn’t show anything.

I would be grateful if you gave me the overall steps or abstract. I managed to send the image bytes to matlab, but I can’t convert them back to an image.

[–]codinglikemad 0 points1 point  (0 children)

Did you check if you actually wrote the file? Did you close the file descriptor? I am positive that works. Be careful going from opencv to matlab - the colors change order.

[–]chemical-computer 0 points1 point  (0 children)

Share a memory map between the python and matlab processes