Hey guys,
I’m trying to receive a mat object from cpp program, which I wrote for interacting with a camera. The principle is to share the memory between 2 programs which makes everything cleaner and more efficient. So far there is no problem having the image copied to the address sent by the python inside the cpp (imshow in cpp is precisely the original footage). Yet, once back to python, the matrix seems lost even those the pointer is pointing to the same location. With imwrite in python, a random pixelated picture is saved. And there is also the problem of converting numpy array to cv matrix.
The address is generated in python first with numpy.zeros((h,w,3),dtype=numpy.uint8)
and linkage between python and cpp is done with ctypes python library.
The 3 problems in this case is:
- Is it possible to convert numpy array to cv mat on the fly? (without saving it locally then read it)./Or generate an empty Mat object.
- Is there any better way to do this linkage?
- Might there be some problem with protecting the memory to make sure the image does not loss after copying from cpp program?
Thanks!