Skip to content

Instantly share code, notes, and snippets.

@olokobayusuf
Last active September 29, 2017 12:37
Show Gist options
  • Save olokobayusuf/2906b6c4070e3a7975559998919ee54e to your computer and use it in GitHub Desktop.
Save olokobayusuf/2906b6c4070e3a7975559998919ee54e to your computer and use it in GitHub Desktop.
// Barcode detection built upon ZXing.NET 0.14.0.0
#define ZXING_API
#if ZXING_API
using ZXing;
#endif
private static BarcodeReader reader {...}
public static void DetectBarcode (Color32[] frame, int width, int height, MetadataCallback<IMetadata> callback) {
if (frame == null || callback == null) return;
#if ZXING_API
reader.DecodeMultiple(frame, width, height).ForEach(result => callback(NatCamBarcode(result)));
#endif
}
@tgouala
Copy link

tgouala commented Jul 17, 2017

Hi Yusuf,

Your example is easy to use with NatCamLegacy.
How to get Color32[] from NatCam.PreviewBuffer on Android or IOS ?

@olokobayusuf
Copy link
Author

Hi there. I just saw this comment. In NatCam 1.5, you can use the System.Runtime.InteropServices.Marshal API's to copy native data into a Color32[]. You pin the array with GCHandle, get its pointer, and use Marshal.Copy. In NatCam 1.6, we added a PreviewBuffer overload that takes in a Color32[].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment