Cannot get ZXing to work with Kinect ColorFrame

210 views Asked by At

I was able to use ZXing to decode an image saved by Kinect:

// create a barcode reader instance
IBarcodeReader reader = new BarcodeReader();
// load a bitmap
Bitmap barcodeBitmap = (Bitmap)Bitmap.FromFile(path);
// detect and decode the barcode inside the bitmap
var result = reader.Decode(barcodeBitmap);

where path is a .png file generated by Kinect SDK sample code. It's executed after screenshot, and it's quite fast, under 1 second.

However, when I tried to do the same thing without any file:

FrameDescription colorFrameDescription = colorFrame.FrameDescription;
byte[] bit = new byte[colorFrameDescription.LengthInPixels * 4];
colorFrame.CopyConvertedFrameDataToArray(bit, ColorImageFormat.Bgra);
RGBLuminanceSource ls = new RGBLuminanceSource(bit, colorFrameDescription.Width, colorFrameDescription.Height);
IBarcodeReader reader = new BarcodeReader()  { AutoRotate = true, TryHarder = true } ;
// detect and decode the barcode inside the bitmap
var result = reader.Decode(ls); 

The program froze and didn't show anything. In debug mode I found the program was always inside reader.Decode() and never escaped. There must be something wrong here, anyone knows?

0

There are 0 answers