Skip to content

Fixed point math, take 2 #127

Closed
wants to merge 4 commits into from

2 participants

@andrebraga

Hi there,

Gave it a try and the results are much more acceptable now 😃 Only three tests not passing, and in my opinion the failing ones are not nearly as catastrophic as before.

2014-03-06 10:49:52.767 otest[75370:303] Rotation 0 degrees:
2014-03-06 10:49:52.767 otest[75370:303] 20 of 35 images passed (20 required)
2014-03-06 10:49:52.768 otest[75370:303] 0 failed due to misreads, 15 not detected
2014-03-06 10:49:52.768 otest[75370:303] 23 of 35 images passed with try harder (23 required)
2014-03-06 10:49:52.768 otest[75370:303] 0 failed due to misreads, 12 not detected
2014-03-06 10:49:52.768 otest[75370:303] Rotation 180 degrees:
2014-03-06 10:49:52.769 otest[75370:303] 21 of 35 images passed (22 required)
2014-03-06 10:49:52.769 otest[75370:303] 0 failed due to misreads, 14 not detected
2014-03-06 10:49:52.769 otest[75370:303] 23 of 35 images passed with try harder (23 required)
2014-03-06 10:49:52.770 otest[75370:303] 0 failed due to misreads, 12 not detected
2014-03-06 10:49:52.770 otest[75370:303] TOTALS:
Decoded 87 images out of 140 (62%, 88 required)
2014-03-06 10:49:52.770 otest[75370:303] --- Test failed by 1 images
/Users/andre/Documents/Projetos/ZXingObjC/ZXingObjCTests/common/AbstractBlackBoxTestCase.m:243: error: -[UPCABlackBox5TestCase testBlackBox] : "passedCounts[x] >= testResult.mustPassCount" should be true. Rotation 180.000000 degrees: Too many images failed
Test Case '-[UPCABlackBox5TestCase testBlackBox]' failed (14.126 seconds).
Test Suite 'UPCABlackBox5TestCase' finished at 2014-03-06 13:49:52 +0000.

One less than what was expected, not too bad...

2014-03-06 10:47:49.690 otest[75370:303] Rotation 0 degrees:
2014-03-06 10:47:49.691 otest[75370:303] 4 of 24 images passed (4 required)
2014-03-06 10:47:49.691 otest[75370:303] 1 failed due to misreads, 19 not detected
2014-03-06 10:47:49.691 otest[75370:303] 8 of 24 images passed with try harder (8 required)
2014-03-06 10:47:49.691 otest[75370:303] 2 failed due to misreads, 14 not detected
2014-03-06 10:47:49.692 otest[75370:303] Rotation 180 degrees:
2014-03-06 10:47:49.692 otest[75370:303] 3 of 24 images passed (2 required)
2014-03-06 10:47:49.692 otest[75370:303] 0 failed due to misreads, 21 not detected
2014-03-06 10:47:49.693 otest[75370:303] 8 of 24 images passed with try harder (8 required)
2014-03-06 10:47:49.693 otest[75370:303] 2 failed due to misreads, 14 not detected
2014-03-06 10:47:49.693 otest[75370:303] TOTALS:
Decoded 23 images out of 96 (23%, 22 required)
2014-03-06 10:47:49.693 otest[75370:303] +++ Test too lax by 1 images

2014-03-06 10:47:49.694 otest[75370:303] --- Test had too many misreads by 2 images
/Users/andre/Documents/Projetos/ZXingObjC/ZXingObjCTests/common/AbstractBlackBoxTestCase.m:247: error: -[RSS14BlackBox2TestCase testBlackBox] : "tryHarderMisreadCounts[x] <= testResult.maxTryHarderMisreads" should be true. Try harder, Rotation 0.000000 degrees: Too many images misread
/Users/andre/Documents/Projetos/ZXingObjC/ZXingObjCTests/common/AbstractBlackBoxTestCase.m:247: error: -[RSS14BlackBox2TestCase testBlackBox] : "tryHarderMisreadCounts[x] <= testResult.maxTryHarderMisreads" should be true. Try harder, Rotation 180.000000 degrees: Too many images misread
Test Case '-[RSS14BlackBox2TestCase testBlackBox]' failed (6.344 seconds).
Test Suite 'RSS14BlackBox2TestCase' finished at 2014-03-06 13:47:49 +0000.

One more than what was expected, now we're talking 😄

Hope you like it!

andrebraga added some commits Feb 7, 2014
@andrebraga andrebraga Parallelised luminance conversion routine and also converted floating…
… point to integer math. Difference in result from FP math is on average less than 1 level. Decent performance boost =)
5050e79
@andrebraga andrebraga Merge commit '9350ea5510ca9c0c06040af1246e619d604bd67a'
Conflicts:
	ZXingObjC/client/ZXCGImageLuminanceSource.m
192d1b7
@andrebraga andrebraga Revert "Revert the "un-premultiplying" code"
This reverts commit 02e1101.
e6eb37d
@andrebraga andrebraga Massaged the fixed point code a little bit. It turns out that shiftin…
…g up the alpha range by 1 and then subtracting 1 to force rounding down was doing more harm than good.

Also, saturating the result to 255 avoids overflows that eventually happen due to some of the liberties taken.
All in all the absolute difference in result from fixed point and floating point deviate, on average, by less than 0.03.
The fixed point code can detect a couple more images than the previous code; however it also detects a couple less. Zero sum I suppose? However it's much faster, so still a win ;)
9e2204c
@cwalcott
cwalcott commented Mar 7, 2014

I can live with that :-)! Thanks again for the work.

@cwalcott cwalcott closed this Mar 7, 2014
@cwalcott cwalcott added a commit that referenced this pull request Mar 24, 2015
@cwalcott cwalcott Ported 151ad68 from ZXing
Original commit message: "Issue #127 : fix typo in table of PDF417
punctuation chars"
a44ca81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.