This project has moved. For the latest updates, please go here.

EAN_13 recognition from camera

Apr 2, 2013 at 11:14 AM
Hello,

I am fiddling with the Windows Phone sample. I am only concerned with EAN_13 barcodes scanning from the camera, and it seems that the zxing.net can't recognize them very well. It takes a lot of time to get a perfect focus ant shot. A lot of barcodes are not recognized at all (too small or not monocolored).

Any tips or suggestions how to improve the recognition rate?
Coordinator
Apr 2, 2013 at 7:11 PM
Which Windows Phone sample do you use? The WP8 or WP7 version?
I compared both. They are not in sync. The WP8 samples lacks the auto focus support.
Perhaps that the issue.
Apr 2, 2013 at 7:42 PM
Edited Apr 2, 2013 at 8:09 PM
Thank you for your time. I have actually used the WP7 version. I am deploying it on Nokia Lumia 800 device.
Coordinator
Apr 2, 2013 at 8:24 PM
Perhaps it is the opposite. Perhaps the auto focus support isn't implemented correctly.
The main problem: I can't test it because I have no WP device. Sorry.
What about other codes? Do QR codes work well?
Apr 2, 2013 at 8:38 PM
The QR codes, at least those I got my hands on worked quite well. They were rather large though and there are no problems with large barcodes.
I am thinking about some preprocessing the image data before decoding it. Maybe cropping out the frame and then resizing the image would help?
Coordinator
Apr 2, 2013 at 8:53 PM
I'm not sure if it helps.

The current samples are using the preview buffer for decoding and not the whole resolution of the camera.
I need a dump of the preview buffer (luminance.PreviewBufferY) for deeper analyzing.
The buffer has to be dumped after the following call
photoCamera.GetPreviewBufferY(luminance.PreviewBufferY);
And I need the width and the height which is used to initialize the PhotoCameraLuminanceSource.
Apr 2, 2013 at 10:07 PM
Do you know a way I could provide you the buffer dump? I cannot access the process with task manager or dump software since it is running on the device.
Coordinator
Apr 2, 2013 at 10:41 PM
Edited Aug 28, 2013 at 8:09 PM
I didn't try it. But I only mean saving the buffer to a file (or IsolatedStorage, any place for a file is suitable).
Something like this:
    using(var appStorage = IsolatedStorageFile.GetUserStoreForApplication())
    using(var file = appStorage.OpenFile("dump.bin", FileMode.OpenOrCreate))
    using(var writer = new BinaryWriter(file))
    {
        writer.Write(luminance.PreviewBufferY);
    }
Aug 27, 2013 at 7:09 PM
Any news on this? I have the same problems with EAN8/EAN13 Barcodes.
Coordinator
Aug 27, 2013 at 7:46 PM
I never got a dump of the preview buffer.
So I could not help here.
Aug 28, 2013 at 6:01 PM
I have made a dump. How can I send it to you?

This is my code:
      foreach (byte b in previewBuffer)
                    {
                        writer.Write(b);
                    }
Is this correct? The byte[] is writen to the file as int values. The code from above only wrote the ToString() text of the byte[] which is the Class-Name
Coordinator
Aug 28, 2013 at 8:07 PM
Sorry, my mistake. Please use the BinaryWriter.
using(var appStorage = IsolatedStorageFile.GetUserStoreForApplication())
using(var file = appStorage.OpenFile("dump.bin", FileMode.OpenOrCreate))
using(var writer = new BinaryWriter(file))
{
    writer.Write(luminance.PreviewBufferY);
}
I will send you an email so you can send me the dump via email.
Coordinator
Sep 8, 2013 at 8:29 PM
Conclusion from the email conversation:

Changing the following line in the WP8 demo will work:
Size resolution = await Task.Factory.StartNew(
    () => captureResolutions.Last(
    c => (c.Width > 1000.0 || c.Height > 1000.0) && previewResolutions.Any(p => (c.Width / c.Height).Equals(p.Width / p.Height))));
to
//Get largest Preview Resolution
Size resolution = await Task.Factory.StartNew(() => previewResolutions.First(c => (captureResolutions.Any(p => p.Width == c.Width && p.Height == c.Height))));
Feb 19, 2014 at 9:11 AM
I have the same problem with WP8 with PhotoCaptureDevice, it scans QRCode very quickly, but scan EAN_13 is very slowly. Can someone tell me why? Thanks
Coordinator
Feb 23, 2014 at 6:39 PM
Do you use the WP8 demo from the source code repository or your own implementation?
Feb 24, 2014 at 1:59 AM
Thanks micjahn's reply. I solved the problem, and the reason was when I clipped the focus prewbuffer, used the wrong copy function