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

New Post: Xamarin Reference Sample


New Post: how to better recognize qrcode

$
0
0
Hi, I'm developping an app for windows phone (silverlight) to recognize the qrcode.
I look the demo and I use a videobrush to show the phone camera content.
I want to draw on videobrush a square to better focus the qrcode, cropping the image, or image processing task?
Anyone knows how to draw on videobrush or any way to better recognize the qrcode?
Thanks a lot.

New Post: any idea why i can't pickup this code?

New Post: Add image or logo inside generated QRCode

$
0
0
Hi all,

Does anyone know if it is possible to add a logo to the centre of the generated QRCode?

Something similar to:
Image

It is very easy to use the library and here is my code so far:
[TestMethod]
public void SimpleQrCode()
{
    IBarcodeWriter writer = new BarcodeWriter
    {
        Format = BarcodeFormat.QR_CODE,
        Options = new QrCodeEncodingOptions
        {
            ErrorCorrection = ErrorCorrectionLevel.L,
            Height = 500,
            Width = 500,
            Margin = 10
        }
    };
    var result = writer.Write("test content");
    var barcodeBitmap = new Bitmap(result);
    barcodeBitmap.Save("C:\\Temp\\qrCode.png", ImageFormat.Png);

    Assert.IsTrue(File.Exists("C:\\Temp\\qrCode.png"));
}

New Post: Add image or logo inside generated QRCode

$
0
0
I wasn't able to achieve this using the library, but by increasing the error correction level I am able to generate the QR code and then apply another image on-top of the QR code.
[TestMethod]
public void SimpleQrCode()
{
    var options = new QrCodeEncodingOptions
    {
        ErrorCorrection = ErrorCorrectionLevel.H, //this allowed me to place my image in the centre of the QR code and maintained scanning functionality.
        Height = 500,
        Width = 500,
        Margin = 0
    };
    IBarcodeWriter writer = new BarcodeWriter
    {
        Format = BarcodeFormat.QR_CODE,
        Options = options
    };

    var result = writer.Write("test content");
    var barcodeBitmap = new Bitmap(result);
    barcodeBitmap.Save(string.Format("C:\\Temp\\qrCode{0}x{1}.png", options.Width, options.Height), ImageFormat.Png);

    Assert.IsTrue(File.Exists(string.Format("C:\\Temp\\qrCode{0}x{1}.png", options.Width, options.Height)));
}

New Post: how to better recognize qrcode

New Post: Optimize qrcode recognition

$
0
0
Which are the rectangle size for better recognize the qrcode?
Thanks

New Post: Continuously stream QR codes

$
0
0
Hi ab185280,

Were you ever able to solve this problem?

I have the same requirement to keep the scanner/camera screen open.

Any help would be really appreciated.

Kind Regards,
Charan

New Post: Continuously stream QR codes

$
0
0
Yes I was able to solve it in the end although not via an intent, I had to import the ZXing libraries and edit the source code myself insode the CaptureActivity class.
I changed the HandleDecode method so that it does not show the UI pause inbetween scanning the frames, instead you can place your own code inside the method to do whatever you need. I am writing every successful decode into an arraylist in the decode method then telling the app to go back to scanning for more frames. When the user selects the back button the result containing the arraylist of scanned data is put back to the original native app intent that called it.
public void handleDecode(final Result rawResult, Bitmap barcode, float scaleFactor) {
        inactivityTimer.onActivity();
        lastResult = rawResult;

        try{

                        // your code here
            restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS);
        }
        catch(Exception e){
        }
    }
Hope this helps

Created Unassigned: UTF problem. Some international characters are not rendered properly [13279]

$
0
0
```
var _tmpstr = "ç. Ýalňyş bolmaz diýen ümit öňden bäri hem bar. öŽŽe";

var _barkodYazici = new ZXing.BarcodeWriter()
{
Format = ZXing.BarcodeFormat.QR_CODE,
Options = new ZXing.Common.EncodingOptions()
{
Height = 300,
Width = 300,
Margin = 1
}
};

using (var bitmap = _barkodYazici.Write(_tmpstr))
using(var stream = new System.IO.MemoryStream())
{
bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
BitmapImage bi = new BitmapImage();
bi.BeginInit();
stream.Seek(0, System.IO.SeekOrigin.Begin);
bi.StreamSource = stream;
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.EndInit();

return bi;
}
```

