C++ version is inferior to java implementation

88 views
Skip to first unread message

Oleksandr Zozulya

unread,
Aug 20, 2013, 6:06:09 AM8/20/13
to zx...@googlegroups.com

I have a couple of QR code images that can be successfully decoded by java version but fail in C++.
Is this a known problem, is there any way to increase the success of C++ version?
Example images are attached.

Unfortunately, I really need to decode images of similar quality in C++, any suggestions
for other libraries (even non-free) or an estimate how much would it take me to fix C++ version?

Thanks for the nice library!
qrc_test_5.jpg

Sean Owen

unread,
Aug 20, 2013, 6:09:13 AM8/20/13
to zx...@googlegroups.com
Steven's done a heroic job of keeping much of the C++ port in sync with Java, but I imagine there are still some differences. The Java code is the primary version.
The "fix" might be to re-port more of the Java changes, which you are welcome to do.

Oleksandr Zozulya

unread,
Aug 20, 2013, 6:15:12 AM8/20/13
to zx...@googlegroups.com
Sean,
  thanks for the answer, 
  do I understand that Steven is the only one who could estimate the work need to update the c++ fork?
  E.g. which java commit is the last one that is synchronized with cpp version?
  Btw, may be there are some hidden cpp options that I missed (--try-harder doesn't help)?

Sean Owen

unread,
Aug 20, 2013, 6:23:55 AM8/20/13
to zx...@googlegroups.com
It is not synced up to any particular version. Some things have been ported, some not, some things exist in different forms. It's more like a separate project that has been kept in an amazing amount of sync given that there was never a real port to begin with.

If you really want an exact port, you would probably have to do it from scratch. 

That said I don't think the difference can be large, since the unit tests pass on the same images. The functional result is quite similar because of Steven's work. Any individual image -- who knows.

Oleksandr Zozulya

unread,
Aug 20, 2013, 6:31:59 AM8/20/13
to zx...@googlegroups.com


That said I don't think the difference can be large, since the unit tests pass on the same images. The functional result is quite similar because of Steven's work. Any individual image -- who knows.


In my case the difference seems to by systematic - image produced by 640x480 cameras (one from mac another kinect) that quite out of focus. 
My be it's a matter of some pre-processing of images, but I tried a few  (sharpen, denoise, contrast) it did not help.

Steven Parkes

unread,
Aug 20, 2013, 9:31:35 AM8/20/13
to Oleksandr Zozulya, zx...@googlegroups.com
I have a number of backlogged changes to apply to the C++ code. In the case of QR codes, I don't believe they are a lot.

Were you testing these from static images and a command line interface or from a camera like a phone?
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "zxing" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to zxing+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> <qrc_test_5.jpg>

Oleksandr Zozulya

unread,
Aug 20, 2013, 9:52:48 AM8/20/13
to zx...@googlegroups.com, Oleksandr Zozulya
Hi Steven

Were you testing these from static images and a command line interface or from a camera like a phone?


The images that can be recognized by java but not c++  are attached in the first message.

Steven Parkes

unread,
Aug 20, 2013, 3:42:39 PM8/20/13
to Oleksandr Zozulya, zx...@googlegroups.com
Yeah, I got that but I'm not sure if you are using a phone or using the command line decoders.

Oleksandr Zozulya

unread,
Aug 20, 2013, 6:39:37 PM8/20/13
to zx...@googlegroups.com, Oleksandr Zozulya


Yeah, I got that but I'm not sure if you are using a phone or using the command line decoders.


I run it from command line, can you reproduce the results?

Oleksandr Zozulya

unread,
Aug 22, 2013, 5:28:48 AM8/22/13
to zx...@googlegroups.com, Oleksandr Zozulya
Hi Steven, I'd still want to come back to this issue, if you have time to discuss.

Do you think it's easy to track down when the differences arise between java and c++
versions, like logging all the intermediate steps and comparing  the results? (e.g. compare images
after binarization step could be ther first thing to check).
 Although we currently decided just to use a better camera in our project, I'd like to understand
the work-flow of computations for my own benefit. I'm talking only about QRC detection.

Steven Parkes

unread,
Aug 22, 2013, 8:22:00 AM8/22/13
to Oleksandr Zozulya, zx...@googlegroups.com
It's on my list list to look at. I generally only have time to look at zxing on the weekends.

I need to see if there are any pending changes in the Java that no one's had time to port to C++. (I keep the patch emails around until I get a chance to port them). Otherwise, yeah, I use a divide and conquer approach: figure out if it's the detector or decoder, look at the alignment pattern detector results. Since these are coming in as jpgs, Sometimes it's the original image formats due to lossy jpg reconstruction differences or color space issues.

I can try to make time this weekend, but I can't promise results.

Oleksandr Zozulya

unread,
Aug 23, 2013, 6:29:27 AM8/23/13
to zx...@googlegroups.com, Oleksandr Zozulya
Hi Steven,
 thanks. I'll also try to dig into the code, is there some "helicopter description" of the algorithms involved?
Or should I just go through the code? I have experience in comp vision, but not in the area of qr detection.
 My strong suspicion is that the difference is due to  out of focus images. Java version
handles them well, c++ not.

On the other note, you may be pleased to hear that I've tested a few other libraries, also commercial,
 and zxing so far beats them. 

Oleksandr Zozulya

unread,
Aug 23, 2013, 10:23:58 AM8/23/13
to zx...@googlegroups.com, Oleksandr Zozulya
A bit of debugging shows that the QR bits are extracted, but then reader cannot decode them and
throws exception.

Oleksandr Zozulya

unread,
Aug 23, 2013, 9:46:39 PM8/23/13
to zx...@googlegroups.com, Oleksandr Zozulya
Hi, I found the solution.

The attached images are actually mirrored from the real ones.
(that's the stream given by photo booth for example)
I knew about it, but because Java implementation can deal with it,
I did attach importance to it.
Does it make sense? Is there an extra check for a mirrored image in Java that absent in C++?

Sean Owen

unread,
Aug 24, 2013, 4:20:23 AM8/24/13
to zx...@googlegroups.com
Yeah it recently added a check for mirrored QR codes since it can finally be done efficiently. These codes are invalid though.

Oleksandr Zozulya

unread,
Aug 26, 2013, 11:56:31 AM8/26/13
to zx...@googlegroups.com
well, one one hand it makes sense, it's faster to mirror bitmatrix, rather than whole image,
but technically it is better to give a warning, so some people won't be confused, like me.
I updated for my needs the c++ code to include inversion like in Java code.
If you want, I can commit the changes.

Steven Parkes

unread,
Aug 26, 2013, 12:29:20 PM8/26/13
to zx...@googlegroups.com, Oleksandr Zozulya

On Aug 22, 2013, at 5:22 AM, Steven Parkes <smpa...@smparkes.net> wrote:

> I can try to make time this weekend, but I can't promise results.

Server melt down last week that I'm still recovering from, so we're looking at this weekend … it's long, so ….

Oleksandr Zozulya

unread,
Sep 24, 2013, 10:07:01 AM9/24/13
to zx...@googlegroups.com, Oleksandr Zozulya
Hi Steven,
 to revive the issue.

 I've made small changes in cpp code to support mirrored images like in Java,
  would you like me to submit the changes? Internally we use our the modified version,
  but we'd prefer it to be synchronized with the open-sourced repository.

Steven Parkes

unread,
Sep 24, 2013, 10:14:06 AM9/24/13
to Oleksandr Zozulya, zx...@googlegroups.com
That sounds good. Did you submit a patch/issue?

Oleksandr Zozulya

unread,
Sep 25, 2013, 5:55:26 AM9/25/13
to zx...@googlegroups.com, Oleksandr Zozulya
No, that's the question, what is the procedure to submit and review patches/changes?
I originally cloned repository from gihub. 
Is the preferred way to create an issue and submit a patch?

Steven Parkes

unread,
Sep 25, 2013, 4:09:11 PM9/25/13
to Oleksandr Zozulya, zx...@googlegroups.com
Cloned or forked?

If you forked, you can always submit a pull request. We don't actually merge via the pull requests, but they're a reasonable way of generating a patch and I can easily grab the commit as necessary.

Actually, even if you didn't fork, you can just push to github and I can similarly cherrypick from there. You can also generate a patch with "git diff".
Reply all
Reply to author
Forward
0 new messages