Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMB barcode could not be read #59

Closed
karthikeyan-live opened this issue Nov 18, 2017 · 4 comments
Closed

IMB barcode could not be read #59

karthikeyan-live opened this issue Nov 18, 2017 · 4 comments

Comments

@karthikeyan-live
Copy link

karthikeyan-live commented Nov 18, 2017

I have tried to read IMB barcode with the below code snippet, but it always return null; any suggestions are highly appreciated. I have also tried with the IMB barcode images in the blackbox testing below, but doesn't works:
https://github.com/micjahn/ZXing.Net/tree/master/Source/test/data/blackbox/imb-1

private static void Decode()
{
    Bitmap bitmap = new Bitmap(@"\07.png");
    try
    {
        MemoryStream memoryStream = new MemoryStream();
        bitmap.Save(memoryStream, ImageFormat.Bmp);
        byte[] byteArray = memoryStream.GetBuffer();
        ZXing.LuminanceSource source = new RGBLuminanceSource(byteArray, bitmap.Width, bitmap.Height);
        var binarizer = new HybridBinarizer(source);
        var binBitmap = new BinaryBitmap(binarizer);
        IMBReader imbReader = new IMBReader();

        Result str = imbReader.decode(binBitmap);

    }
    catch { }

}
@micjahn
Copy link
Owner

micjahn commented Nov 18, 2017

Your code with the sample image 07.png works like a charm for me.

Anyway, I would use a much simpler way

private static void Decode2()
{
	var bitmap = new Bitmap(@"\07.png"); // make sure that the file exists at the root level
	try
	{
		var imbReader = new BarcodeReader
		{
			Options =
			{
				PossibleFormats = new List<BarcodeFormat> {BarcodeFormat.IMB}
			}
		};
		var result = imbReader.Decode(bitmap);
		if (result != null)
			System.Console.WriteLine(result.Text);
		else
			System.Console.WriteLine("nothing found");
	}
	catch (System.Exception exc)
	{
		System.Console.WriteLine(exc.ToString());
	}
}

@micjahn micjahn closed this as completed Nov 18, 2017
@karthikeyan-live
Copy link
Author

Thank you, your code works fine 👍

@micjahn
Copy link
Owner

micjahn commented Nov 20, 2017

I'm glad that I could help you.

@abhishekgaur4feb
Copy link

@micjahn and @karthikeyan-live can you please share me the libraries used?
Currently i am using the below mentioned libraries but not able to get BarcodeFormat.IMB

com.google.zxing core 3.2.1 com.google.zxing javase 3.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants