I try to use a .NET Assembly in a python application using Python.NET. The C# code captures an image, that i want to use with python. Let's say I have the following C# method:
public static byte[] Return_Image_As_Byte_Array()
{
Image image = Image.FromFile("C:\path\to\an\image");
ImageConverter imageConverter = new ImageConverter();
byte[] ByteArray = (byte[])imageConverter.ConvertTo(image, typeof(byte[]));
return ByteArray;
}
When I use Python.Net in python i do the following:
import clr
clr.AddReference('MyAssembly')
from MyAssembly import MyClass
print(MyClass.Return_Image_As_Byte())
This gives me the output:
<System.Byte[] at 0xb7ba20c080>
Is there a way to turn this image from C# into a native python type like numpy array?
list(System.Byte[])