Quantcast
Channel: ZXing.Net
Viewing all 1871 articles
Browse latest View live

Commented Issue: IndexOutOfRangeException with Kinect [12902]

$
0
0
Hello,

i am using the zxing.NET library with the Microsoft Kinect. My problem is, i am getting __after few seconds__ a IndexOutOfRangeException if i want to decode a bitmap. The exception occurs in the method "CovertBitmapToQRcode" if i want to decode the Bitmap. The Resolution of the images from Kinect: 1280x960. Here is the code:
```
void _KinectDevice_AllFramesReady(object sender, AllFramesReadyEventArgs e)
{
using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
{
if (colorFrame != null)
{
if (framecounter > 1)
{
//Copy the information from the colorFrame into an array
colorFrame.CopyPixelDataTo(this._ColorImagePixelData);

//Show the captured image
ColorImageElement.Source = WriteableBitmap.Create(colorFrame.Width, colorFrame.Height, 96, 96, PixelFormats.Bgr32, null, this._ColorImagePixelData, colorFrame.Width * colorFrame.BytesPerPixel);

//Convert the BitmapSouce to a Bitmap
System.Drawing.Bitmap image = BitmapFromSource((BitmapSource)ColorImageElement.Source);

//Show the qrCode in a label
lblQRCode.Content = CovertBitmapToQRcode(image);
framecounter = 0;
}
framecounter++;
}
}
}

//This Method converts a given BitmapSource to a Bitmap.
private System.Drawing.Bitmap BitmapFromSource(BitmapSource bitmapsource)
{
System.Drawing.Bitmap bitmap;
using (MemoryStream outStream = new MemoryStream())
{
BitmapEncoder enc = new BmpBitmapEncoder();
enc.Frames.Add(BitmapFrame.Create(bitmapsource));
enc.Save(outStream);
bitmap = new System.Drawing.Bitmap(outStream);
}
return bitmap;
}

private string CovertBitmapToQRcode(System.Drawing.Bitmap barcodeBitmap)
{

//Flip the bitmap. Because the captured bitmap from the Kinect is mirrored
barcodeBitmap.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipX);
// detect and decode the barcode inside the bitmap
var result = reader.Decode(barcodeBitmap); __//Here i am getting the Exception__

// do something with the result
if (result != null)
{
return "Decoded QRCode: " + result.Text;
}

return "Decoded QRCode: ";
}
```
Thanks for help and for the great library
Comments: ** Comment from web user: micjahn **

Do you have the chance to dump the picture to disk which is decoded when the exception occurs?
Perhaps if you put a try-catch around the Decode call.
I need the failing picture to reproduce the error.

```
try
{
// detect and decode the barcode inside the bitmap
var result = reader.Decode(barcodeBitmap); __//Here i am getting the Exception__
}
catch
{
// dump the current bitmap to the hard disk
}
```


New Post: Does ZXing.Net QRCode support Structured Append?

$
0
0
Thank you!

I could get the merged text, with r86075!

FYI here is a set of Results output.
--- 0
BarcodeFormat=QR_CODE
RawBytes=Byte[] Array
ResultMetadata=
  BYTE_SEGMENTS=System.Collections.Generic.List`1[System.Byte[]]
  ERROR_CORRECTION_LEVEL=L
  STRUCTURED_APPEND_SEQUENCE=17
  STRUCTURED_APPEND_PARITY=79
ResultPoints=ResultPoint[] Array ; 4 points
  [0]=(119.5, 110.5)
  [1]=(119.5, 56.5)
  [2]=(173.5, 56.5)
  [3]=(164.5, 101.5)
Text= the lazy dog
Timestamp=635036022080691425

--- 1
BarcodeFormat=QR_CODE
RawBytes=Byte[] Array
ResultMetadata=
  BYTE_SEGMENTS=System.Collections.Generic.List`1[System.Byte[]]
  ERROR_CORRECTION_LEVEL=L
  STRUCTURED_APPEND_SEQUENCE=1
  STRUCTURED_APPEND_PARITY=79
