Invert Pixels - Zxing

Invert pixels - zxing

You don't want to print the values as characters because they aren't ASCII. Print them as unsigneds:

printf(" %u", ...);

You can simplify the loop to simply

result[i] = static_cast<unsigned char>(255 - result[i]);

The other conversions are normal integral promotion.

And you should note that ZXing uses some asymmetric heuristics when identifying codes. If you don't have a guard region surrounding the code that is, in this case, black (since the guard region is supposed to be white), it may fail to identify the code.

Zxing weird image reverse

I think I know what you have done. The data looks like RGB565 bitmap data (or something similar). You can't put such a byte array into the PlanarYUVLuminanceSource. You have to make sure that the byte array which you use with the planar source is really a array with only yuv data, not RGB565.
The rules are easy:
if you use the following code snippet

new RGBLuminanceSource(rawRgb, width, height, format)

make sure that the value of format matches the layout and data of the parameter rawRgb.
if you use somethin glike the following

new PlanarYUVLuminanceSource(yuvBytes, 640, 960, 0, 0, 640, 960, false);

make sure that yuvBytes only contains real yuv data.
I can only give a better answer if you post a more complete code sample.

Reduce border width on QR Codes generated by ZXing?

The QR spec requires a four module quiet zone and that's what zxing creates. (See QUIET_ZONE_SIZE in QRCodeWriter.renderResult.)

More recent versions of ZXing allow you to set the size of the quiet zone (basically the intrinsic padding of the QR code) by supplying an int value with the EncodeHintType.MARGIN key. Simply include it in the hints Map you supply to the Writer's encode(...) method, e.g.:

Map<EncodeHintType, Object> hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hints.put(EncodeHintType.MARGIN, 2); /* default = 4 */

If you change this, you risk lowering the decode success rate.

Decoding colored image using ZXing library in Java

It just binarizes based on the computed luminance of each pixel. Anything reasonably like dark-on-light should be fine. A thousand colors are fine. If it's light-on-dark (inverted), then you do need to invert the image or modify the code to invert the image. This is almost surely not the issue.

Distorting finder patterns is a trickier business since it's easier to make it invalid this way. You will need to preserve pretty nearly the 1:1:3:1:1 dark-light-dark-light-dark ratios scanning across the pattern horizontally and vertically. Rounding the corners a bit is fine. You couldn't for example put white space between black modules.

Can you post the original image you're trying to decode? I could tell you very quickly what's right and wrong.

Creating colored QR codes using zxing

In MatrixToImageWriter.java (which I assume you are using), under javase/ change the constant BLACK. It is an int in ARGB format and currently has value 0xFF000000. Leave the alpha value at 0xFF. Change the rest to describe your color in hex format. You can do the same with WHITE if you like.

ZXing on Android: how to set camera in negative mode?

I do not know if it completely impossible with ZXing but with ZBar it is possible!

  1. First download the ZBar android version on sourceforge:
    http://sourceforge.net/projects/zbar/files/AndroidSDK/

  2. Add project to eclipse

  3. Open CameraPreview.java

  4. Add a private var to the class:

    private Camera.Parameters mCameraParams;

  5. Add the following lines after the line: mCamera = camera; in the constructor CameraPreview:

    mCameraParams = camera.getParameters();
    mCameraParams.setColorEffect(Camera.Parameters.EFFECT_NEGATIVE);
    mCamera.setParameters(mCameraParams);

  6. That's it! (run the project)

Also think that ZBar is faster to detect damaged barcodes. Is the same as the PC-version i have used in another project and does the job very well. Blink with your eyes and the code is there. No fancy things at all, just good!

Using ZXing for scanning 0.5 x 0.5 cm code

The code needs to be black-on-white to be scanned -- scanning inverted codes is not required by the relevant specs, so most don't. Just invert it first.



Related Topics



Leave a reply



Submit