1

I'm currently working on a school project related to QR Codes generation, and i have a really huge problem with the error correction system. I found this website http://www.pclviewer.com/rs2/calculator.html, it works like a charm but it's an online tool, and i need this exact functionality ported in Java. Is there any way i can found this ? I tried the zxing class but i can't figure how to only use the Reed-Solomon part (because of course it's the only part i can use).

Thanks you all for answers, and have a good day.

Rogue
  • 751
  • 1
  • 17
  • 36

1 Answers1

2

You should use the implemenation in zxing. I know you say you couldn't figure it out, but, surely if you look at the code you see the API. It doesn't get much simpler than:

https://code.google.com/p/zxing/source/browse/trunk/core/src/main/java/com/google/zxing/common/reedsolomon/ReedSolomonEncoder.java#52

https://code.google.com/p/zxing/source/browse/trunk/core/src/main/java/com/google/zxing/common/reedsolomon/ReedSolomonDecoder.java#58

You can see how these are used, even, in QR codes:

https://code.google.com/p/zxing/source/browse/trunk/core/src/main/java/com/google/zxing/qrcode/decoder/Decoder.java#191

Sean Owen
  • 66,182
  • 23
  • 141
  • 173
  • Ok, i guess i will have to explain that i'm only using this part of the API not the whole thing... I'm gonne try this, thanks. – Rogue Nov 23 '13 at 16:45
  • Does the implementation in zxing work for general Reed Solomon encoding in Java, or is it limited to the type supported in QR Codes? The ReedSolomonEncoder API differs from [Luigi Rizzo's C++](http://info.iet.unipi.it/~luigi/fec.html) ("Effective Erasure Codes..." at that link) implementation. Various resources seem to imply that the zxing library only works for 256 bytes or less--can anyone shed some light one this? Will zxing work for general Reed Solomon encoding, or only the type required by QR Codes? – user1978019 Aug 16 '15 at 03:11
  • I don't think it's different or special as used in QR codes. I don't think API differences tell you anything. It certainly is not limited to 256 bytes -- have a look at the unit tests that encode large QR codes. I have never heard otherwise. – Sean Owen Aug 16 '15 at 19:35
  • Great, thank you. Your comment [here](http://stackoverflow.com/questions/2921599/java-ecc-error-correcting-code-library) was one of the things that made me wonder if the implementation was broadly applicable: "this implements the variant used in QR Codes and Data Matrix....For your purposes you may have to modify...". Perhaps that will make more sense as I understand the math. Thanks! – user1978019 Aug 17 '15 at 15:39
  • I think I was referring to the different generator polynomials rather than R-S itself, but I forget. I think it's generically applicable. – Sean Owen Aug 18 '15 at 08:47
  • I've figured out how to use the ReedSolomonEncoder. This leads me to another question: [it seems that](https://github.com/zxing/zxing/blob/master/core/src/test/java/com/google/zxing/common/reedsolomon/ReedSolomonTestCase.java#L428) with n data elements and k error correcting elements, a receiver requires n + k/2 elements to reconstruct the message. This is different than most other specifications I've read (eg [this paper](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.103.7089&rep=rep1&type=pdf)). I've conducted some tests that seem to bear this out. What motivates this difference? – user1978019 Aug 21 '15 at 19:40
  • No, R-S always needs 1 error-correcting codeword to fix an erasure, and 2 to fix an error. That's what the comment says. – Sean Owen Aug 22 '15 at 09:45
  • Ohhh, I see. In that case, a hopefully final question: can the zxing library be used for erasure correction? I'm out of the office so don't have my code handy to check, but am very curious. Does it recover in-place an array of size n composed of both data and ec packets? I would think it would rely on knowing not only data from ec packets (as specified by the twoS parameter), but also the index where the packet belongs, which the api doesn't seem to include. Thank you very much for the help! – user1978019 Aug 22 '15 at 20:56
  • I ended up using [this library](https://github.com/Backblaze/JavaReedSolomon) for erasure correction. This allowed me to have n data packets, k error correcting packets, and require any subset of n packets to reconstruct all data. – user1978019 Oct 10 '15 at 04:22