ResultPoints=ResultPoint[] Array ; 4 points
  [0]=(22.5, 76.5)
  [1]=(22.5, 22.5)
  [2]=(76.5, 22.5)
  [3]=(67.5, 67.5)
Text=The quick brown fox jumps over
Timestamp=635036022080891437

--- 2
BarcodeFormat=QR_CODE
RawBytes=Byte[] Array
ResultMetadata=(none) ; null
ResultPoints=ResultPoint[] Array ; 0 points
Text=The quick brown fox jumps over the lazy dog
Timestamp=635036025106344483

Commented Issue: IndexOutOfRangeException with Kinect [12902]

$
0
0
Hello,

i am using the zxing.NET library with the Microsoft Kinect. My problem is, i am getting __after few seconds__ a IndexOutOfRangeException if i want to decode a bitmap. The exception occurs in the method "CovertBitmapToQRcode" if i want to decode the Bitmap. The Resolution of the images from Kinect: 1280x960. Here is the code:
```
void _KinectDevice_AllFramesReady(object sender, AllFramesReadyEventArgs e)
{
using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
{
if (colorFrame != null)
{
if (framecounter > 1)
{
//Copy the information from the colorFrame into an array
colorFrame.CopyPixelDataTo(this._ColorImagePixelData);

//Show the captured image
ColorImageElement.Source = WriteableBitmap.Create(colorFrame.Width, colorFrame.Height, 96, 96, PixelFormats.Bgr32, null, this._ColorImagePixelData, colorFrame.Width * colorFrame.BytesPerPixel);

//Convert the BitmapSouce to a Bitmap
System.Drawing.Bitmap image = BitmapFromSource((BitmapSource)ColorImageElement.Source);

//Show the qrCode in a label
lblQRCode.Content = CovertBitmapToQRcode(image);
framecounter = 0;
}
framecounter++;
}
}
}

//This Method converts a given BitmapSource to a Bitmap.
private System.Drawing.Bitmap BitmapFromSource(BitmapSource bitmapsource)
{
System.Drawing.Bitmap bitmap;
using (MemoryStream outStream = new MemoryStream())
{
BitmapEncoder enc = new BmpBitmapEncoder();
enc.Frames.Add(BitmapFrame.Create(bitmapsource));
enc.Save(outStream);
bitmap = new System.Drawing.Bitmap(outStream);
}
return bitmap;
}

private string CovertBitmapToQRcode(System.Drawing.Bitmap barcodeBitmap)
{

//Flip the bitmap. Because the captured bitmap from the Kinect is mirrored
barcodeBitmap.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipX);
// detect and decode the barcode inside the bitmap
var result = reader.Decode(barcodeBitmap); __//Here i am getting the Exception__

// do something with the result
if (result != null)
{
return "Decoded QRCode: " + result.Text;
}

return "Decoded QRCode: ";
}
```
Thanks for help and for the great library
Comments: ** Comment from web user: HassanMurat **

I have the picture. But if I want to decode the same picture, i do not get an exception. I think the problem is with the Kinect.
The funny thing is, if I want to decode pictures with 1280x960 in the output window in visual studios, i see every second these exceptions:
"A first chance exception of type 'System.ArgumentException' occurred in zxing.dll" and
"A first chance exception of type 'System.IndexOutOfRangeException' occurred in zxing.dll".
And after a short time (maybe one minute) i get an "System.IndexOutOfRangeException" exception in the code.
When I change the resolution to 640x480 everything is fine.

Thanks

Patch Uploaded: #14450

$
0
0

sfurlani has uploaded a patch.

Description:
Changes for the new PDF417 code added to https://code.google.com/p/zxing/ in revisions r2708 and r2693 (Possibly Others). Adds an update to Common/DecoderResult.cs as well.