QrCode above isn't rendered correctly. Some data is lost.
But if use code from stackoverflow:

```
//http://stackoverflow.com/questions/6198744/convert-string-utf-16-to-utf-8-in-c-sharp
public static string Utf16ToUtf8(string utf16String)
{
/**************************************************************
* Every .NET string will store text with the UTF16 encoding, *
* known as Encoding.Unicode. Other encodings may exist as *
* Byte-Array or incorrectly stored with the UTF16 encoding. *
* *
* UTF8 = 1 bytes per char *
* ["100" for the ansi 'd'] *
* ["206" and "186" for the russian 'κ'] *
* *
* UTF16 = 2 bytes per char *
* ["100, 0" for the ansi 'd'] *
* ["186, 3" for the russian 'κ'] *
* *
* UTF8 inside UTF16 *
* ["100, 0" for the ansi 'd'] *
* ["206, 0" and "186, 0" for the russian 'κ'] *
* *
* We can use the convert encoding function to convert an *
* UTF16 Byte-Array to an UTF8 Byte-Array. When we use UTF8 *
* encoding to string method now, we will get a UTF16 string. *
* *
* So we imitate UTF16 by filling the second byte of a char *
* with a 0 byte (binary 0) while creating the string. *
**************************************************************/

// Storage for the UTF8 string
string utf8String = String.Empty;

// Get UTF16 bytes and convert UTF16 bytes to UTF8 bytes
byte[] utf16Bytes = Encoding.Unicode.GetBytes(utf16String);
byte[] utf8Bytes = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, utf16Bytes);

// Fill UTF8 bytes inside UTF8 string
for (int i = 0; i < utf8Bytes.Length; i++)
{
// Because char always saves 2 bytes, fill char with 0
byte[] utf8Container = new byte[2] { utf8Bytes[i], 0 };
utf8String += BitConverter.ToChar(utf8Container, 0);
}

// Return UTF8
return utf8String;
}
```

and replace :

```
var _tmpstr = "ç. Ýalňyş bolmaz diýen ümit öňden bäri hem bar. öŽŽe";
```

with:

```
var _tmpstr = Utf16ToUtf8("ç. Ýalňyş bolmaz diýen ümit öňden bäri hem bar. öŽŽe");
```

rendering results are correct

Commented Unassigned: UTF problem. Some international characters are not rendered properly [13279]

$
0
0
```
var _tmpstr = "ç. Ýalňyş bolmaz diýen ümit öňden bäri hem bar. öŽŽe";

var _barkodYazici = new ZXing.BarcodeWriter()
{
Format = ZXing.BarcodeFormat.QR_CODE,
Options = new ZXing.Common.EncodingOptions()
{
Height = 300,
Width = 300,
Margin = 1
}
};

using (var bitmap = _barkodYazici.Write(_tmpstr))
using(var stream = new System.IO.MemoryStream())
{
bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
BitmapImage bi = new BitmapImage();
bi.BeginInit();
stream.Seek(0, System.IO.SeekOrigin.Begin);
bi.StreamSource = stream;
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.EndInit();

return bi;
}
```

QrCode above isn't rendered correctly. Some data is lost.
But if use code from stackoverflow:

```
//http://stackoverflow.com/questions/6198744/convert-string-utf-16-to-utf-8-in-c-sharp
public static string Utf16ToUtf8(string utf16String)
{
/**************************************************************
* Every .NET string will store text with the UTF16 encoding, *
* known as Encoding.Unicode. Other encodings may exist as *
* Byte-Array or incorrectly stored with the UTF16 encoding. *
* *
* UTF8 = 1 bytes per char *
* ["100" for the ansi 'd'] *
* ["206" and "186" for the russian 'κ'] *
* *
* UTF16 = 2 bytes per char *
* ["100, 0" for the ansi 'd'] *
* ["186, 3" for the russian 'κ'] *
* *
* UTF8 inside UTF16 *
* ["100, 0" for the ansi 'd'] *
* ["206, 0" and "186, 0" for the russian 'κ'] *
* *
* We can use the convert encoding function to convert an *
* UTF16 Byte-Array to an UTF8 Byte-Array. When we use UTF8 *
* encoding to string method now, we will get a UTF16 string. *
* *
* So we imitate UTF16 by filling the second byte of a char *
* with a 0 byte (binary 0) while creating the string. *
**************************************************************/

// Storage for the UTF8 string
string utf8String = String.Empty;

// Get UTF16 bytes and convert UTF16 bytes to UTF8 bytes
byte[] utf16Bytes = Encoding.Unicode.GetBytes(utf16String);
byte[] utf8Bytes = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, utf16Bytes);

// Fill UTF8 bytes inside UTF8 string
for (int i = 0; i < utf8Bytes.Length; i++)
{
// Because char always saves 2 bytes, fill char with 0
byte[] utf8Container = new byte[2] { utf8Bytes[i], 0 };
utf8String += BitConverter.ToChar(utf8Container, 0);
}

// Return UTF8
return utf8String;
}
```

