Hi @yishu_corpex
I'd suggest cross-sharing memory between Python and C# (shared memory block):
Python side:
import mmap
import numpy as np
import os
# Example buffer size for a 1920x1080 image with 3 channels (RGB)
buffer_size = 1920 * 1080 * 3
# Create a new memory-mapped file
with mmap.mmap(-1, buffer_size, "Local\\MySharedMemory") as mm:
frame = np.random.randint(0, 255, (1080, 1920, 3), dtype=np.uint8) # example frame
mm.write(frame.tobytes()) # Write the numpy array to shared memory
C#
using System;
using System.IO.MemoryMappedFiles;
using System.Runtime.InteropServices;
public class Program
{
public static void Main()
{
int width = 1920;
int height = 1080;
int channels = 3;
using (var mmf = MemoryMappedFile.OpenExisting("MySharedMemory"))
{
using (var accessor = mmf.CreateViewAccessor())
{
byte[] buffer = new byte[width * height * channels];
accessor.ReadArray(0, buffer, 0, buffer.Length);
// Optionally convert to a managed array, handle as needed
}
}
}
}
Thoughts?