This patch includes the changes to the **code only,** as I don't have visual studio (only Xamarin.Studio) so I couldn't add the files to the many, many projects. I've also only run it on Xamarin.Android and not done any of the black box or performance testing.

Commented Issue: IndexOutOfRangeException with Kinect [12902]

$
0
0
Hello,

i am using the zxing.NET library with the Microsoft Kinect. My problem is, i am getting __after few seconds__ a IndexOutOfRangeException if i want to decode a bitmap. The exception occurs in the method "CovertBitmapToQRcode" if i want to decode the Bitmap. The Resolution of the images from Kinect: 1280x960. Here is the code:
```
void _KinectDevice_AllFramesReady(object sender, AllFramesReadyEventArgs e)
{
using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
{
if (colorFrame != null)
{
if (framecounter > 1)
{
//Copy the information from the colorFrame into an array
colorFrame.CopyPixelDataTo(this._ColorImagePixelData);

//Show the captured image
ColorImageElement.Source = WriteableBitmap.Create(colorFrame.Width, colorFrame.Height, 96, 96, PixelFormats.Bgr32, null, this._ColorImagePixelData, colorFrame.Width * colorFrame.BytesPerPixel);

//Convert the BitmapSouce to a Bitmap
System.Drawing.Bitmap image = BitmapFromSource((BitmapSource)ColorImageElement.Source);

//Show the qrCode in a label
lblQRCode.Content = CovertBitmapToQRcode(image);
framecounter = 0;
}
framecounter++;
}
}
}

//This Method converts a given BitmapSource to a Bitmap.
private System.Drawing.Bitmap BitmapFromSource(BitmapSource bitmapsource)
{
System.Drawing.Bitmap bitmap;
using (MemoryStream outStream = new MemoryStream())
{
BitmapEncoder enc = new BmpBitmapEncoder();
enc.Frames.Add(BitmapFrame.Create(bitmapsource));
enc.Save(outStream);
bitmap = new System.Drawing.Bitmap(outStream);
}
return bitmap;
}

private string CovertBitmapToQRcode(System.Drawing.Bitmap barcodeBitmap)
{

//Flip the bitmap. Because the captured bitmap from the Kinect is mirrored
barcodeBitmap.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipX);
// detect and decode the barcode inside the bitmap
var result = reader.Decode(barcodeBitmap); __//Here i am getting the Exception__

// do something with the result
if (result != null)
{
return "Decoded QRCode: " + result.Text;
}

return "Decoded QRCode: ";
}
```
Thanks for help and for the great library
Comments: ** Comment from web user: micjahn **

Very hard to find the error without the chance to debugging it.
But I validate a new patch for PDF417 decoding which change nearly every line.
Perhaps that patch will fix your error.
And I downloaded the kinect sdk. Perhaps I can write a special luminance source class for kinect.
With that you don't have to convert the frame to a bitmap.

Source code checked in, #86127

$
0
0
performance improvements for monotouch

Source code checked in, #86128

Source code checked in, #86129


Commented Issue: IndexOutOfRangeException with Kinect [12902]

$
0
0
Hello,

