Hi drwr,
I’ve setup named shared memory in C++ and I have used mmap in Python to successfully transfer data from C++ to Python. Both applications are separate processes launched on their own.
In C++ the image is stored as the first element of array plane_addr and then to get it into shared memory I copy it like this:
CopyMemory((PVOID)pBuf, video_frame_image_info.plane_addr[0], BUF_SIZE);
In Python I access the data via:
m = mmap.mmap(0, 307221, "Global\\MyFileMappingObject", mmap.ACCESS_READ)
With m.read(1024) I can read the image as a data stream of chars, but obviously not wanted.
I’m not sure how to get the pointer as long int to use with set_ram_mipmap_pointer_from_int() from my shared memory as m prints as: “<mmap.mmap object at 0x00B42688>”
I’m able to read/save the image using PIL, but I’d like to be able to set this direct to the ramImage
import mmap
from PIL import Image
m = mmap.mmap(0, 307221, "Global\\MyFileMappingObject", mmap.ACCESS_READ)
size = 640, 480
im = Image.frombuffer("L", size, m, "raw", "L", 0, 1)
im.save("test.jpg", "JPEG")
Do you have any thoughts how I can make it so I can get the pointer to load it in via set_ram_mipmap_pointer_from_int() or secondly how to take my data stream and load that directly into setRamImage()?
Thanks!