Giter VIP home page Giter VIP logo

Comments (11)

srowen avatar srowen commented on May 26, 2024

It is already possible to configure the initial size (https://github.com/zxing/zxing/blob/master/core/src/main/java/com/google/zxing/common/detector/WhiteRectangleDetector.java#L53), and that's the right answer if you are using exceptionally large images, or just know more about how big the barcode is.

from zxing.

tgibson11 avatar tgibson11 commented on May 26, 2024

That is true if I am instantiating my own Detector. But DataMatrixReader instantiates its own Detector, and I don't see any way that I could tell it to use a different one. (Except by making my own Reader implementation, which would involve duplicating a lot of code.)

from zxing.

srowen avatar srowen commented on May 26, 2024

OK what about a patch to set it to a max(INIT_SIZE, some % of image size) ?

On Mon, Feb 10, 2014 at 9:23 PM, tgibson11 [email protected] wrote:

That is true if I am instantiating my own Detector. But DataMatrixReader
instantiates its own Detector, and I don't see any way that I could tell it
to use a different one.


Reply to this email directly or view it on GitHubhttps://github.com//issues/49#issuecomment-34684016
.

from zxing.

tgibson11 avatar tgibson11 commented on May 26, 2024

Shall I make this change and submit a pull request?

from zxing.

srowen avatar srowen commented on May 26, 2024

Sure open a PR. Just try running the tests first. The only issue to watch
out for is whether the change tends to make images fail that passed before.

On Mon, Feb 10, 2014 at 9:34 PM, tgibson11 [email protected] wrote:

Shall I make this change and submit a pull request?


Reply to this email directly or view it on GitHubhttps://github.com//issues/49#issuecomment-34685222
.

from zxing.

tgibson11 avatar tgibson11 commented on May 26, 2024

This turned out to be more complicated than I first thought.

My original idea is requires the assumption that a rectangle X% of the image size is still contained inside the barcode. At least I think that is true, but you can correct me if I'm wrong. This might not be true if there is a small barcode in the center of a large image. There is also the arbitrariness of choosing a percentage.

I thought of a different approach that seems to work.

The current WhiteRectangleDetector expands the rectangle until all sides are white, which as you know might be a white area completely inside the barcode.

I propose to first expand the rectangle until each side contains at least one black point, then proceed as before.

An important assumption is that all sides of the initial rectangle are inside the barcode. I think that assumption was already being made, but it was difficult for me to be sure.

You can see my proposed changes here: https://github.com/tgibson11/zxing.

Let me know what you think.

from zxing.

srowen avatar srowen commented on May 26, 2024

Yes there is no way to know a priori where or how big the barcode is. I
think the idea is to make a guess that is likely to strike a happy medium
between working, and being fast, on images of a type that are likely to be
used.

Your assumption sounds correct and I don't see a problem with it. Of
course, you may hit the side of the image instead of something black.

Your changes don't look too hairy. If they work for your use case, and
don't cause additional images to fail the unit tests, let's commit.

On Wed, Feb 12, 2014 at 5:36 PM, tgibson11 [email protected] wrote:

This turned out to be more complicated than I first thought.

My original idea is requires the assumption that a rectangle X% of the
image size is still contained inside the barcode. At least I think that is
true, but you can correct me if I'm wrong. This might not be true if there
is a small barcode in the center of a large image. There is also the
arbitrariness of choosing a percentage.

I thought of a different approach that seems to work.

The current WhiteRectangleDetector expands the rectangle until all sides
are white, which as you know might be a white area completely inside the
barcode.

I propose to first expand the rectangle until each side contains at least
one black point, then proceed as before.

An important assumption is that all sides of the initial rectangle are
inside the barcode. I think that assumption was already being made, but it
was difficult for me to be sure.

You can see my proposed changes here: https://github.com/tgibson11/zxing.

Let me know what you think.


Reply to this email directly or view it on GitHubhttps://github.com//issues/49#issuecomment-34893978
.

from zxing.

darkpotpot avatar darkpotpot commented on May 26, 2024

Hi,

I have a similar problem with the following image
barcode_ko

The initial rectangle is not white only, so the rectangle expand correctly at the beginning. Unfortunately, it stops at the red zone on the image below because there is a white rectangle inside the datamatrix.
barcode_ko_detected
Is there a way to avoid this false area detection ?

Regards

Julien

from zxing.

srowen avatar srowen commented on May 26, 2024

The idea proposed here would probably fix this. The current heuristic is "OK" but does fall down in corner cases like this.

from zxing.

darkpotpot avatar darkpotpot commented on May 26, 2024

Maybe I misunderstood the idea proposed by tgibson, but I don't think it will change the white rectangle problem inside the datamatrix. Once a black point is found on each border, if this "starting rectangle " is inside a bigger white rectangle, it will expand up to the white rectangle but not further.

from zxing.

srowen avatar srowen commented on May 26, 2024

Hm, yeah you may have a point there. The current process is really a simplistic heuristic that happens to work quite well for images from a camera, which are not nearly so clean or axis aligned. There's a "PURE_BARCODE" mode that's intended for this particular type of image, and that ought to work -- try http://zxing.org/w/decode?u=https%3A%2F%2Fcloud.githubusercontent.com%2Fassets%2F145699%2F16151321%2Fac423ca8-349c-11e6-8035-90bfd2a3c242.png

from zxing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.