i am using the zxing.NET library with the Microsoft Kinect. My problem is, i am getting __after few seconds__ a IndexOutOfRangeException if i want to decode a bitmap. The exception occurs in the method "CovertBitmapToQRcode" if i want to decode the Bitmap. The Resolution of the images from Kinect: 1280x960. Here is the code:
```
void _KinectDevice_AllFramesReady(object sender, AllFramesReadyEventArgs e)
{
using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
{
if (colorFrame != null)
{
if (framecounter > 1)
{
//Copy the information from the colorFrame into an array
colorFrame.CopyPixelDataTo(this._ColorImagePixelData);

//Show the captured image
ColorImageElement.Source = WriteableBitmap.Create(colorFrame.Width, colorFrame.Height, 96, 96, PixelFormats.Bgr32, null, this._ColorImagePixelData, colorFrame.Width * colorFrame.BytesPerPixel);

//Convert the BitmapSouce to a Bitmap
System.Drawing.Bitmap image = BitmapFromSource((BitmapSource)ColorImageElement.Source);

//Show the qrCode in a label
lblQRCode.Content = CovertBitmapToQRcode(image);
framecounter = 0;
}
framecounter++;
}
}
}

//This Method converts a given BitmapSource to a Bitmap.
private System.Drawing.Bitmap BitmapFromSource(BitmapSource bitmapsource)
{
System.Drawing.Bitmap bitmap;
using (MemoryStream outStream = new MemoryStream())
{
BitmapEncoder enc = new BmpBitmapEncoder();
enc.Frames.Add(BitmapFrame.Create(bitmapsource));
enc.Save(outStream);
bitmap = new System.Drawing.Bitmap(outStream);
}
return bitmap;
}

private string CovertBitmapToQRcode(System.Drawing.Bitmap barcodeBitmap)
{

//Flip the bitmap. Because the captured bitmap from the Kinect is mirrored
barcodeBitmap.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipX);
// detect and decode the barcode inside the bitmap
var result = reader.Decode(barcodeBitmap); __//Here i am getting the Exception__

// do something with the result
if (result != null)
{
return "Decoded QRCode: " + result.Text;
}

return "Decoded QRCode: ";
}
```
Thanks for help and for the great library
Comments: ** Comment from web user: micjahn **

With revision 86128 and 86129 I added two special classes and a new project to the repository.
https://zxingnet.codeplex.com/SourceControl/changeset/86128
https://zxingnet.codeplex.com/SourceControl/changeset/86129
If you can build your own version of zxing you will get a new assembly zxing.kinect.dll.
That assembly can be used directly with ColorImageFrame instances.
Alternativly you can add the two classes from the subdirectory kinect to your project file.
Please try it out.

```
var reader = new ZXing.Kinect.BarcodeReader();

void _KinectDevice_AllFramesReady(object sender, AllFramesReadyEventArgs e)
{
using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
{
if (colorFrame != null)
{
if (framecounter > 1)
{
//Show the qrCode in a label
lblQRCode.Content = CovertBitmapToQRcode(colorFrame);
framecounter = 0;
}
framecounter++;
}
}
}

private string CovertBitmapToQRcode(ColorImageFrame barcodeBitmap)
{
// detect and decode the barcode inside the bitmap
var result = reader.Decode(barcodeBitmap);

// do something with the result
if (result != null)
{
return "Decoded QRCode: " + result.Text;
}

return "Decoded QRCode: ";
}
```

Source code checked in, #86130

$
0
0
switch RGB32 to BGR32 for kinect

New Post: Reading QR codes / bar codes in windows 8 application using xaml C#

$
0
0
Hi

I want to read qr codes in windows 8 application, i went through some discussions on different thread but got confused and still was not able to get out.

I use the following code
        var openPicker = new FileOpenPicker { ViewMode = PickerViewMode.Thumbnail, SuggestedStartLocation = PickerLocationId.PicturesLibrary };
        openPicker.FileTypeFilter.Add(".jpg");
        openPicker.FileTypeFilter.Add(".jpeg");
        openPicker.FileTypeFilter.Add(".png");

        StorageFile file = await openPicker.PickSingleFileAsync();
        if (file != null)
        {
            // Application now has read/write access to the picked file

            BitmapImage bmp = new BitmapImage();
            IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read);
            bmp.SetSource(stream);
            BarCodeImage.Source = bmp;

            IBarcodeReader reader = new BarcodeReader();
            WriteableBitmap barcodeBitmap = new WriteableBitmap(1,1);
            barcodeBitmap.SetSource(stream);
            var result = reader.Decode(barcodeBitmap);
        }
but while loading the result i am getting exception. Please help what should be code for it

New Post: Reading QRcode in an image, which have more than one barcode

$
0
0
Hi,

As I know, IBarcodeReader.Decode() function reads all the barcodes there are on an image.

