I have a library written in C++ with binding for C# for gathering information from an image.
Currently in C#.NET I’m using my library in this way:
unsafe
{
Bitmap imageData = new Bitmap("image.jpg");
BitmapData data = imageData.LockBits(
new Rectangle(new Point(0, 0), imageData.Size),
ImageLockMode.ReadWrite,
PixelFormat.Format24bppRgb);
// Get the address of first pixel in image
byte* pointer = (byte*)data.Scan0;
// My object singleton
Live live = w2d.GetLive();
// Call process and retrieve information
Content content = live.Process(pointer,
(uint)imageData.Width,
(uint)imageData.Height,
data.Stride,
false,
engine);
}
Now what I want is to integrate this with Unity. Using a Unity script I’ve created a WebCamTexture object like this:
WebCamDevice device = new WebCamDevice();
// texture is a class attribute in order to be able to access it from Update()
texture = new WebCamTexture(device.name, (int)width, (int)height, 30);
renderer.material.mainTexture = texture;
texture.Play();
This works great and I can see the webcam image in Unity when executing.
On the Update() method of this script I would like to retrieve the frame from memory (as I do with the Bitmap in .NET) and pass that info to my processing library. In essence what I need is a way to find the memory address of the frame and how it is encoded in memory (I hope it’s like the Bitmap (uncompressed) and RGB24).
Thanks in advance,