It's not exactly what you're asking for, but you can use an in-memory database such as Redis as a conduit for exchanging OpenCV images between your programs. Though less direct than raw memory mapping, and while it introduces an additional application layer, the data is still manipulated strictly in RAM. In my experience, this tactic is fast enough to be near-realtime on a modern machine.
I've used such architecture for https://github.com/vmlaker/hello-websocket, albeit it uses Python at both ends.
Here's a minimalistic example of a similar protocol implementing the source in C++, and Python for the target application. The following C++ program reads an image from a file on disk using OpenCV, and stores the image in Redis under the key image:
#include <opencv4/opencv2/opencv.hpp>
#include <cpp_redis/cpp_redis>
int main(int argc, char** argv)
{
cv::Mat image = cv::imread("input.jpg");
std::vector<uchar> buf;
cv::imencode(".jpg", image, buf);
cpp_redis::client client;
client.connect();
client.set("image", {buf.begin(), buf.end()});
client.sync_commit();
}
Then in Python you grab the image from the database and do what you will:
import cv2
import numpy as np
import redis
store = redis.Redis()
image = store.get('image')
array = np.frombuffer(image, np.uint8)
decoded = cv2.imdecode(array, flags=1)
cv2.imshow('hello', decoded)
cv2.waitKey()
Going the other way is pretty straightforward. You can get cpp_redis here: https://github.com/cpp-redis/cpp_redis.