If one image have more than one barcode(maybe incould code39, QRcode.....),
but I only want to read QRcode, how can i do ?

I had use WindowsFormsDemo to read it, but only read first bracode.
and then, I have test QRCodeMultiReader, but i don't how to use it.

Anybody having the same problem? Can advise?

thanks.

New Post: Reading QRcode in an image, which have more than one barcode

$
0
0
If you want to find only one code inside an image with a specific type, you can use the following code snippet:
var reader = new BarcodeReader
   {
      PossibleFormats = new List<BarcodeFormat>
         {
            BarcodeFormat.QR_CODE
         }
   };
var result = reader.Decode(bitmap);
If you want to find more than one code inside an image you have to use the following snippet:
var reader = new BarcodeReader
   {
      PossibleFormats = new List<BarcodeFormat>
         {
            BarcodeFormat.QR_CODE
         }
   };
var results = reader.DecodeMultiple(bitmap);
The WindowsFormsDemo has an options dialog where you can enable multiple codes per image.

New Post: Reading QR codes / bar codes in windows 8 application using xaml C#

$
0
0
Please post the exception with stacktrace here. It makes it easier finding the error.
But I think I know what happens.
You can try the following snippet:
var openPicker = new FileOpenPicker { ViewMode = PickerViewMode.Thumbnail, SuggestedStartLocation = PickerLocationId.PicturesLibrary };
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");

StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
    // Application now has read/write access to the picked file

    BitmapImage bmp = new BitmapImage();
    IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read);
    bmp.SetSource(stream);
    BarCodeImage.Source = bmp;

    IBarcodeReader reader = new BarcodeReader();
    WriteableBitmap barcodeBitmap = new WriteableBitmap(1,1);
    barcodeBitmap.SetSource(stream);
    
    // and create it again because otherwise the WB isn't fully initialized and decoding
    // results in a IndexOutOfRange
    barcodeBitmap = new WriteableBitmap(barcodeBitmap.PixelWidth, barcodeBitmap.PixelHeight);
    stream.Seek(0);
    barcodeBitmap.SetSource(stream);
    
    var result = reader.Decode(barcodeBitmap);
}

Commented Feature: Implement the new PDF417 decoder algorithms [12891]

$
0
0
The java version of zxing has a new PDF417 decoder which has a much better success rate.
I converted the java code to C# but the performance is worst.

This issue documents the java changesets which I have to look at if I can fix the performance issue:
2594, 2596, 2639, 2640, 2642, 2660
Comments: ** Comment from web user: jppriest **

Is there a preview version for this at all? So that I can check for accuracy?


New Post: Reading QRcode in an image, which have more than one barcode

$
0
0
Hi micjahn,

I want to to find only one code inside an image with a QR Code type.
I have try both of you suggest code, but it don't work.
Can you advise again ?
using ZXing;
using ZXing.Common;
using ZXing.Multi;
using ZXing.Multi.QrCode;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {



        private readonly IBarcodeReader barcodeReader;
        private readonly IList<ResultPoint> resultPoints;
        private readonly IDictionary<DecodeHintType, object> hints;
  
        public Form1()
        {
            InitializeComponent();
            resultPoints = new List<ResultPoint>();
         
            barcodeReader = new BarcodeReader { AutoRotate = true, TryHarder = true };
            hints = new Dictionary<DecodeHintType, object>();

            barcodeReader.ResultPointFound += point =>
            {
                if (point == null)
                    resultPoints.Clear();
                else
                    resultPoints.Add(point);
            };
            barcodeReader.ResultFound += result =>
            {
                txtType.Text = result.BarcodeFormat.ToString();
                txtDecoderContent.Text = result.Text;
            };
        }

        private void button1_Click(object sender, EventArgs e)
        {
             var fileName = "C:\\test.PNG";
             Decode((Bitmap)Bitmap.FromFile(fileName));
        }

  
        private void Decode(Bitmap image)
        {
            resultPoints.Clear();
         /*   var reader = new BarcodeReader
            {
                PossibleFormats = new List<BarcodeFormat>
                 {
                    BarcodeFormat.QR_CODE
                 }
            };
        
            var result = reader.Decode(image);
         */ 
            var result = barcodeReader.Decode(image);
            var timerStart = DateTime.Now.Ticks;
            var timerStop = DateTime.Now.Ticks;

            if (result == null)
            {
                txtDecoderContent.Text = "No barcode recognized";
            }
            labDuration.Text = new TimeSpan(timerStop - timerStart).Milliseconds.ToString("0 ms");
         }
    }
}