and replace :

```
var _tmpstr = "ç. Ýalňyş bolmaz diýen ümit öňden bäri hem bar. öŽŽe";
```

with:

```
var _tmpstr = Utf16ToUtf8("ç. Ýalňyş bolmaz diýen ümit öňden bäri hem bar. öŽŽe");
```

rendering results are correct
Comments: ** Comment from web user: micjahn **

The standard encoding for QR code is ISO8859-1 (defined in the specs).
Your characters are not valid for that character set.
If you want to use such content in a correct way you have to define the UTF-8 character set in the encoding options:
```
var _barkodYazici = new ZXing.BarcodeWriter()
{
Format = ZXing.BarcodeFormat.QR_CODE,
Options = new ZXing.QrCode.QrCodeEncodingOptions()
{
Height = 300,
Width = 300,
Margin = 1,
CharacterSet = "UTF-8"
}
};
```

The encoder automatically adds the necessary ECI segment. Some readers have trouble with the ECI segment, so you can explicitly disable it with another option.
```
var _barkodYazici = new ZXing.BarcodeWriter()
{
Format = ZXing.BarcodeFormat.QR_CODE,
Options = new ZXing.QrCode.QrCodeEncodingOptions()
{
Height = 300,
Width = 300,
Margin = 1,
CharacterSet = "UTF-8",
DisableECI = true
}
};
```

Closed Unassigned: UTF problem. Some international characters are not rendered properly [13279]

$
0
0
```
var _tmpstr = "ç. Ýalňyş bolmaz diýen ümit öňden bäri hem bar. öŽŽe";

var _barkodYazici = new ZXing.BarcodeWriter()
{
Format = ZXing.BarcodeFormat.QR_CODE,
Options = new ZXing.Common.EncodingOptions()
{
Height = 300,
Width = 300,
Margin = 1
}
};

using (var bitmap = _barkodYazici.Write(_tmpstr))
using(var stream = new System.IO.MemoryStream())
{
bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
BitmapImage bi = new BitmapImage();
bi.BeginInit();
stream.Seek(0, System.IO.SeekOrigin.Begin);
bi.StreamSource = stream;
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.EndInit();

return bi;
}
```

QrCode above isn't rendered correctly. Some data is lost.
But if use code from stackoverflow:

```
//http://stackoverflow.com/questions/6198744/convert-string-utf-16-to-utf-8-in-c-sharp
public static string Utf16ToUtf8(string utf16String)
{
/**************************************************************
* Every .NET string will store text with the UTF16 encoding, *
* known as Encoding.Unicode. Other encodings may exist as *
* Byte-Array or incorrectly stored with the UTF16 encoding. *
* *
* UTF8 = 1 bytes per char *
* ["100" for the ansi 'd'] *
* ["206" and "186" for the russian 'κ'] *
* *
* UTF16 = 2 bytes per char *
* ["100, 0" for the ansi 'd'] *
* ["186, 3" for the russian 'κ'] *
* *
* UTF8 inside UTF16 *
* ["100, 0" for the ansi 'd'] *
* ["206, 0" and "186, 0" for the russian 'κ'] *
* *
* We can use the convert encoding function to convert an *
* UTF16 Byte-Array to an UTF8 Byte-Array. When we use UTF8 *
* encoding to string method now, we will get a UTF16 string. *
* *
* So we imitate UTF16 by filling the second byte of a char *
* with a 0 byte (binary 0) while creating the string. *
**************************************************************/

// Storage for the UTF8 string
string utf8String = String.Empty;

// Get UTF16 bytes and convert UTF16 bytes to UTF8 bytes
byte[] utf16Bytes = Encoding.Unicode.GetBytes(utf16String);
byte[] utf8Bytes = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, utf16Bytes);

// Fill UTF8 bytes inside UTF8 string
for (int i = 0; i < utf8Bytes.Length; i++)
{
// Because char always saves 2 bytes, fill char with 0
byte[] utf8Container = new byte[2] { utf8Bytes[i], 0 };
utf8String += BitConverter.ToChar(utf8Container, 0);
}

// Return UTF8
return utf8String;
}
```

