/// <summary> /// Copy data from managed array to this Mat /// </summary> /// <typeparam name="T">The type of managed data array</typeparam> /// <param name="data">The managed array where data will be copied from</param> public void SetTo <T>(T[] data) { Debug.Assert(data.Length == Total.ToInt32() * ElementSize / Toolbox.SizeOf <T>(), String.Format("Invalid data length, expecting {0} but was {1}", Total.ToInt32() * ElementSize / Toolbox.SizeOf <T>(), data.Length)); GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned); MatInvoke.cveMatCopyDataFrom(this, handle.AddrOfPinnedObject()); handle.Free(); }