New Post: Reading QR codes / bar codes in windows 8 application using xaml C#

$
0
0
I tried the above piece of code, it throws error again

Message - Index was outside the bounds of the array.

StackTrace :-
at ZXing.BitmapLuminanceSource..ctor(WriteableBitmap writeableBitmap) in c:\Users\michael.jahn\Documents\SVN\ZXing.Net.WINMD\Source\lib\BitmapLuminanceSource.Silverlight.cs:line 56
at ZXing.BarcodeReader.<.cctor>b__3(WriteableBitmap bitmap) in c:\Users\michael.jahn\Documents\SVN\ZXing.Net.WINMD\Source\lib\BarcodeReader.WINMD.cs:line 37
at ZXing.BarcodeReader.Decode(WriteableBitmap barcodeBitmap) in c:\Users\michael.jahn\Documents\SVN\ZXing.Net.WINMD\Source\lib\BarcodeReader.WINMD.cs:line 312
at BarCode_Reader.MainPage.<ButtonBase_OnClick>d__1.MoveNext() in e:\Practice\BarCode Reader\BarCode Reader\MainPage.xaml.cs:line 71


For the previous code
Message - Value cannot be null. Parameter name: source

StackTrace :-
at System.Runtime.InteropServices.Marshal.CopyToManaged(IntPtr source, Object destination, Int32 startIndex, Int32 length)
at System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeBufferExtensions.CopyTo(IBuffer source, UInt32 sourceIndex, Byte[] destination, Int32 destinationIndex, Int32 count)
at System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeBufferExtensions.ToArray(IBuffer source, UInt32 sourceIndex, Int32 count)
at ZXing.BitmapLuminanceSource..ctor(WriteableBitmap writeableBitmap) in c:\Users\michael.jahn\Documents\SVN\ZXing.Net.WINMD\Source\lib\BitmapLuminanceSource.Silverlight.cs:line 50
at ZXing.BarcodeReader.<.cctor>b__3(WriteableBitmap bitmap) in c:\Users\michael.jahn\Documents\SVN\ZXing.Net.WINMD\Source\lib\BarcodeReader.WINMD.cs:line 37
at ZXing.BarcodeReader.Decode(WriteableBitmap barcodeBitmap) in c:\Users\michael.jahn\Documents\SVN\ZXing.Net.WINMD\Source\lib\BarcodeReader.WINMD.cs:line 312
at BarCode_Reader.MainPage.<ButtonBase_OnClick>d__1.MoveNext() in e:\Practice\BarCode Reader\BarCode Reader\MainPage.xaml.cs:line 64

New Post: Reading QRcode in an image, which have more than one barcode

$
0
0
Can you give me a sample image which you tried?

Commented Feature: Implement the new PDF417 decoder algorithms [12891]

$
0
0
The java version of zxing has a new PDF417 decoder which has a much better success rate.
I converted the java code to C# but the performance is worst.

This issue documents the java changesets which I have to look at if I can fix the performance issue:
2594, 2596, 2639, 2640, 2642, 2660
Comments: ** Comment from web user: micjahn **

It's still work in progress. If it is finished I will commit the sources and you can build your own version of zxing and test it.

New Post: Reading QR codes / bar codes in windows 8 application using xaml C#

Viewing all 1871 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>