and replace :

```
var _tmpstr = "ç. Ýalňyş bolmaz diýen ümit öňden bäri hem bar. öŽŽe";
```

with:

```
var _tmpstr = Utf16ToUtf8("ç. Ýalňyş bolmaz diýen ümit öňden bäri hem bar. öŽŽe");
```

rendering results are correct

New Post: Optimize qrcode recognition

$
0
0
The rectangle size doesn't influence the recognition rate.
The resolution of the image, the autofocus and the whole quality of the captured image are the key values for a good result.

New Post: Continuously stream QR codes

$
0
0
Only one small remark:
Your solution is based on the original java version of zxing and can not be used with ZXing.Net.

New Post: any idea why i can't pickup this code?

$
0
0
Not really.
How did you generate the barcodes? Which app or library did you use?

New Post: Continuously stream QR codes

$
0
0
Agreed micjahn.

I'm looking for something in ZXing.net.

Any help would be great.

Thanks guys.

Regards,
Charan

New Post: vuforia example is not working!!!???

$
0
0
I am also having trouble running the Vuforia example.

I have the VuforiaScanner script attached to the AR camera.

I have dragged the camera into the "Vuforia" QCARBehaviour variable on the script.

I have a 3D Text object selected as the "Target" variable on the script.

I get the following error when I run the code:

Failed to set frame format
UnityEngine.Debug:LogError(Object)
CameraDeviceImpl:SetFrameFormat(PIXEL_FORMAT, Boolean)
VuforiaScanner:<Update>m__3() (at Assets/VuforiaScanner.cs:39)
Loom:Update() (at Assets/Plugins/radical/System/Loom.cs:146)

So far I've been unable to find instructions on how to configure and run this example.

New Post: Scan Barcode Continuously

$
0
0
My code trust scan 1 barcode each time. I want it to scan continuously.
ex: I put an barcode in front of my device camera, my app scan it and show the result, and also with the second barcode. Until I click button "BACK". Can I do that? Thank you.

New Post: Windows Phone 8.1

$
0
0
Hello,
I have created an QR-Code Scanner for WP 8.1.
My Problem is that it needs about 8 seconds to complete the process.
I've used your WindowsRT example to get rid of QR-Code scanning.

The process inside the while loop is currently running really slow! Any suggestions how i can improve the process?
Code Snippets:
await _mediaCapture.StartPreviewAsync();

int i = 0;
var barcodeReader = new BarcodeReader
{
    TryHarder = true,
    AutoRotate = true
};

while (_result == null)
{
    photoStorageFile = await KnownFolders.PicturesLibrary.CreateFileAsync("scan.jpg", CreationCollisionOption.ReplaceExisting);
    await _mediaCapture.CapturePhotoToStorageFileAsync(ImageEncodingProperties.CreateJpeg(), photoStorageFile);

    var stream = await photoStorageFile.OpenReadAsync();

    var writeableBmp = new WriteableBitmap(1, 1);
    writeableBmp.SetSource(stream);

    writeableBmp = new WriteableBitmap(writeableBmp.PixelWidth, writeableBmp.PixelHeight);
    stream.Seek(0);
    writeableBmp.SetSource(stream);
    _result = barcodeReader.Decode(writeableBmp);
    if (_result != null)
    {
        CaptureImage.Source = writeableBmp;
    }

    i += 1;
    ScanResult.Text = "Nummer " + i;
}
await _mediaCapture.StopPreviewAsync();
VideoCapture.Visibility = Visibility.Collapsed;
CaptureImage.Visibility = Visibility.Visible;
ScanResult.Text = _result.Text;
}

Created Unassigned: Code 39 scan returns wrong string on Android [13281]

$
0
0
When a code 39 barcode contains the $ character, on xamarin android, the returned string escapes the $ and substracts 64 to the binary value of the following character, for example the attached barcode should read "$A $B" (decimal bytes: 36, 65, 32, 36, 66) but the resulting decimal bytes are 1, 32, 2.

The standalone android app reads the barcode correctly (or has a workaround).
A text QR code with the same string is read correctly.
Viewing all 1871 articles
Browse latest View live


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