Foros: English (Thread #10792)

Problem with logicalSeeds (2006-04-15 00:36 by benjaminbellamy #21236)

I found out that sometimes (but not often enough to make me realize it sooner) the logical seeds I calculate are wrong :

// bug here :
for(int i=0 ; i<sqrtCenters ; i++) {
logicalSeeds[i] = 6 + i * (4 + 4 * version) / (sqrtCenters - 1);
logicalSeeds[i] -= (logicalSeeds[i] - 2) % 4;
}


Any idea ?
Regards,
Benjamin.

Responder al #21236×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar

Bug example (2006-04-15 00:56 by benjaminbellamy #21237)

Take a version 21 image code :
- It has a 101 pixel width.
- It has 5x5 patterns (sqrtCenters=5).
- It has 4x4 areas.

If you use my formula, logical seeds would be :
6 (ok)
26 (wrong, it should be 28)
50 (ok)
70 (wrong, it should be 72)
95 (ok)

Obviously my guessing was wrong...
Anybody has anything better ?

Benjamin.
Responder al #21236

Responder al #21237×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar

RE: Bug example (2006-04-16 01:35 by drhu00 #21258)

I think we can use following:
else if (version >= 14 && version <= 20) {
logicalSeeds = new int[4];
logicalSeeds[0] = 6;
logicalSeeds[1] = 7 + 1 * version / 2;
logicalSeeds[2] = 9 + 2 * version / 2;
logicalSeeds[3] = 10 + 4 * version;
logicalCenters = new Point[logicalSeeds.length][logicalSeeds.length];
}
else if (version >= 21 && version <= 27) {
logicalSeeds = new int[5];
logicalSeeds[0] = 6;
logicalSeeds[1] = 7 + 1 * version;
logicalSeeds[2] = 8 + 2 * version;
logicalSeeds[3] = 9 + 3 * version;
logicalSeeds[4] = 10 + 4 * version;
logicalCenters = new Point[logicalSeeds.length][logicalSeeds.length];
}

But we still need the correct cal for getCenter
Do you know some number for ver >= 28? If we know what it should be, maybe we can fihure out the formula
Responder al #21237

Responder al #21258×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar

RE: Bug example (2006-04-15 00:58 by benjaminbellamy #21238)

...it's not 95 but 94 of course...
Responder al #21236

Responder al #21238×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar

RE: Problem with logicalSeeds (2006-04-15 04:16 by drhu00 #21240)

Benjamin, in your new code, you should avoid using float. Because we try to build application for J2ME that only support CLDC 1.0 (no floating point support).
In your code AlignmentPatern.java and Point.java, change ratio from float to int.
Responder al #21236

Responder al #21240×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar

Float issue (2006-04-15 05:00 by benjaminbellamy #21241)

Ooops, sorry, I didn't see that one coming...

I will correct that ASAP.

Benjamin.
Responder al #21236

Responder al #21241×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar

RE: Problem with logicalSeeds (2006-04-16 15:58 by yanbe #21271)

Although it's ideal way to solve logical seeds by single fomula, higher version (ver>=14) seems to has irregular logical seeds.

For example, to get 28 <= ver <= 34 logical seeds we have to write code follow:

if (version >= 28 && version <= 34) {
logicalSeeds = new int[6];
logicalSeeds[0] = 6;
logicalSeeds[1] = 26;

if (version % 2 == 1) logicalSeeds[1] += 4;
if (version == 32 || version == 34) logicalSeeds[1] += 8;

int d = 0;
if (version >= 30) d += 2;
if (version >= 33) d += 2;

for (int i = 2; i < logicalSeeds.length; i++) {
logicalSeeds[i] = logicalSeeds[1] + (i - 1) * (24 + d);
}
}

Like this code, distance between seeds has some regularity. So I suggest this way as a compromise solution on ver >= 14 symbols.
Responder al #21236

Responder al #21271×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar

Irregular logicalSeeds (2006-04-18 18:53 by benjaminbellamy #21327)

If we can't find a regular formula, at least we can find a regular... array !

I suggest we used an array containing all the values.

It's fast, it's reliable, it doesn't waste much memory and it allows us to use the same code for all versions.
It just needs patience to write the table... and I already did it.

Something like that :


package jp.sourceforge.qrcode.codec.reader.pattern;

public class LogicalSeed
{

public static int[][] seed;

{
seed=new int[40][];
seed[0] = new int[] { 6 };
seed[1] = new int[] { 6, 18 };
seed[2] = new int[] { 6, 22 };
seed[3] = new int[] { 6, 26 };
seed[4] = new int[] { 6, 30 };
seed[5] = new int[] { 6, 34 };
seed[6] = new int[] { 6, 22, 38 };
seed[7] = new int[] { 6, 24, 42 };
seed[8] = new int[] { 6, 26, 46 };
seed[9] = new int[] { 6, 28, 50 };
seed[10] = new int[] { 6, 30, 54 };
seed[11] = new int[] { 6, 32, 58 };
seed[12] = new int[] { 6, 34, 62 };
seed[13] = new int[] { 6, 26, 46, 66 };
seed[14] = new int[] { 6, 26, 48, 70 };
seed[15] = new int[] { 6, 26, 50, 74 };
seed[16] = new int[] { 6, 30, 54, 78 };
seed[17] = new int[] { 6, 30, 56, 82 };
seed[18] = new int[] { 6, 30, 58, 86 };
seed[19] = new int[] { 6, 34, 62, 90 };
seed[20] = new int[] { 6, 28, 50, 72, 94 };
seed[21] = new int[] { 6, 26, 50, 74, 98 };
seed[22] = new int[] { 6, 30, 54, 78, 102 };
seed[23] = new int[] { 6, 28, 54, 80, 106 };
seed[24] = new int[] { 6, 32, 58, 84, 110 };
seed[25] = new int[] { 6, 30, 58, 86, 114 };
seed[26] = new int[] { 6, 34, 62, 90, 118 };
seed[27] = new int[] { 6, 26, 50, 74, 98, 122 };
seed[28] = new int[] { 6, 30, 54, 78, 102, 126 };
seed[29] = new int[] { 6, 26, 52, 78, 104, 130 };
seed[30] = new int[] { 6, 30, 56, 82, 108, 134 };
seed[31] = new int[] { 6, 34, 60, 86, 112, 138 };
seed[32] = new int[] { 6, 30, 58, 86, 114, 142 };
seed[33] = new int[] { 6, 34, 62, 90, 118, 146 };
seed[34] = new int[] { 6, 30, 54, 78, 102, 126, 150 };
seed[35] = new int[] { 6, 24, 50, 75, 102, 128, 154 };
seed[36] = new int[] { 6, 28, 54, 80, 106, 132, 158 };
seed[37] = new int[] { 6, 32, 58, 84, 110, 136, 162 };
seed[38] = new int[] { 6, 26, 54, 82, 110, 138, 166 };
seed[39] = new int[] { 6, 30, 58, 86, 114, 142, 170 };
}
}


Regards,
Benjamin.
Responder al #21271

Responder al #21327×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar

New LogicalSeed class (2006-04-19 04:12 by benjaminbellamy #21350)

I added a new class to get the logical seeds :
http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/qrcode/qrcode/src/jp/sourceforge/qrcode/codec/reader/pattern/LogicalSeed.java?rev=1.1&view=markup

And I replaced :

int sqrtCenters = (version / 7) + 2;
logicalSeeds = new int[sqrtCenters];
for(int i=0 ; i<sqrtCenters ; i++) {
logicalSeeds[i] = 6 + i * (4 + 4 * version) / (sqrtCenters - 1);
logicalSeeds[i] -= (logicalSeeds[i] - 2) % 4;
}

by :

logicalSeeds = LogicalSeed.getSeed(version);

in AlignmentPattern class and in QRCodeSymbol class.

Now it should work from version 1 to version 40.

Regards,
Benjamin.
Responder al #21327

Responder al #21350×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar

RE: New LogicalSeed class (2006-04-19 08:02 by drhu00 #21357)

Good job. I like the seeds table. Actually, I prefer to use simple table to replace the hard understable calculation if the value can be predetermine, mostlikely depending on the versiom. The speed is the key point in decoding.
Responder al #21350

Responder al #21357×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar